Arduino Filters
master
Filter library for Arduino
src
AH
Hardware
IncrementDecrementButtons.hpp
Go to the documentation of this file.
1
/* ✔ */
2
3
#pragma once
4
5
#include <
AH/Settings/Warnings.hpp
>
6
AH_DIAGNOSTIC_WERROR
()
// Enable errors on warnings
7
8
#include "Button.hpp"
9
10
BEGIN_AH_NAMESPACE
11
25
class
IncrementDecrementButtons
{
26
public
:
37
IncrementDecrementButtons
(
const
Button
&
incrementButton
,
38
const
Button
&
decrementButton
)
39
:
incrementButton
(
incrementButton
),
decrementButton
(
decrementButton
) {}
40
42
void
begin
() {
43
incrementButton
.
begin
();
44
decrementButton
.
begin
();
45
}
46
52
enum
State
{
53
Nothing
= 0,
54
IncrementShort
,
55
IncrementLong
,
56
IncrementHold
,
57
DecrementShort
,
58
DecrementLong
,
59
DecrementHold
,
60
Reset
,
61
};
62
66
State
update
() {
return
state
=
updateImplementation
(); }
67
74
State
getState
()
const
{
return
state
; }
75
77
void
invert
() {
78
incrementButton
.
invert
();
79
decrementButton
.
invert
();
80
}
81
82
protected
:
83
State
updateImplementation
();
84
85
private
:
86
Button
incrementButton
;
87
Button
decrementButton
;
88
89
enum
{
90
Initial
,
91
LongPress
,
92
AfterReset
,
93
}
longPressState
=
Initial
;
94
unsigned
long
longPressRepeat
;
95
State
state
=
Nothing
;
96
};
97
98
END_AH_NAMESPACE
99
100
AH_DIAGNOSTIC_POP
()
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition:
NamespaceSettings.hpp:10
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition:
NamespaceSettings.hpp:9
Warnings.hpp
AH_DIAGNOSTIC_POP
#define AH_DIAGNOSTIC_POP()
Definition:
Warnings.hpp:36
AH_DIAGNOSTIC_WERROR
#define AH_DIAGNOSTIC_WERROR()
Definition:
Warnings.hpp:35
Button
A class for reading and debouncing buttons and switches.
Definition:
Button.hpp:18
Button::invert
void invert()
Invert the input state of this button (button pressed is HIGH instead of LOW).
Definition:
Button.cpp:11
Button::begin
void begin()
Initialize (enable the internal pull-up resistor).
Definition:
Button.cpp:9
IncrementDecrementButtons
A class for buttons that increment and decrement some counter or setting.
Definition:
IncrementDecrementButtons.hpp:25
IncrementDecrementButtons::IncrementDecrementButtons
IncrementDecrementButtons(const Button &incrementButton, const Button &decrementButton)
Create a IncrementDecrementButtons object.
Definition:
IncrementDecrementButtons.hpp:37
IncrementDecrementButtons::incrementButton
Button incrementButton
Definition:
IncrementDecrementButtons.hpp:86
IncrementDecrementButtons::longPressState
enum IncrementDecrementButtons::@1 longPressState
IncrementDecrementButtons::updateImplementation
State updateImplementation()
Definition:
IncrementDecrementButtons.cpp:8
IncrementDecrementButtons::State
State
An enumeration of the different actions to be performed by the counter.
Definition:
IncrementDecrementButtons.hpp:52
IncrementDecrementButtons::DecrementLong
@ DecrementLong
The counter must be decremented (after long press).
Definition:
IncrementDecrementButtons.hpp:58
IncrementDecrementButtons::Nothing
@ Nothing
The counter should not be incremented.
Definition:
IncrementDecrementButtons.hpp:53
IncrementDecrementButtons::IncrementShort
@ IncrementShort
The counter must be incremented (after short press).
Definition:
IncrementDecrementButtons.hpp:54
IncrementDecrementButtons::IncrementHold
@ IncrementHold
The counter must be incremented (still pressed).
Definition:
IncrementDecrementButtons.hpp:56
IncrementDecrementButtons::DecrementHold
@ DecrementHold
The counter must be decremented (still pressed).
Definition:
IncrementDecrementButtons.hpp:59
IncrementDecrementButtons::DecrementShort
@ DecrementShort
The counter must be decremented (after short press).
Definition:
IncrementDecrementButtons.hpp:57
IncrementDecrementButtons::Reset
@ Reset
The counter should be reset to the initial value.
Definition:
IncrementDecrementButtons.hpp:60
IncrementDecrementButtons::IncrementLong
@ IncrementLong
The counter must be incremented (after long press).
Definition:
IncrementDecrementButtons.hpp:55
IncrementDecrementButtons::longPressRepeat
unsigned long longPressRepeat
Definition:
IncrementDecrementButtons.hpp:94
IncrementDecrementButtons::invert
void invert()
Definition:
IncrementDecrementButtons.hpp:77
IncrementDecrementButtons::state
State state
Definition:
IncrementDecrementButtons.hpp:95
IncrementDecrementButtons::getState
State getState() const
Return the state of the increment/decrement button without updating it.
Definition:
IncrementDecrementButtons.hpp:74
IncrementDecrementButtons::begin
void begin()
Definition:
IncrementDecrementButtons.hpp:42
IncrementDecrementButtons::update
State update()
Update and return the state of the increment/decrement button.
Definition:
IncrementDecrementButtons.hpp:66
IncrementDecrementButtons::Initial
@ Initial
Definition:
IncrementDecrementButtons.hpp:90
IncrementDecrementButtons::AfterReset
@ AfterReset
Definition:
IncrementDecrementButtons.hpp:92
IncrementDecrementButtons::LongPress
@ LongPress
Definition:
IncrementDecrementButtons.hpp:91
IncrementDecrementButtons::decrementButton
Button decrementButton
Definition:
IncrementDecrementButtons.hpp:87
Generated by
1.9.4