Actually yes, I guess you could remove the pullup if it's on for too long.
So maybe some additional code:
var onCount = 0;
var pulledUp = true;
setInterval(function() { // every 10 seconds
if (!pulledUp) pinMode(D2,"input_pullup");
if (D2.read()) { // LED is off - all ok
onCount = 0;
pulledUp = true;
} else {
onCount++;
if (onCount>6) { // >60 secs on
pulledUp = false;
}
}
if (!pulledUp) pinMode(D2,"input");
}, 10000);
//And then in your setWatch
setWatch(function(e) {
if (!pulledUp) return;
//...
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.
Actually yes, I guess you could remove the pullup if it's on for too long.
So maybe some additional code: