Struct ev3dev_lang_rust::sensors::InfraredSensor
source · [−]pub struct InfraredSensor { /* private fields */ }Expand description
LEGO EV3 infrared sensor.
Implementations
sourceimpl InfraredSensor
impl InfraredSensor
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_IR_PROX: &'static str = "IR-PROX"
pub const MODE_IR_PROX: &'static str = "IR-PROX"
Proximity
sourcepub fn set_mode_ir_prox(&self) -> Ev3Result<()>
pub fn set_mode_ir_prox(&self) -> Ev3Result<()>
Proximity
sourcepub fn is_mode_ir_prox(&self) -> Ev3Result<bool>
pub fn is_mode_ir_prox(&self) -> Ev3Result<bool>
Proximity
sourcepub const MODE_IR_SEEK: &'static str = "IR-SEEK"
pub const MODE_IR_SEEK: &'static str = "IR-SEEK"
IR Seeker
sourcepub fn set_mode_ir_seek(&self) -> Ev3Result<()>
pub fn set_mode_ir_seek(&self) -> Ev3Result<()>
IR Seeker
sourcepub fn is_mode_ir_seek(&self) -> Ev3Result<bool>
pub fn is_mode_ir_seek(&self) -> Ev3Result<bool>
IR Seeker
sourcepub const MODE_IR_REMOTE: &'static str = "IR-REMOTE"
pub const MODE_IR_REMOTE: &'static str = "IR-REMOTE"
IR Remote Control
sourcepub fn set_mode_ir_remote(&self) -> Ev3Result<()>
pub fn set_mode_ir_remote(&self) -> Ev3Result<()>
IR Remote Control
sourcepub fn is_mode_ir_remote(&self) -> Ev3Result<bool>
pub fn is_mode_ir_remote(&self) -> Ev3Result<bool>
IR Remote Control
sourcepub const MODE_IR_REM_A: &'static str = "IR-REM-A"
pub const MODE_IR_REM_A: &'static str = "IR-REM-A"
IR Remote Control
sourcepub fn set_mode_ir_rem_a(&self) -> Ev3Result<()>
pub fn set_mode_ir_rem_a(&self) -> Ev3Result<()>
IR Remote Control
sourcepub fn is_mode_ir_rem_a(&self) -> Ev3Result<bool>
pub fn is_mode_ir_rem_a(&self) -> Ev3Result<bool>
IR Remote Control
sourcepub const MODE_IR_S_ALT: &'static str = "IR-S-ALT"
pub const MODE_IR_S_ALT: &'static str = "IR-S-ALT"
Alternate IR Seeker ???
sourcepub fn set_mode_ir_s_alt(&self) -> Ev3Result<()>
pub fn set_mode_ir_s_alt(&self) -> Ev3Result<()>
Alternate IR Seeker ???
sourcepub fn is_mode_ir_s_alt(&self) -> Ev3Result<bool>
pub fn is_mode_ir_s_alt(&self) -> Ev3Result<bool>
Alternate IR Seeker ???
sourcepub const MODE_IR_CAL: &'static str = "IR-CAL"
pub const MODE_IR_CAL: &'static str = "IR-CAL"
Calibration ???
sourcepub fn set_mode_ir_cal(&self) -> Ev3Result<()>
pub fn set_mode_ir_cal(&self) -> Ev3Result<()>
Calibration ???
sourcepub fn is_mode_ir_cal(&self) -> Ev3Result<bool>
pub fn is_mode_ir_cal(&self) -> Ev3Result<bool>
Calibration ???
sourcepub fn get_distance(&self) -> Ev3Result<i32>
pub fn get_distance(&self) -> Ev3Result<i32>
Get the proximity distance, in the range 0-100 (pct).
Trait Implementations
sourceimpl Clone for InfraredSensor
impl Clone for InfraredSensor
sourcefn clone(&self) -> InfraredSensor
fn clone(&self) -> InfraredSensor
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for InfraredSensor
impl Debug for InfraredSensor
sourceimpl Device for InfraredSensor
impl Device for InfraredSensor
sourcefn get_attribute(&self, name: &str) -> Attribute
fn get_attribute(&self, name: &str) -> Attribute
Returns the attribute wrapper for an attribute name.
sourcefn get_address(&self) -> Ev3Result<String>
fn get_address(&self) -> Ev3Result<String>
Returns the name of the port that the motor is connected to.
sourcefn set_command(&self, command: &str) -> Ev3Result<()>
fn set_command(&self, command: &str) -> Ev3Result<()>
Sends a command to the device controller.
sourcefn get_commands(&self) -> Ev3Result<Vec<String>>
fn get_commands(&self) -> Ev3Result<Vec<String>>
Returns a space separated list of commands that are supported by the device controller.
sourcefn get_driver_name(&self) -> Ev3Result<String>
fn get_driver_name(&self) -> Ev3Result<String>
Returns the name of the driver that provides this device.
sourceimpl Sensor for InfraredSensor
impl Sensor for InfraredSensor
sourcefn get_bin_data(&self) -> Ev3Result<String>
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. Read more
sourcefn get_bin_data_format(&self) -> Ev3Result<String>
fn get_bin_data_format(&self) -> Ev3Result<String>
Returns the format of the values in bin_data for the current mode. Possible values are:
sourcefn get_decimals(&self) -> Ev3Result<i32>
fn get_decimals(&self) -> Ev3Result<i32>
Returns the number of decimal places for the values in the value<N> attributes of the current mode.
sourcefn get_fw_version(&self) -> Ev3Result<String>
fn get_fw_version(&self) -> Ev3Result<String>
Returns the firmware version of the sensor if available. Currently only NXT/I2C sensors support this. Read more
sourcefn get_mode(&self) -> Ev3Result<String>
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. Read more
sourcefn set_mode(&self, mode: &str) -> Ev3Result<()>
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. Read more
sourcefn get_modes(&self) -> Ev3Result<Vec<String>>
fn get_modes(&self) -> Ev3Result<Vec<String>>
Returns a list of the valid modes for the sensor.
sourcefn get_num_values(&self) -> Ev3Result<i32>
fn get_num_values(&self) -> Ev3Result<i32>
Returns the number of value<N> attributes that will return a valid value for the current mode.
sourcefn get_poll_ms(&self) -> Ev3Result<i32>
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. Read more
sourcefn set_poll_ms(&self, poll_ms: i32) -> Ev3Result<()>
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. Read more
sourcefn get_units(&self) -> Ev3Result<String>
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.
sourcefn get_value(&self, index: u8) -> Ev3Result<i32>
fn get_value(&self, index: u8) -> Ev3Result<i32>
Returns the current value{index} value if available.
sourcefn get_value0(&self) -> Ev3Result<i32>
fn get_value0(&self) -> Ev3Result<i32>
Returns the current value0 value if available.
sourcefn get_value1(&self) -> Ev3Result<i32>
fn get_value1(&self) -> Ev3Result<i32>
Returns the current value1 value if available.
sourcefn get_value2(&self) -> Ev3Result<i32>
fn get_value2(&self) -> Ev3Result<i32>
Returns the current value2 value if available.
sourcefn get_value3(&self) -> Ev3Result<i32>
fn get_value3(&self) -> Ev3Result<i32>
Returns the current value3 value if available.
sourcefn get_value4(&self) -> Ev3Result<i32>
fn get_value4(&self) -> Ev3Result<i32>
Returns the current value4 value if available.
sourcefn get_value5(&self) -> Ev3Result<i32>
fn get_value5(&self) -> Ev3Result<i32>
Returns the current value5 value if available.
sourcefn get_value6(&self) -> Ev3Result<i32>
fn get_value6(&self) -> Ev3Result<i32>
Returns the current value6 value if available.
sourcefn get_value7(&self) -> Ev3Result<i32>
fn get_value7(&self) -> Ev3Result<i32>
Returns the current value7 value if available.
sourcefn get_text_value(&self) -> Ev3Result<String>
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
impl !RefUnwindSafe for InfraredSensor
impl Send for InfraredSensor
impl !Sync for InfraredSensor
impl Unpin for InfraredSensor
impl UnwindSafe for InfraredSensor
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more