Arduino Helpers
master
Utility library for Arduino
src
AH
Hardware
IncrementDecrementButtons.hpp
Go to the documentation of this file.
1
/* ✔ */
2
3
#pragma once
4
5
#include "
Button.hpp
"
6
7
BEGIN_AH_NAMESPACE
8
22
class
IncrementDecrementButtons
{
23
public
:
34
IncrementDecrementButtons
(
const
Button
&
incrementButton
,
35
const
Button
&
decrementButton
)
36
:
incrementButton
(
incrementButton
),
decrementButton
(
decrementButton
) {}
37
39
void
begin
() {
40
incrementButton
.
begin
();
41
decrementButton
.
begin
();
42
}
43
49
enum
State
{
50
Nothing
= 0,
51
IncrementShort
,
52
IncrementLong
,
53
IncrementHold
,
54
DecrementShort
,
55
DecrementLong
,
56
DecrementHold
,
57
Reset
,
58
};
59
63
State
update
() {
return
state
=
updateImplementation
(); }
64
71
State
getState
()
const
{
return
state
; }
72
74
void
invert
() {
75
incrementButton
.
invert
();
76
decrementButton
.
invert
();
77
}
78
79
protected
:
80
State
updateImplementation
();
81
82
private
:
83
Button
incrementButton
;
84
Button
decrementButton
;
85
86
enum
{
87
Initial
,
88
LongPress
,
89
AfterReset
,
90
}
longPressState
=
Initial
;
91
unsigned
long
longPressRepeat
;
92
State
state
=
Nothing
;
93
};
94
95
END_AH_NAMESPACE
Button.hpp
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition:
NamespaceSettings.hpp:14
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition:
NamespaceSettings.hpp:11
Button
A class for reading and debouncing buttons and switches.
Definition:
Button.hpp:15
Button::invert
void invert()
Invert the input state of this button (button pressed is HIGH instead of LOW).
Definition:
Button.cpp:9
Button::begin
void begin()
Initialize (enable the internal pull-up resistor).
Definition:
Button.cpp:7
IncrementDecrementButtons
A class for buttons that increment and decrement some counter or setting.
Definition:
IncrementDecrementButtons.hpp:22
IncrementDecrementButtons::IncrementDecrementButtons
IncrementDecrementButtons(const Button &incrementButton, const Button &decrementButton)
Create a IncrementDecrementButtons object.
Definition:
IncrementDecrementButtons.hpp:34
IncrementDecrementButtons::incrementButton
Button incrementButton
Definition:
IncrementDecrementButtons.hpp:83
IncrementDecrementButtons::longPressState
enum IncrementDecrementButtons::@1 longPressState
IncrementDecrementButtons::updateImplementation
State updateImplementation()
Definition:
IncrementDecrementButtons.cpp:6
IncrementDecrementButtons::State
State
An enumeration of the different actions to be performed by the counter.
Definition:
IncrementDecrementButtons.hpp:49
IncrementDecrementButtons::DecrementLong
@ DecrementLong
The counter must be decremented (after long press).
Definition:
IncrementDecrementButtons.hpp:55
IncrementDecrementButtons::Nothing
@ Nothing
The counter should not be incremented.
Definition:
IncrementDecrementButtons.hpp:50
IncrementDecrementButtons::IncrementShort
@ IncrementShort
The counter must be incremented (after short press).
Definition:
IncrementDecrementButtons.hpp:51
IncrementDecrementButtons::IncrementHold
@ IncrementHold
The counter must be incremented (still pressed).
Definition:
IncrementDecrementButtons.hpp:53
IncrementDecrementButtons::DecrementHold
@ DecrementHold
The counter must be decremented (still pressed).
Definition:
IncrementDecrementButtons.hpp:56
IncrementDecrementButtons::DecrementShort
@ DecrementShort
The counter must be decremented (after short press).
Definition:
IncrementDecrementButtons.hpp:54
IncrementDecrementButtons::Reset
@ Reset
The counter should be reset to the initial value.
Definition:
IncrementDecrementButtons.hpp:57
IncrementDecrementButtons::IncrementLong
@ IncrementLong
The counter must be incremented (after long press).
Definition:
IncrementDecrementButtons.hpp:52
IncrementDecrementButtons::longPressRepeat
unsigned long longPressRepeat
Definition:
IncrementDecrementButtons.hpp:91
IncrementDecrementButtons::invert
void invert()
Definition:
IncrementDecrementButtons.hpp:74
IncrementDecrementButtons::state
State state
Definition:
IncrementDecrementButtons.hpp:92
IncrementDecrementButtons::getState
State getState() const
Return the state of the increment/decrement button without updating it.
Definition:
IncrementDecrementButtons.hpp:71
IncrementDecrementButtons::begin
void begin()
Definition:
IncrementDecrementButtons.hpp:39
IncrementDecrementButtons::update
State update()
Update and return the state of the increment/decrement button.
Definition:
IncrementDecrementButtons.hpp:63
IncrementDecrementButtons::Initial
@ Initial
Definition:
IncrementDecrementButtons.hpp:87
IncrementDecrementButtons::AfterReset
@ AfterReset
Definition:
IncrementDecrementButtons.hpp:89
IncrementDecrementButtons::LongPress
@ LongPress
Definition:
IncrementDecrementButtons.hpp:88
IncrementDecrementButtons::decrementButton
Button decrementButton
Definition:
IncrementDecrementButtons.hpp:84
Generated by
1.9.4