pub struct KeypadInput<'a, E> { /* private fields */ }
Expand description

A virtual embedded-hal input pin representing one key of the keypad.

A KeypadInput stores references to one row and one column pin. When you read from it with .is_low() or .is_high(), it secretly sets the column pin low, reads from the row pin, and then sets the column pin high again. The column pin is actually stored inside a RefCell in the keypad struct, so that multiple KeypadInputs can mutate the column pin’s state as needed, even though they only have a shared/immutable reference to it.

This has several implications.

  1. Reading from KeypadInputs is not reentrant. If we were in the middle of reading a KeypadInput and entered an interrupt service routine that read any KeypadInput of the same keypad, we might read an incorrect value or cause a panic.

  2. Reading from a KeypadInput is slower than reading from a real input pin, because it needs to change the output pin state twice for every read.

Implementations

Create a new KeypadInput. For use in macros.

Trait Implementations

Read the state of the key at this row and column. Not reentrant.

Read the state of the key at this row and column. Not reentrant.

Error type

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.

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.