35 auto stableTime = button.stableTime(
now);
36 switch (button.update()) {
37 case Button::Released: {
38 if (multiPressCountNew > 0 && stableTime > multiPressDelay) {
39 multiPressCount = multiPressCountNew;
40 multiPressCountNew = 0;
41 event = MultiPressDone;
44 case Button::Falling: {
45 event = (stableTime <= multiPressDelay) ? MultiPress
47 multiPressCountNew +=
event == MultiPress;
49 case Button::Pressed: {
50 if (
not longPress && stableTime >= longPressDelay) {
55 case Button::Rising: {
56 event = longPress ? LongPressRelease : ShortPressRelease;
77 this->longPressDelay = longPressDelay;
84 this->multiPressDelay = multiPressDelay;
89 return button.previousBounceTime();
92 unsigned long stableTime()
const {
return button.stableTime(); }
95 return button.stableTime(
now);
101 return getButtonState() == Button::Pressed ? stableTime() : 0;
107 return longPress ? stableTime() : 0;
120 unsigned long longPressDelay = 1000;
121 unsigned long multiPressDelay = 400;
122 bool longPress =
false;
129 case None:
return F(
"None");
130 case PressStart:
return F(
"PressStart");
131 case ShortPressRelease:
return F(
"ShortPressRelease");
132 case LongPress:
return F(
"LongPress");
133 case LongPressRelease:
return F(
"LongPressRelease");
134 case MultiPress:
return F(
"MultiPress");
135 case MultiPressDone:
return F(
"MultiPressDone");
137 return F(
"<invalid>");
#define BEGIN_AH_NAMESPACE
std::remove_reference< decltype(*F(""))>::type * FlashString_t
@ None
No buffers available.
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...
void begin() override
Initialize the shift register.
Type for storing pin numbers of Extended Input/Output elements.