ev3dev_lang_rust/motors/
mod.rs1#[macro_use]
4mod dc_motor_macro;
5#[macro_use]
6mod servo_motor_macro;
7#[macro_use]
8mod tacho_motor_macro;
9
10mod large_motor;
11pub use self::large_motor::LargeMotor;
12
13mod medium_motor;
14pub use self::medium_motor::MediumMotor;
15
16mod tacho_motor;
17pub use self::tacho_motor::TachoMotor;
18
19use crate::{port_constants, Port};
20
21#[derive(Debug, Copy, Clone)]
23pub enum MotorPort {
24 OutA,
26 OutB,
28 OutC,
30 OutD,
32}
33
34impl MotorPort {
35 pub fn format_name(name: &str) -> String {
37 match name {
38 "motor0" => MotorPort::OutA.address(),
39 "motor1" => MotorPort::OutB.address(),
40 "motor2" => MotorPort::OutC.address(),
41 "motor3" => MotorPort::OutD.address(),
42 _ => name.to_owned(),
43 }
44 }
45}
46
47impl Port for MotorPort {
48 fn address(&self) -> String {
49 match self {
50 MotorPort::OutA => port_constants::OUTPUT_A.to_owned(),
51 MotorPort::OutB => port_constants::OUTPUT_B.to_owned(),
52 MotorPort::OutC => port_constants::OUTPUT_C.to_owned(),
53 MotorPort::OutD => port_constants::OUTPUT_D.to_owned(),
54 }
55 }
56}