#include <timeObj.h>
#include <blinker.h>
#include <mechButton.h>
#define LONG_PRESS_MS 1000
mechButton aBtn(2);
timeObj btnTimer(LONG_PRESS_MS,false);
blinker theLED(13);
void setup() {
aBtn.setCallback(btnClick);
}
void btnClick(void) {
if (aBtn.getState()) { // Button lift..
theLED.setOnOff(false); // Loose the blink.
} else { // Button pressed!
btnTimer.start(); // Start the timer.
}
}
void loop() {
idle(); // Run the magic behind the scenes. (Ticks)
if (btnTimer.ding()) { // If the timer has expired.. (Long press has happened!)
theLED.setOnOff(true); // Start blinking!
btnTimer.reset(); // Shut off the timer.
}
}