Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
ButtonReader.h
Go to the documentation of this file.
1#ifndef HUMIDISTAT_BUTTONREADER_H
2#define HUMIDISTAT_BUTTONREADER_H
3
4#include <stdint.h>
5
6#include "aliases.h"
7#include "Buttons.h"
8
11private:
12 const VoltLadder &voltLadder;
13 uint8_t pin_btn;
14
16 unsigned long pressedSince = 0;
17public:
21 explicit ButtonReader(uint8_t pin_btn, const VoltLadder *voltLadder);
22
24 void sample();
25
28 Buttons isPressed() const;
29
32 uint32_t getPressedFor() const;
33};
34
35#endif //HUMIDISTAT_BUTTONREADER_H
Buttons
Possible button values.
Definition Buttons.h:5
Read button state from a voltage ladder-style keypad.
uint8_t pin_btn
Pin corresponding to the keypad.
uint32_t getPressedFor() const
Get the duration the key has been pressed. This can be used for debouncing using a stable interval.
Buttons isPressed() const
Get the button state.
ButtonReader(uint8_t pin_btn, const VoltLadder *voltLadder)
Constructor.
unsigned long pressedSince
Time of the start of the keypress (in micros)
void sample()
Sample the button signal. Call this in the main loop.
const VoltLadder & voltLadder
Reference to a voltLadder instance.
Buttons lastState
Last sampled state of the keypad.