I tested simple de-bouncer. The setWatch is used once, then re-enabled after a period of 200ms just after the associated function is called:
function test(){
console.log("Hello!"); //the actual task done after pressing the BTN1
setTimeout(setupBTN1, 200); //every time test() is ran the BTN1 handler is enabled again after a period of 200ms
}
function setupBTN1(){
setWatch(test, BTN1, {repeat:false, edge:"rising"});
}
setupBTN1(); //single BTN1-triggered test() function call is enabled
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I tested simple de-bouncer. The setWatch is used once, then re-enabled after a period of 200ms just after the associated function is called: