1 #ifndef TCLIBRARYDEV_TCONEBUTTONHANDLER_H
2 #define TCLIBRARYDEV_TCONEBUTTONHANDLER_H
4 #include <PlatformDetermination.h>
5 #include <SwitchInput.h>
18 int doubleClickThreshold;
22 : lastPress(0), buttonPin(buttonPin), doubleClickThreshold(doubleClickThreshold) {
26 switches.addSwitchListener(buttonPin,
this, NO_REPEAT,
false);
29 void onPressed(pinid_t pin,
bool held)
override {
32 void onReleased(pinid_t pin,
bool held)
override {
33 if(held && pin == buttonPin) {
37 if((millis() - lastPress) < doubleClickThreshold) {
41 auto enc = switches.getEncoder();
42 if(enc->getCurrentReading() == enc->getMaximumValue()) {
43 enc->setCurrentReading(0);
44 enc->runCallback(enc->getCurrentReading());