Enum rcx::SensorMode

source ·
#[repr(u8)]
pub enum SensorMode { Raw = 0, Boolean = 1, EdgeCount = 2, PulseCount = 3, Percentage = 4, TemperatureC = 5, TemperatureF = 6, Angle = 7, }
Expand description

Set the slope and mode of sensor number sensor to the value specified by mode, and clear that sensor’s value. The bits of mode are split into two portions. Bits 0-4 contain a slope value in 0..31, while bits 5-7 contain the mode, 0..7. The eight modes, which control the value returned by the sensor, are:

    Mode	Name	Description
    0	Raw	Value in 0..1023.
    1	Boolean	Either 0 or 1.
    2	Edge count	Number of boolean transitions.
    3	Pulse count	Number of boolean transitions divided by two.
    4	Percentage	Raw value scaled to 0..100.
    5	Temperature in °C	1/10ths of a degree, -19.8..69.5.
    6	Temperature in °F	1/10ths of a degree, -3.6..157.1.
    7	Angle	1/16ths of a rotation, represented as a signed short.

The slope value controls 0/1 detection for the three boolean modes. A slope of 0 causes raw sensor values greater than 562 to cause a transition to 0 and raw sensor values less than 460 to cause a transition to 1. The hysteresis prevents bouncing between 0 and 1 near the transition point. A slope value in 1..31, inclusive, causes a transition to 0 or to 1 whenever the difference between consecutive raw sensor values exceeds the slope. Increases larger than the slope result in 0 transitions, while decreases larger than the slope result in 1 transitions. Note the inversions: high raw values correspond to a boolean 0, while low raw values correspond to a boolean 1.

Variants§

§

Raw = 0

§

Boolean = 1

§

EdgeCount = 2

§

PulseCount = 3

§

Percentage = 4

§

TemperatureC = 5

§

TemperatureF = 6

§

Angle = 7

Trait Implementations§

source§

impl Clone for SensorMode

source§

fn clone(&self) -> SensorMode

Returns a copy 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 SensorMode

source§

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

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

impl PartialEq for SensorMode

source§

fn eq(&self, other: &SensorMode) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for SensorMode

source§

impl Eq for SensorMode

source§

impl StructuralPartialEq for SensorMode

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> 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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.