ev3dev_lang_rust/
lib.rs

1#![deny(missing_docs)]
2#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
3
4//! # Rust language bindings for ev3dev
5//!
6//! ```no_run
7//! extern crate ev3dev_lang_rust;
8//!
9//! use ev3dev_lang_rust::Ev3Result;
10//! use ev3dev_lang_rust::motors::{LargeMotor, MotorPort};
11//! use ev3dev_lang_rust::sensors::ColorSensor;
12//!
13//! fn main() -> Ev3Result<()> {
14//!
15//!     // Get large motor on port outA.
16//!     let large_motor = LargeMotor::get(MotorPort::OutA)?;
17//!
18//!     // Set command "run-direct".
19//!     large_motor.run_direct()?;
20//!
21//!     // Run motor.
22//!     large_motor.set_duty_cycle_sp(50)?;
23//!
24//!     // Find color sensor. Always returns the first recognized one.
25//!     let color_sensor = ColorSensor::find()?;
26//!
27//!     // Switch to rgb mode.
28//!     color_sensor.set_mode_rgb_raw()?;
29//!
30//!     // Get current rgb color tuple.
31//!     println!("Current rgb color: {:?}", color_sensor.get_rgb()?);
32//!
33//!     Ok(())
34//! }
35//! ```
36
37#[cfg(feature = "screen")]
38extern crate framebuffer;
39
40#[cfg(feature = "screen")]
41extern crate image;
42
43#[macro_use]
44extern crate ev3dev_lang_rust_derive;
45extern crate libc;
46extern crate paste;
47
48#[macro_use]
49mod findable;
50
51#[macro_use]
52mod ev3_button_functions;
53
54mod attribute;
55pub use attribute::Attribute;
56mod driver;
57pub use driver::Driver;
58#[cfg(feature = "override-driver-path")]
59pub use driver::DRIVER_PATH;
60mod device;
61pub use device::Device;
62
63mod utils;
64pub use utils::{Ev3Error, Ev3Result, Port};
65
66pub mod wait;
67
68pub mod motors;
69pub mod sensors;
70
71#[cfg(feature = "ev3")]
72mod ev3;
73#[cfg(feature = "ev3")]
74pub use ev3::Button;
75#[cfg(feature = "ev3")]
76pub use ev3::Led;
77#[cfg(feature = "ev3")]
78mod port_constants {
79    pub const OUTPUT_A: &str = "outA";
80    pub const OUTPUT_B: &str = "outB";
81    pub const OUTPUT_C: &str = "outC";
82    pub const OUTPUT_D: &str = "outD";
83
84    pub const INPUT_1: &str = "in1";
85    pub const INPUT_2: &str = "in2";
86    pub const INPUT_3: &str = "in3";
87    pub const INPUT_4: &str = "in4";
88}
89
90#[cfg(feature = "brickpi")]
91mod brickpi;
92#[cfg(feature = "brickpi")]
93pub use brickpi::Led;
94#[cfg(feature = "brickpi")]
95mod port_constants {
96    pub const OUTPUT_A: &str = "serial0-0:MA";
97    pub const OUTPUT_B: &str = "serial0-0:MB";
98    pub const OUTPUT_C: &str = "serial0-0:MC";
99    pub const OUTPUT_D: &str = "serial0-0:MD";
100
101    pub const INPUT_1: &str = "serial0-0:S1";
102    pub const INPUT_2: &str = "serial0-0:S2";
103    pub const INPUT_3: &str = "serial0-0:S3";
104    pub const INPUT_4: &str = "serial0-0:S4";
105}
106
107#[cfg(feature = "brickpi3")]
108mod brickpi3;
109#[cfg(feature = "brickpi3")]
110pub use brickpi3::Led;
111#[cfg(feature = "brickpi3")]
112mod port_constants {
113    pub const OUTPUT_A: &str = "spi0.1:MA";
114    pub const OUTPUT_B: &str = "spi0.1:MB";
115    pub const OUTPUT_C: &str = "spi0.1:MC";
116    pub const OUTPUT_D: &str = "spi0.1:MD";
117
118    pub const INPUT_1: &str = "spi0.1:S1";
119    pub const INPUT_2: &str = "spi0.1:S2";
120    pub const INPUT_3: &str = "spi0.1:S3";
121    pub const INPUT_4: &str = "spi0.1:S4";
122}
123
124pub mod sound;
125
126mod power_supply;
127pub use power_supply::PowerSupply;
128
129#[cfg(feature = "screen")]
130mod screen;
131#[cfg(feature = "screen")]
132pub use screen::Screen;