Struct Rotary

Source
pub struct Rotary<A, B, P> { /* private fields */ }
Expand description

Holds current/old state and both InputPin

Implementations§

Source§

impl<A, B> Rotary<A, B, DefaultPhase>
where A: InputPin, B: InputPin,

Source

pub fn new(pin_a: A, pin_b: B) -> Self

Accepts two InputPins, these will be read on every update()

Source§

impl<A, B, P: Phase> Rotary<A, B, P>
where A: InputPin, B: InputPin,

Source

pub fn with_phase(pin_a: A, pin_b: B, phase: P) -> Self

Accepts two InputPins, these will be read on every update(), while using phase to determine the direction.

Source

pub fn update(&mut self) -> Result<Direction, Either<A::Error, B::Error>>

Call update to evaluate the next state of the encoder, propagates errors from InputPin read

Source

pub fn pin_a(&mut self) -> &mut A

Returns a reference to the first pin. Can be used to clear interrupt.

Source

pub fn pin_b(&mut self) -> &mut B

Returns a reference to the second pin. Can be used to clear interrupt.

Source

pub fn pins(&mut self) -> (&mut A, &mut B)

Returns a reference to both pins. Can be used to clear interrupt.

Source

pub fn into_inner(self) -> (A, B)

Consumes this Rotary, returning the underlying pins A and B.

Trait Implementations§

Source§

impl<A: Clone, B: Clone, P: Clone> Clone for Rotary<A, B, P>

Source§

fn clone(&self) -> Rotary<A, B, P>

Returns a duplicate 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<A: Debug, B: Debug, P: Debug> Debug for Rotary<A, B, P>

Source§

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

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

impl<A: PartialEq, B: PartialEq, P: PartialEq> PartialEq for Rotary<A, B, P>

Source§

fn eq(&self, other: &Rotary<A, B, P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A: Eq, B: Eq, P: Eq> Eq for Rotary<A, B, P>

Source§

impl<A, B, P> StructuralPartialEq for Rotary<A, B, P>

Auto Trait Implementations§

§

impl<A, B, P> Freeze for Rotary<A, B, P>
where A: Freeze, B: Freeze, P: Freeze,

§

impl<A, B, P> RefUnwindSafe for Rotary<A, B, P>

§

impl<A, B, P> Send for Rotary<A, B, P>
where A: Send, B: Send, P: Send,

§

impl<A, B, P> Sync for Rotary<A, B, P>
where A: Sync, B: Sync, P: Sync,

§

impl<A, B, P> Unpin for Rotary<A, B, P>
where A: Unpin, B: Unpin, P: Unpin,

§

impl<A, B, P> UnwindSafe for Rotary<A, B, P>
where A: UnwindSafe, B: UnwindSafe, P: UnwindSafe,

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.