Struct keypad::KeypadInput[][src]

pub struct KeypadInput<'a> { /* fields omitted */ }

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.

Methods

impl<'a> KeypadInput<'a>
[src]

Create a new KeypadInput. For use in macros.

Trait Implementations

impl<'a> InputPin for KeypadInput<'a>
[src]

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.

Auto Trait Implementations

impl<'a> !Send for KeypadInput<'a>

impl<'a> !Sync for KeypadInput<'a>