Struct UltrasonicSensor

Source
pub struct UltrasonicSensor { /* private fields */ }
Expand description

LEGO EV3 ultrasonic sensor.

Implementations§

Source§

impl UltrasonicSensor

Source

pub const MODE_US_DIST_CM: &'static str = "US-DIST-CM"

Continuous measurement - sets LEDs on, steady. Units in centimeters. Distance (0-2550)

Source

pub const MODE_US_DIST_IN: &'static str = "US-DIST-IN"

Continuous measurement - sets LEDs on, steady. Units in inches. Distance (0-1003)

Source

pub const MODE_US_LISTEN: &'static str = "US-LISTEN"

Listen - sets LEDs on, blinking. Presence (0-1) #

Source

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)

Source

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)

Source

pub const MODE_US_DC_CM: &'static str = "US-DC-CM"

??? - sets LEDs on, steady. Units in centimeters. Distance (0-2550)

Source

pub const MODE_US_DC_IN: &'static str = "US-DC-IN"

??? - sets LEDs on, steady. Units in inches. Distance (0-1003)

Source

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.

Source

pub fn find() -> Ev3Result<Self>

Try to find a Self. Only returns a motor if their is exactly one connected, Error::NotFound otherwise.

Source

pub fn list() -> Ev3Result<Vec<Self>>

Extract list of connected ‘Self’

Source

pub fn set_mode_us_dist_cm(&self) -> Ev3Result<()>

Continuous measurement - sets LEDs on, steady. Units in centimeters. Distance (0-2550)

Source

pub fn is_mode_us_dist_cm(&self) -> Ev3Result<bool>

Continuous measurement - sets LEDs on, steady. Units in centimeters. Distance (0-2550)

Source

pub fn set_mode_us_dist_in(&self) -> Ev3Result<()>

Continuous measurement - sets LEDs on, steady. Units in inches. Distance (0-1003)

Source

pub fn is_mode_us_dist_in(&self) -> Ev3Result<bool>

Continuous measurement - sets LEDs on, steady. Units in inches. Distance (0-1003)

Source

pub fn set_mode_us_listen(&self) -> Ev3Result<()>

Listen - sets LEDs on, blinking. Presence (0-1) #

Source

pub fn is_mode_us_listen(&self) -> Ev3Result<bool>

Listen - sets LEDs on, blinking. Presence (0-1) #

Source

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)

Source

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)

Source

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)

Source

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)

Source

pub fn set_mode_us_dc_cm(&self) -> Ev3Result<()>

??? - sets LEDs on, steady. Units in centimeters. Distance (0-2550)

Source

pub fn is_mode_us_dc_cm(&self) -> Ev3Result<bool>

??? - sets LEDs on, steady. Units in centimeters. Distance (0-2550)

Source

pub fn set_mode_us_dc_in(&self) -> Ev3Result<()>

??? - sets LEDs on, steady. Units in inches. Distance (0-1003)

Source

pub fn is_mode_us_dc_in(&self) -> Ev3Result<bool>

??? - sets LEDs on, steady. Units in inches. Distance (0-1003)

Source

pub fn get_distance(&self) -> Ev3Result<i32>

Measurement of the distance detected by the sensor, unscaled.

Source

pub fn get_distance_centimeters(&self) -> Ev3Result<f32>

Measurement of the distance detected by the sensor, in centimeters.

Source

pub fn get_distance_inches(&self) -> Ev3Result<f32>

Measurement of the distance detected by the sensor, in inches.

Trait Implementations§

Source§

impl Clone for UltrasonicSensor

Source§

fn clone(&self) -> UltrasonicSensor

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UltrasonicSensor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Device for UltrasonicSensor

Source§

fn get_attribute(&self, name: &str) -> Attribute

Returns the attribute wrapper for an attribute name.
Source§

fn get_address(&self) -> Ev3Result<String>

Returns the name of the port that the motor is connected to.
Source§

fn set_command(&self, command: &str) -> Ev3Result<()>

Sends a command to the device controller.
Source§

fn get_commands(&self) -> Ev3Result<Vec<String>>

Returns a space separated list of commands that are supported by the device controller.
Source§

fn get_driver_name(&self) -> Ev3Result<String>

Returns the name of the driver that provides this device.
Source§

impl Sensor for UltrasonicSensor

Source§

fn get_bin_data(&self) -> Ev3Result<String>

Reading the file will give the unscaled raw values in the 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>

Returns the format of the values in bin_data for the current mode. Possible values are:
Source§

fn get_decimals(&self) -> Ev3Result<i32>

Returns the number of decimal places for the values in the value<N> attributes of the current mode.
Source§

fn get_fw_version(&self) -> Ev3Result<String>

Returns the firmware version of the sensor if available. Currently only NXT/I2C sensors support this.
Source§

fn get_mode(&self) -> Ev3Result<String>

Returns the current mode. See the individual sensor documentation for a description of the modes available for each type of sensor.
Source§

fn set_mode(&self, mode: &str) -> Ev3Result<()>

Sets the sensor to that mode. See the individual sensor documentation for a description of the modes available for each type of sensor.
Source§

fn get_modes(&self) -> Ev3Result<Vec<String>>

Returns a list of the valid modes for the sensor.
Source§

fn get_num_values(&self) -> Ev3Result<i32>

Returns the number of value<N> attributes that will return a valid value for the current mode.
Source§

fn get_poll_ms(&self) -> Ev3Result<i32>

Returns the polling period of the sensor in milliseconds. Returns -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<()>

Sets the polling period of the sensor in milliseconds. Setting to 0 disables polling. 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 get_units(&self) -> Ev3Result<String>

Returns the units of the measured value for the current mode. May return empty string if units are unknown.
Source§

fn get_value(&self, index: u8) -> Ev3Result<i32>

Returns the current value{index} value if available.
Source§

fn get_value0(&self) -> Ev3Result<i32>

Returns the current value0 value if available.
Source§

fn get_value1(&self) -> Ev3Result<i32>

Returns the current value1 value if available.
Source§

fn get_value2(&self) -> Ev3Result<i32>

Returns the current value2 value if available.
Source§

fn get_value3(&self) -> Ev3Result<i32>

Returns the current value3 value if available.
Source§

fn get_value4(&self) -> Ev3Result<i32>

Returns the current value4 value if available.
Source§

fn get_value5(&self) -> Ev3Result<i32>

Returns the current value5 value if available.
Source§

fn get_value6(&self) -> Ev3Result<i32>

Returns the current value6 value if available.
Source§

fn get_value7(&self) -> Ev3Result<i32>

Returns the current value7 value if available.
Source§

fn get_text_value(&self) -> Ev3Result<String>

Returns a space delimited string representing sensor-specific text values. Returns -EOPNOTSUPP if a sensor does not support text values.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.