pinMode(D1,"input_pullup");
var times = [];
var currentWatch;
function startWatching() {
currentWatch = setWatch(function(e) {
// work out how long the pulse was, in milliseconds
var pulseLen = 1000 * (e.time - e.lastTime);
// then save it, if it was less than 1 second
if (pulseLen < 1000) {
times.push(pulseLen);
} else {
times = [];
}
}, D1, {repeat:true});
}
startWatching();
function stopWatching() {
clearWatch(currentWatch);
currentWatch = null;
}
setWatch(function(e) {
stopWatching();
Puck.IR(times);
console.log(times);
startWatching();
}, BTN, { repeat: true, edge: 'rising', debounce: 50 });
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 can confirm the new firmware fixes the issue :)
The puck can now replay the IR pulses perfectly
Code below if anyone is interested
Thanks for your help.