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
10
class
ButtonReader
{
11
private
:
12
const
VoltLadder &
voltLadder
;
13
uint8_t
pin_btn
;
14
15
Buttons
lastState
=
Buttons::NONE
;
16
unsigned
long
pressedSince
= 0;
17
public
:
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.h
Buttons
Buttons
Possible button values.
Definition
Buttons.h:5
Buttons::NONE
@ NONE
aliases.h
ButtonReader
Read button state from a voltage ladder-style keypad.
Definition
ButtonReader.h:10
ButtonReader::pin_btn
uint8_t pin_btn
Pin corresponding to the keypad.
Definition
ButtonReader.h:13
ButtonReader::getPressedFor
uint32_t getPressedFor() const
Get the duration the key has been pressed. This can be used for debouncing using a stable interval.
Definition
ButtonReader.cpp:18
ButtonReader::isPressed
Buttons isPressed() const
Get the button state.
Definition
ButtonReader.cpp:14
ButtonReader::ButtonReader
ButtonReader(uint8_t pin_btn, const VoltLadder *voltLadder)
Constructor.
Definition
ButtonReader.cpp:4
ButtonReader::pressedSince
unsigned long pressedSince
Time of the start of the keypress (in micros)
Definition
ButtonReader.h:16
ButtonReader::sample
void sample()
Sample the button signal. Call this in the main loop.
Definition
ButtonReader.cpp:6
ButtonReader::voltLadder
const VoltLadder & voltLadder
Reference to a voltLadder instance.
Definition
ButtonReader.h:12
ButtonReader::lastState
Buttons lastState
Last sampled state of the keypad.
Definition
ButtonReader.h:15
src
input
ButtonReader.h
Generated by
1.12.0