Struct DebouncedInputPin

Source
pub struct DebouncedInputPin<T: InputPin, A> {
    pub pin: T,
    /* private fields */
}
Expand description

A debounced input pin.

Implements approach 1 from here (archived 2018-09-03).

Requires update() to be called every ~1ms.

Fields§

§pin: T

The wrapped pin.

Implementations§

Source§

impl<T: InputPin, A> DebouncedInputPin<T, A>

Source

pub fn new(pin: T, _activeness: A) -> Self

Initializes a new debounced input pin.

Source

pub fn is_active(&self) -> bool

Checks if the pin debounce state is active.

Trait Implementations§

Source§

impl<T: InputPin> Debounce for DebouncedInputPin<T, ActiveHigh>

Source§

fn update(&mut self) -> Result<Self::State, Self::Error>

Updates the debounce logic.

Needs to be called every ~1ms.

Source§

type Error = <T as InputPin>::Error

Source§

type State = DebounceState

Source§

impl<T: InputPin> Debounce for DebouncedInputPin<T, ActiveLow>

Source§

fn update(&mut self) -> Result<Self::State, Self::Error>

Updates the debounce logic.

Needs to be called every ~1ms.

Source§

type Error = <T as InputPin>::Error

Source§

type State = DebounceState

Source§

impl<T: InputPin> InputPin for DebouncedInputPin<T, ActiveHigh>

Source§

type Error = <T as InputPin>::Error

Error type
Source§

fn is_high(&self) -> Result<bool, Self::Error>

Is the input pin high?
Source§

fn is_low(&self) -> Result<bool, Self::Error>

Is the input pin low?
Source§

impl<T: InputPin> InputPin for DebouncedInputPin<T, ActiveLow>

Source§

type Error = <T as InputPin>::Error

Error type
Source§

fn is_high(&self) -> Result<bool, Self::Error>

Is the input pin high?
Source§

fn is_low(&self) -> Result<bool, Self::Error>

Is the input pin low?

Auto Trait Implementations§

§

impl<T, A> Freeze for DebouncedInputPin<T, A>
where T: Freeze,

§

impl<T, A> RefUnwindSafe for DebouncedInputPin<T, A>

§

impl<T, A> Send for DebouncedInputPin<T, A>
where T: Send, A: Send,

§

impl<T, A> Sync for DebouncedInputPin<T, A>
where T: Sync, A: Sync,

§

impl<T, A> Unpin for DebouncedInputPin<T, A>
where T: Unpin, A: Unpin,

§

impl<T, A> UnwindSafe for DebouncedInputPin<T, A>
where T: UnwindSafe, A: 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> 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.