Struct rotary_encoder_embedded::RotaryEncoder
source · pub struct RotaryEncoder<MODE, DT, CLK> { /* private fields */ }
Expand description
Rotary Encoder
Implementations§
source§impl<DT, CLK> RotaryEncoder<AngularVelocityMode, DT, CLK>
impl<DT, CLK> RotaryEncoder<AngularVelocityMode, DT, CLK>
sourcepub fn set_velocity_inc_factor(&mut self, inc_factor: f32)
pub fn set_velocity_inc_factor(&mut self, inc_factor: f32)
Set the velocity_inc_factor. How quickly the velocity increases to 1.0.
sourcepub fn set_velocity_dec_factor(&mut self, dec_factor: f32)
pub fn set_velocity_dec_factor(&mut self, dec_factor: f32)
Set the velocity_dec_factor. How quickly the velocity decreases or cools-down
sourcepub fn set_velocity_action_ms(&mut self, action_ms: u64)
pub fn set_velocity_action_ms(&mut self, action_ms: u64)
Set the velocity_action_ms. The window of duration (milliseconds) that the velocity will increase
sourcepub fn decay_velocity(&mut self)
pub fn decay_velocity(&mut self)
This function should be called periodically, either via a timer or the main loop. This function will reduce the angular velocity over time, the amount is configurable via the constructor
sourcepub fn update(&mut self, current_time_millis: u64) -> Direction
pub fn update(&mut self, current_time_millis: u64) -> Direction
Update the state machine of the RotaryEncoder. This should be called ideally from an interrupt vector when either the DT or CLK pins state changes. This function will update the RotaryEncoder’s Direction and current Angular Velocity.
current_time
- Current timestamp in ms (strictly monotonously increasing)
source§impl<DT, CLK, MODE> RotaryEncoder<MODE, DT, CLK>
impl<DT, CLK, MODE> RotaryEncoder<MODE, DT, CLK>
sourcepub fn into_angular_velocity_mode(
self
) -> RotaryEncoder<AngularVelocityMode, DT, CLK>
pub fn into_angular_velocity_mode( self ) -> RotaryEncoder<AngularVelocityMode, DT, CLK>
Configure RotaryEncoder
to use the AngularVelocityMode API
source§impl<DT, CLK> RotaryEncoder<StandardMode, DT, CLK>
impl<DT, CLK> RotaryEncoder<StandardMode, DT, CLK>
source§impl<LOGIC, DT, CLK> RotaryEncoder<LOGIC, DT, CLK>
impl<LOGIC, DT, CLK> RotaryEncoder<LOGIC, DT, CLK>
sourcepub fn into_standard_mode(self) -> RotaryEncoder<StandardMode, DT, CLK>
pub fn into_standard_mode(self) -> RotaryEncoder<StandardMode, DT, CLK>
Configure RotaryEncoder
to use the standard API
source§impl<MODE, DT, CLK> RotaryEncoder<MODE, DT, CLK>
impl<MODE, DT, CLK> RotaryEncoder<MODE, DT, CLK>
Common