|
Humidistat
Arduino firmware for a humidistat (humidity controller)
|
Read button state from a voltage ladder-style keypad. More...
#include <ButtonReader.h>
Public Member Functions | |
| ButtonReader (uint8_t pin_btn, const VoltLadder *voltLadder) | |
| Constructor. | |
| void | sample () |
| Sample the button signal. Call this in the main loop. | |
| Buttons | isPressed () const |
| Get the button state. | |
| uint32_t | getPressedFor () const |
| Get the duration the key has been pressed. This can be used for debouncing using a stable interval. | |
Private Attributes | |
| const VoltLadder & | voltLadder |
| Reference to a voltLadder instance. | |
| uint8_t | pin_btn |
| Pin corresponding to the keypad. | |
| Buttons | lastState = Buttons::NONE |
| Last sampled state of the keypad. | |
| unsigned long | pressedSince = 0 |
| Time of the start of the keypress (in micros) | |
Read button state from a voltage ladder-style keypad.
Definition at line 10 of file ButtonReader.h.
|
explicit |
Constructor.
| pin_btn | Pin corresponding to the keypad |
| voltLadder | Pointer to VoltLadder instance |
Definition at line 4 of file ButtonReader.cpp.
| uint32_t ButtonReader::getPressedFor | ( | ) | const |
Get the duration the key has been pressed. This can be used for debouncing using a stable interval.
Definition at line 18 of file ButtonReader.cpp.
| Buttons ButtonReader::isPressed | ( | ) | const |
Get the button state.
Definition at line 14 of file ButtonReader.cpp.
| void ButtonReader::sample | ( | ) |
Sample the button signal. Call this in the main loop.
Definition at line 6 of file ButtonReader.cpp.
|
private |
Last sampled state of the keypad.
Definition at line 15 of file ButtonReader.h.
|
private |
Pin corresponding to the keypad.
Definition at line 13 of file ButtonReader.h.
|
private |
Time of the start of the keypress (in micros)
Definition at line 16 of file ButtonReader.h.
|
private |
Reference to a voltLadder instance.
Definition at line 12 of file ButtonReader.h.