Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
AH
Hardware
IncrementButton.cpp
Go to the documentation of this file.
1
#include "
IncrementButton.hpp
"
2
3
BEGIN_AH_NAMESPACE
4
5
IncrementButton::State
IncrementButton::updateImplementation
() {
6
Button::State
incrState =
button
.update();
7
8
if
(incrState ==
Button::Released
) {
9
// Button released, don't do anything
10
// This one is first to minimize overhead
11
// because most of the time, the button will
12
// be released
13
return
Nothing
;
14
}
else
if
(incrState ==
Button::Rising
) {
15
auto
res =
longPressState
==
LongPress
?
ReleasedLong
:
ReleasedShort
;
16
longPressState
=
Initial
;
17
return
res;
18
}
else
if
(incrState ==
Button::Falling
) {
19
return
IncrementShort
;
20
}
else
{
// if (incrState == Button::Pressed)
21
auto
now = millis();
22
if
(
longPressState
==
LongPress
) {
23
// still long pressed
24
if
(now -
longPressRepeat
>=
LONG_PRESS_REPEAT_DELAY
) {
25
longPressRepeat
+=
LONG_PRESS_REPEAT_DELAY
;
26
return
IncrementHold
;
27
}
28
}
else
if
(
button
.stableTime(now) >=
LONG_PRESS_DELAY
) {
29
// long press starts
30
longPressState
=
LongPress
;
31
longPressRepeat
= now;
32
return
IncrementLong
;
33
}
34
}
35
return
Nothing
;
36
}
37
38
END_AH_NAMESPACE
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition
AH/Settings/NamespaceSettings.hpp:14
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition
AH/Settings/NamespaceSettings.hpp:11
IncrementButton.hpp
AH::Button::State
State
An enumeration of the different states a button can be in.
Definition
Button.hpp:47
AH::Button::Rising
@ Rising
Input went from low to high (0,1).
Definition
Button.hpp:51
AH::Button::Falling
@ Falling
Input went from high to low (1,0).
Definition
Button.hpp:50
AH::Button::Released
@ Released
Input went from high to high (1,1).
Definition
Button.hpp:49
AH::IncrementButton::State
State
An enumeration of the different actions to be performed by the counter.
Definition
IncrementButton.hpp:38
AH::IncrementButton::Nothing
@ Nothing
The counter must not be incremented.
Definition
IncrementButton.hpp:39
AH::IncrementButton::IncrementShort
@ IncrementShort
The counter must be incremented (after short press).
Definition
IncrementButton.hpp:40
AH::IncrementButton::IncrementHold
@ IncrementHold
The counter must be incremented (still pressed).
Definition
IncrementButton.hpp:42
AH::IncrementButton::ReleasedLong
@ ReleasedLong
The button was released after a long press.
Definition
IncrementButton.hpp:44
AH::IncrementButton::IncrementLong
@ IncrementLong
The counter must be incremented (after long press).
Definition
IncrementButton.hpp:41
AH::IncrementButton::ReleasedShort
@ ReleasedShort
The button was released after a short press.
Definition
IncrementButton.hpp:43
AH::IncrementButton::longPressRepeat
unsigned long longPressRepeat
Definition
IncrementButton.hpp:72
AH::IncrementButton::button
Button button
Definition
IncrementButton.hpp:66
AH::IncrementButton::Initial
@ Initial
Definition
IncrementButton.hpp:69
AH::IncrementButton::LongPress
@ LongPress
Definition
IncrementButton.hpp:70
AH::IncrementButton::longPressState
enum AH::IncrementButton::@020366366041243377067032113342014277330317273145 longPressState
AH::IncrementButton::updateImplementation
State updateImplementation()
Definition
IncrementButton.cpp:5
AH::LONG_PRESS_REPEAT_DELAY
constexpr unsigned long LONG_PRESS_REPEAT_DELAY
The time between increments/decremnets during a long press.
Definition
AH/Settings/Settings.hpp:87
AH::LONG_PRESS_DELAY
constexpr unsigned long LONG_PRESS_DELAY
The time in milliseconds before a press is registered as a long press.
Definition
AH/Settings/Settings.hpp:84
Generated by
1.17.0