32 void begin() { button.begin(); }
38 auto stableTime = button.stableTime(now);
39 switch (button.update()) {
40 case Button::Released: {
41 if (multiPressCountNew > 0 && stableTime > multiPressDelay) {
42 multiPressCount = multiPressCountNew;
43 multiPressCountNew = 0;
44 event = MultiPressDone;
47 case Button::Falling: {
48 event = (stableTime <= multiPressDelay) ? MultiPress
50 multiPressCountNew +=
event == MultiPress;
52 case Button::Pressed: {
53 if (not longPress && stableTime >= longPressDelay) {
58 case Button::Rising: {
59 event = longPress ? LongPressRelease : ShortPressRelease;
80 this->longPressDelay = longPressDelay;
87 this->multiPressDelay = multiPressDelay;
92 return button.previousBounceTime();
95 unsigned long stableTime()
const {
return button.stableTime(); }
98 return button.stableTime(now);
104 return getButtonState() == Button::Pressed ? stableTime() : 0;
110 return longPress ? stableTime() : 0;
123 unsigned long longPressDelay = 1000;
124 unsigned long multiPressDelay = 400;
125 bool longPress =
false;
126 uint8_t multiPressCountNew = 0;
127 uint8_t multiPressCount = 0;
132 case None:
return F(
"None");
133 case PressStart:
return F(
"PressStart");
134 case ShortPressRelease:
return F(
"ShortPressRelease");
135 case LongPress:
return F(
"LongPress");
136 case LongPressRelease:
return F(
"LongPressRelease");
137 case MultiPress:
return F(
"MultiPress");
138 case MultiPressDone:
return F(
"MultiPressDone");
140 return F(
"<invalid>");
#define BEGIN_AH_NAMESPACE
std::remove_reference< decltype(*F(""))>::type * FlashString_t
#define AH_DIAGNOSTIC_POP()
#define AH_DIAGNOSTIC_WERROR()
Type for storing pin numbers of Extended Input/Output elements.