pub struct DebouncedInput<Switch: InputSwitch, Config: DebouncedInputConfig> { /* private fields */ }
Expand description

Concrete implementation of debounced input.

Type Params

Switch - InputSwitch that provides input for debouncing.

Config - DebouncedInputConfig that provides configs for debouncing.

Example

debounced_input_config!(
    SomeDebouncedInputConfig,
    debounce_timer: MyElapsedTimer = MyElapsedTimer::new(20.millis())
);

type MyDebouncedInput<Switch> = DebouncedInput<Switch, SomeDebouncedInputConfig>;

let mut clock = SysClock::new();
let mut debounced_input = MyDebouncedInput::new(pin.into_active_low_switch());

loop {
    match debounced_input.update(clock.now()).unwrap() {
        DebouncedInputEvent::Low => do_something_when_low(),
        DebouncedInputEvent::High => do_something_when_high(),
        DebouncedInputEvent::Rise => do_something_upon_rise(),
        DebouncedInputEvent::Fall => do_something_upon_fall(),
    }
}

Implementations

Creates a new DebouncedInput<Switch, Config> from a concrete Switch.

input_switch - an concrete instance of Switch.

Returns the is stable high state.

Returns the is stable low state.

Borrow Switch.

Consumes self and release Switch.

Trait Implementations

Update a control and return an current event or error after update. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Consumes the IoPin returning a Switch of the appropriate ActiveLevel. Read more
Consumes the IoPin returning a Switch<IoPin, ActiveLow>. Read more
Consumes the IoPin returning a Switch<IoPin, ActiveHigh>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.