Hi everybody, I have this code:
clearWatch(); setWatch(() => { console.log('\-----'); console.log('BTN3'); btn3Handler() }, BTN3, { debounce: DEBOUNCE, repeat: true, edge: "falling" }); setWatch(() => { console.log('BTN4'); btn4Handler() }, BTN4, { debounce: DEBOUNCE, repeat: true, edge: "falling" });
When I press BTN3 I get often (not always) get this in console:
\---- BTN3 BTN4
It looks like BTN4 fires together with BTN3.
The only workaround I found is this ugly one (clear watches before calling the handler and reattach them after):
clearWatch(); setWatch(() => { console.log('-----'); console.log('BTN3'); clearWatch(); btn3Handler(); addWatch(); }, BTN3, { debounce: DEBOUNCE, repeat: true, edge: "falling" }); setWatch(() => { console.log('BTN4'); btn4handler(); }, BTN4, { debounce: DEBOUNCE, repeat: true, edge: "falling" });
The issue doesn't happen in the emulator, just on the real clock.
This is the gist with the complete code (the issue is at line 119): https://gist.github.com/fbedussi/05f7bee30cf7fbc43a3dbfa728c5edb2
Is this a bug or am I missing something?
thanks and kudos for the project!
@fbedussi started
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.
Hi everybody,
I have this code:
When I press BTN3 I get often (not always) get this in console:
It looks like BTN4 fires together with BTN3.
The only workaround I found is this ugly one (clear watches before calling the handler and reattach them after):
The issue doesn't happen in the emulator, just on the real clock.
This is the gist with the complete code (the issue is at line 119):
https://gist.github.com/fbedussi/05f7bee30cf7fbc43a3dbfa728c5edb2
Is this a bug or am I missing something?
thanks and kudos for the project!