Trait ev3dev_lang_rust::sensors::Sensor
source · pub trait Sensor: Device {
Show 21 methods
// Provided methods
fn get_bin_data(&self) -> Ev3Result<String> { ... }
fn get_bin_data_format(&self) -> Ev3Result<String> { ... }
fn get_decimals(&self) -> Ev3Result<i32> { ... }
fn get_fw_version(&self) -> Ev3Result<String> { ... }
fn get_mode(&self) -> Ev3Result<String> { ... }
fn set_mode(&self, mode: &str) -> Ev3Result<()> { ... }
fn get_modes(&self) -> Ev3Result<Vec<String>> { ... }
fn get_num_values(&self) -> Ev3Result<i32> { ... }
fn get_poll_ms(&self) -> Ev3Result<i32> { ... }
fn set_poll_ms(&self, poll_ms: i32) -> Ev3Result<()> { ... }
fn get_units(&self) -> Ev3Result<String> { ... }
fn get_value(&self, index: u8) -> Ev3Result<i32> { ... }
fn get_value0(&self) -> Ev3Result<i32> { ... }
fn get_value1(&self) -> Ev3Result<i32> { ... }
fn get_value2(&self) -> Ev3Result<i32> { ... }
fn get_value3(&self) -> Ev3Result<i32> { ... }
fn get_value4(&self) -> Ev3Result<i32> { ... }
fn get_value5(&self) -> Ev3Result<i32> { ... }
fn get_value6(&self) -> Ev3Result<i32> { ... }
fn get_value7(&self) -> Ev3Result<i32> { ... }
fn get_text_value(&self) -> Ev3Result<String> { ... }
}Expand description
Common utility functions for sensors.
Provided Methods§
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.
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.
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.
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.
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.
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.
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.