pub struct CompassSensor { /* private fields */ }
Expand description
HiTechnic EV3 / NXT Compass Sensor.
Implementations§
Source§impl CompassSensor
impl CompassSensor
Sourcepub const COMMAND_START_CALIBRATION: &'static str = "BEGIN-CAL"
pub const COMMAND_START_CALIBRATION: &'static str = "BEGIN-CAL"
Command for starting the calibration
Sourcepub const COMMAND_STOP_CALIBRATION: &'static str = "END-CAL"
pub const COMMAND_STOP_CALIBRATION: &'static str = "END-CAL"
Command for stopping the calibration
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 fn get_rotation(&self) -> Ev3Result<i32>
pub fn get_rotation(&self) -> Ev3Result<i32>
gets rotation (in degree) from the compass sensor
Sourcepub fn get_relative_rotation(&self) -> Ev3Result<i32>
pub fn get_relative_rotation(&self) -> Ev3Result<i32>
calculates the rotation to the origin / the zero point
Sourcepub fn start_calibration(&self) -> Ev3Result<()>
pub fn start_calibration(&self) -> Ev3Result<()>
calibration: start the calibration by start_calibration() turn the robot 360 degrees end the calibration by stop_calibration() attention: if calibration has not finished, the get_rotation method always returns -258
starts the calibration
Sourcepub fn stop_calibration(&self) -> Ev3Result<()>
pub fn stop_calibration(&self) -> Ev3Result<()>
stops the calibration
Trait Implementations§
Source§impl Clone for CompassSensor
impl Clone for CompassSensor
Source§fn clone(&self) -> CompassSensor
fn clone(&self) -> CompassSensor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CompassSensor
impl Debug for CompassSensor
Source§impl Device for CompassSensor
impl Device for CompassSensor
Source§fn get_attribute(&self, name: &str) -> Attribute
fn get_attribute(&self, name: &str) -> Attribute
Returns the attribute wrapper for an attribute name.
Source§fn get_address(&self) -> Ev3Result<String>
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<()>
fn set_command(&self, command: &str) -> Ev3Result<()>
Sends a command to the device controller.
Source§fn 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.
Source§fn get_driver_name(&self) -> Ev3Result<String>
fn get_driver_name(&self) -> Ev3Result<String>
Returns the name of the driver that provides this device.
Source§impl Sensor for CompassSensor
impl Sensor for CompassSensor
Source§fn 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.Source§fn 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:Source§fn 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.Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn get_modes(&self) -> Ev3Result<Vec<String>>
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>
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>
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<()>
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>
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>
fn get_value(&self, index: u8) -> Ev3Result<i32>
Returns the current
value{index}
value if available.Source§fn get_value0(&self) -> Ev3Result<i32>
fn get_value0(&self) -> Ev3Result<i32>
Returns the current
value0
value if available.Source§fn get_value1(&self) -> Ev3Result<i32>
fn get_value1(&self) -> Ev3Result<i32>
Returns the current
value1
value if available.Source§fn get_value2(&self) -> Ev3Result<i32>
fn get_value2(&self) -> Ev3Result<i32>
Returns the current
value2
value if available.Source§fn get_value3(&self) -> Ev3Result<i32>
fn get_value3(&self) -> Ev3Result<i32>
Returns the current
value3
value if available.Source§fn get_value4(&self) -> Ev3Result<i32>
fn get_value4(&self) -> Ev3Result<i32>
Returns the current
value4
value if available.Source§fn get_value5(&self) -> Ev3Result<i32>
fn get_value5(&self) -> Ev3Result<i32>
Returns the current
value5
value if available.Source§fn get_value6(&self) -> Ev3Result<i32>
fn get_value6(&self) -> Ev3Result<i32>
Returns the current
value6
value if available.Source§fn get_value7(&self) -> Ev3Result<i32>
fn get_value7(&self) -> Ev3Result<i32>
Returns the current
value7
value if available.Source§fn 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 !Freeze for CompassSensor
impl !RefUnwindSafe for CompassSensor
impl Send for CompassSensor
impl !Sync for CompassSensor
impl Unpin for CompassSensor
impl UnwindSafe for CompassSensor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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