Unless I'm totally misunderstanding, you need to actually check the value in theisLong variable and do something with it, rather than having 2 watches:
setWatch(function(e){
var isLong = (e.time-e.lastTime)>0.4;
print(isLong.toString());
if (isLong) onD23();
else offD23();
}, BTN, {repeat:true, debounce:50, edge:"falling"});
function onD23(){
console.log("onD23");
digitalWrite(D23,1);
setTimeout(function () { digitalWrite(D23,0); }, 1000);
}
function offD23(){
console.log("offD23");
digitalWrite(D23,0);
setTimeout(function () { digitalWrite(D23,1); }, 1000);
}
It's still going to get a bit confusing though - it'd be easier to check if you had 2 different LEDs.
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.
Unless I'm totally misunderstanding, you need to actually check the value in the
isLong
variable and do something with it, rather than having 2 watches:It's still going to get a bit confusing though - it'd be easier to check if you had 2 different LEDs.