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 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.
Methods
impl<'a> KeypadInput<'a>
[src]
impl<'a> KeypadInput<'a>
pub fn new(row: &'a InputPin, col: &'a RefCell<OutputPin>) -> Self
[src]
pub fn new(row: &'a InputPin, col: &'a RefCell<OutputPin>) -> Self
Create a new KeypadInput
. For use in macros.
Trait Implementations
impl<'a> InputPin for KeypadInput<'a>
[src]
impl<'a> InputPin for KeypadInput<'a>
Auto Trait Implementations
impl<'a> !Send for KeypadInput<'a>
impl<'a> !Send for KeypadInput<'a>
impl<'a> !Sync for KeypadInput<'a>
impl<'a> !Sync for KeypadInput<'a>