Struct PinSwitch

Source
pub struct PinSwitch<P: InputPin, S: PressedState, C: Clock> { /* private fields */ }
Expand description

Switch implementation for InputPin of embedded_hal

Implementations§

Source§

impl<P: InputPin, S: PressedState, C: Clock> PinSwitch<P, S, C>

Source

pub fn new(pin: P) -> Self

Create new PinSwitch instance for the passed in pin

Trait Implementations§

Source§

impl<P: InputPin, S: PressedState, C: Clock> Switch<C> for PinSwitch<P, S, C>

Source§

fn poll(&mut self, now: Instant<C>)

Poll the switch for the hardware state changes Read more
Source§

fn has_changed(&self) -> bool

Indicates that the switch state has has_changed since the last poll
Source§

fn is_pressed(&self) -> bool

Indicates that the switch is in pressed state
Source§

fn is_released(&self) -> bool

Indicates that the switch is in released state
Source§

fn pressed_for(&self) -> Option<Milliseconds<C::T>>

Returns the duration for which the switch has been pressed for Read more
Source§

fn released_for(&self) -> Option<Milliseconds<C::T>>

Returns the duration for which the switch has been released for Read more
Source§

fn wait(&mut self, clock: &C)

Wait for the state to change Read more
Source§

fn reset(&mut self)

Reset the switch state to initial values
Source§

fn prev_state_lasted_for(&self) -> Milliseconds<<C as Clock>::T>

Returns the duration for which the last switch state lasted for
Source§

fn current_state(&self, now: Instant<C>) -> Milliseconds<<C as Clock>::T>

Returns the duration for which the current state is held Read more

Auto Trait Implementations§

§

impl<P, S, C> Freeze for PinSwitch<P, S, C>
where P: Freeze, <C as Clock>::T: Freeze,

§

impl<P, S, C> RefUnwindSafe for PinSwitch<P, S, C>

§

impl<P, S, C> Send for PinSwitch<P, S, C>
where P: Send, <C as Clock>::T: Send, S: Send,

§

impl<P, S, C> Sync for PinSwitch<P, S, C>
where P: Sync, <C as Clock>::T: Sync, S: Sync,

§

impl<P, S, C> Unpin for PinSwitch<P, S, C>
where P: Unpin, <C as Clock>::T: Unpin, S: Unpin,

§

impl<P, S, C> UnwindSafe for PinSwitch<P, S, C>
where P: UnwindSafe, <C as Clock>::T: UnwindSafe, S: 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.