Struct rotary_encoder_embedded::RotaryEncoder [−][src]
Rotary Encoder
Implementations
impl<DT, CLK> RotaryEncoder<DT, CLK> where
DT: InputPin,
CLK: InputPin,
[src]
DT: InputPin,
CLK: InputPin,
pub fn new(
pin_dt: DT,
pin_clk: CLK,
velocity_inc_factor: Option<f32>,
velocity_dec_factor: Option<f32>,
velocity_action_ms: Option<i64>
) -> Self
[src]
pin_dt: DT,
pin_clk: CLK,
velocity_inc_factor: Option<f32>,
velocity_dec_factor: Option<f32>,
velocity_action_ms: Option<i64>
) -> Self
Initiates a new Rotary Encoder, taking two InputPins InputPin
.
Optionally the behaviour of the angular velocity can be modified:
velocity_inc_factor: How quickly the velocity increases to 1.0.
velocity_dec_factor: How quickly the velocity decreases or cools-down
velocity_action_ms: The window of duration (milliseconds) that the velocity will increase
pub fn tick(&mut self)
[src]
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
pub fn borrow_pins(&mut self) -> (&mut DT, &mut CLK)
[src]
Borrow a mutable reference to the underlying InputPins. This is useful for clearing hardware interrupts.
pub fn release(self) -> (DT, CLK)
[src]
Release the underying resources such as the InputPins back to the initiator
pub fn update(&mut self, current_time: NaiveDateTime)
[src]
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.
pub fn direction(&self) -> Direction
[src]
Returns the current Direction of the RotaryEncoder
pub fn velocity(&self) -> Velocity
[src]
Returns the current angular velocity of the RotaryEncoder The Angular Velocity is a value between 0.0 and 1.0 This is useful for incrementing/decrementing a value in an exponential fashion
Auto Trait Implementations
impl<DT, CLK> Send for RotaryEncoder<DT, CLK> where
CLK: Send,
DT: Send,
CLK: Send,
DT: Send,
impl<DT, CLK> Sync for RotaryEncoder<DT, CLK> where
CLK: Sync,
DT: Sync,
CLK: Sync,
DT: Sync,
impl<DT, CLK> Unpin for RotaryEncoder<DT, CLK> where
CLK: Unpin,
DT: Unpin,
CLK: Unpin,
DT: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,