Struct keypad::KeypadInput
source · [−]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 KeypadInput
s can mutate the column pin’s state as needed,
even though they only have a shared/immutable reference to it.
This has several implications.
-
Reading from
KeypadInput
s is not reentrant. If we were in the middle of reading aKeypadInput
and entered an interrupt service routine that read anyKeypadInput
of the same keypad, we might read an incorrect value or cause apanic
. -
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.