Struct ev3dev_lang_rust::sensors::UltrasonicSensor
source · pub struct UltrasonicSensor { /* private fields */ }Expand description
LEGO EV3 ultrasonic sensor.
Implementations§
source§impl UltrasonicSensor
impl UltrasonicSensor
sourcepub fn get(port: SensorPort) -> Ev3Result<Self>
pub fn get(port: SensorPort) -> Ev3Result<Self>
Try to get a Self on the given port. Returns None if port is not used or another device is connected.
sourcepub fn find() -> Ev3Result<Self>
pub fn find() -> Ev3Result<Self>
Try to find a Self. Only returns a motor if their is exactly one connected, Error::NotFound otherwise.
sourcepub const MODE_US_DIST_CM: &'static str = "US-DIST-CM"
pub const MODE_US_DIST_CM: &'static str = "US-DIST-CM"
Continuous measurement - sets LEDs on, steady. Units in centimeters. Distance (0-2550)
sourcepub fn set_mode_us_dist_cm(&self) -> Ev3Result<()>
pub fn set_mode_us_dist_cm(&self) -> Ev3Result<()>
Continuous measurement - sets LEDs on, steady. Units in centimeters. Distance (0-2550)
sourcepub fn is_mode_us_dist_cm(&self) -> Ev3Result<bool>
pub fn is_mode_us_dist_cm(&self) -> Ev3Result<bool>
Continuous measurement - sets LEDs on, steady. Units in centimeters. Distance (0-2550)
sourcepub const MODE_US_DIST_IN: &'static str = "US-DIST-IN"
pub const MODE_US_DIST_IN: &'static str = "US-DIST-IN"
Continuous measurement - sets LEDs on, steady. Units in inches. Distance (0-1003)
sourcepub fn set_mode_us_dist_in(&self) -> Ev3Result<()>
pub fn set_mode_us_dist_in(&self) -> Ev3Result<()>
Continuous measurement - sets LEDs on, steady. Units in inches. Distance (0-1003)
sourcepub fn is_mode_us_dist_in(&self) -> Ev3Result<bool>
pub fn is_mode_us_dist_in(&self) -> Ev3Result<bool>
Continuous measurement - sets LEDs on, steady. Units in inches. Distance (0-1003)
sourcepub const MODE_US_LISTEN: &'static str = "US-LISTEN"
pub const MODE_US_LISTEN: &'static str = "US-LISTEN"
Listen - sets LEDs on, blinking. Presence (0-1) #
sourcepub fn set_mode_us_listen(&self) -> Ev3Result<()>
pub fn set_mode_us_listen(&self) -> Ev3Result<()>
Listen - sets LEDs on, blinking. Presence (0-1) #
sourcepub fn is_mode_us_listen(&self) -> Ev3Result<bool>
pub fn is_mode_us_listen(&self) -> Ev3Result<bool>
Listen - sets LEDs on, blinking. Presence (0-1) #
sourcepub const MODE_US_SI_CM: &'static str = "US-SI-CM"
pub const MODE_US_SI_CM: &'static str = "US-SI-CM"
Single measurement - LEDs on momentarily when mode is set, then off. Units in centimeters. Distance (0-2550)
sourcepub fn set_mode_us_si_cm(&self) -> Ev3Result<()>
pub fn set_mode_us_si_cm(&self) -> Ev3Result<()>
Single measurement - LEDs on momentarily when mode is set, then off. Units in centimeters. Distance (0-2550)
sourcepub fn is_mode_us_si_cm(&self) -> Ev3Result<bool>
pub fn is_mode_us_si_cm(&self) -> Ev3Result<bool>
Single measurement - LEDs on momentarily when mode is set, then off. Units in centimeters. Distance (0-2550)
sourcepub const MODE_US_SI_IN: &'static str = "US-SI-IN"
pub const MODE_US_SI_IN: &'static str = "US-SI-IN"
Single measurement - LEDs on momentarily when mode is set, then off. Units in inches. Distance (0-1003)
sourcepub fn set_mode_us_si_in(&self) -> Ev3Result<()>
pub fn set_mode_us_si_in(&self) -> Ev3Result<()>
Single measurement - LEDs on momentarily when mode is set, then off. Units in inches. Distance (0-1003)
sourcepub fn is_mode_us_si_in(&self) -> Ev3Result<bool>
pub fn is_mode_us_si_in(&self) -> Ev3Result<bool>
Single measurement - LEDs on momentarily when mode is set, then off. Units in inches. Distance (0-1003)
sourcepub const MODE_US_DC_CM: &'static str = "US-DC-CM"
pub const MODE_US_DC_CM: &'static str = "US-DC-CM"
??? - sets LEDs on, steady. Units in centimeters. Distance (0-2550)
sourcepub fn set_mode_us_dc_cm(&self) -> Ev3Result<()>
pub fn set_mode_us_dc_cm(&self) -> Ev3Result<()>
??? - sets LEDs on, steady. Units in centimeters. Distance (0-2550)
sourcepub fn is_mode_us_dc_cm(&self) -> Ev3Result<bool>
pub fn is_mode_us_dc_cm(&self) -> Ev3Result<bool>
??? - sets LEDs on, steady. Units in centimeters. Distance (0-2550)
sourcepub const MODE_US_DC_IN: &'static str = "US-DC-IN"
pub const MODE_US_DC_IN: &'static str = "US-DC-IN"
??? - sets LEDs on, steady. Units in inches. Distance (0-1003)
sourcepub fn set_mode_us_dc_in(&self) -> Ev3Result<()>
pub fn set_mode_us_dc_in(&self) -> Ev3Result<()>
??? - sets LEDs on, steady. Units in inches. Distance (0-1003)
sourcepub fn is_mode_us_dc_in(&self) -> Ev3Result<bool>
pub fn is_mode_us_dc_in(&self) -> Ev3Result<bool>
??? - sets LEDs on, steady. Units in inches. Distance (0-1003)
sourcepub fn get_distance(&self) -> Ev3Result<i32>
pub fn get_distance(&self) -> Ev3Result<i32>
Measurement of the distance detected by the sensor, unscaled.
sourcepub fn get_distance_centimeters(&self) -> Ev3Result<f32>
pub fn get_distance_centimeters(&self) -> Ev3Result<f32>
Measurement of the distance detected by the sensor, in centimeters.
sourcepub fn get_distance_inches(&self) -> Ev3Result<f32>
pub fn get_distance_inches(&self) -> Ev3Result<f32>
Measurement of the distance detected by the sensor, in centimeters.
Trait Implementations§
source§impl Clone for UltrasonicSensor
impl Clone for UltrasonicSensor
source§fn clone(&self) -> UltrasonicSensor
fn clone(&self) -> UltrasonicSensor
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for UltrasonicSensor
impl Debug for UltrasonicSensor
source§impl Device for UltrasonicSensor
impl Device for UltrasonicSensor
source§fn get_attribute(&self, name: &str) -> Attribute
fn get_attribute(&self, name: &str) -> Attribute
source§fn get_address(&self) -> Ev3Result<String>
fn get_address(&self) -> Ev3Result<String>
source§fn set_command(&self, command: &str) -> Ev3Result<()>
fn set_command(&self, command: &str) -> Ev3Result<()>
source§fn get_commands(&self) -> Ev3Result<Vec<String>>
fn get_commands(&self) -> Ev3Result<Vec<String>>
source§fn get_driver_name(&self) -> Ev3Result<String>
fn get_driver_name(&self) -> Ev3Result<String>
source§impl Sensor for UltrasonicSensor
impl Sensor for UltrasonicSensor
source§fn get_bin_data(&self) -> Ev3Result<String>
fn get_bin_data(&self) -> Ev3Result<String>
value<N> attributes.
Use bin_data_format, num_values and the individual sensor documentation to determine how to interpret the data.source§fn get_bin_data_format(&self) -> Ev3Result<String>
fn get_bin_data_format(&self) -> Ev3Result<String>
bin_data for the current mode. Possible values are:source§fn get_decimals(&self) -> Ev3Result<i32>
fn get_decimals(&self) -> Ev3Result<i32>
value<N> attributes of the current mode.source§fn get_fw_version(&self) -> Ev3Result<String>
fn get_fw_version(&self) -> Ev3Result<String>
source§fn get_mode(&self) -> Ev3Result<String>
fn get_mode(&self) -> Ev3Result<String>
source§fn set_mode(&self, mode: &str) -> Ev3Result<()>
fn set_mode(&self, mode: &str) -> Ev3Result<()>
source§fn get_modes(&self) -> Ev3Result<Vec<String>>
fn get_modes(&self) -> Ev3Result<Vec<String>>
source§fn get_num_values(&self) -> Ev3Result<i32>
fn get_num_values(&self) -> Ev3Result<i32>
value<N> attributes that will return a valid value for the current mode.source§fn get_poll_ms(&self) -> Ev3Result<i32>
fn get_poll_ms(&self) -> Ev3Result<i32>
-EOPNOTSUPP if changing polling is not supported.
Note: Setting poll_ms too high can cause the input port auto detection to fail.
If this happens, use the mode attribute of the port to force the port to nxt-i2c mode. Values must not be negative.source§fn set_poll_ms(&self, poll_ms: i32) -> Ev3Result<()>
fn set_poll_ms(&self, poll_ms: i32) -> Ev3Result<()>
nxt-i2c mode. Values must not be negative.source§fn get_units(&self) -> Ev3Result<String>
fn get_units(&self) -> Ev3Result<String>
source§fn get_value(&self, index: u8) -> Ev3Result<i32>
fn get_value(&self, index: u8) -> Ev3Result<i32>
value{index} value if available.source§fn get_value0(&self) -> Ev3Result<i32>
fn get_value0(&self) -> Ev3Result<i32>
value0 value if available.source§fn get_value1(&self) -> Ev3Result<i32>
fn get_value1(&self) -> Ev3Result<i32>
value1 value if available.source§fn get_value2(&self) -> Ev3Result<i32>
fn get_value2(&self) -> Ev3Result<i32>
value2 value if available.source§fn get_value3(&self) -> Ev3Result<i32>
fn get_value3(&self) -> Ev3Result<i32>
value3 value if available.source§fn get_value4(&self) -> Ev3Result<i32>
fn get_value4(&self) -> Ev3Result<i32>
value4 value if available.source§fn get_value5(&self) -> Ev3Result<i32>
fn get_value5(&self) -> Ev3Result<i32>
value5 value if available.source§fn get_value6(&self) -> Ev3Result<i32>
fn get_value6(&self) -> Ev3Result<i32>
value6 value if available.source§fn get_value7(&self) -> Ev3Result<i32>
fn get_value7(&self) -> Ev3Result<i32>
value7 value if available.source§fn get_text_value(&self) -> Ev3Result<String>
fn get_text_value(&self) -> Ev3Result<String>
-EOPNOTSUPP if a sensor does not support text values.