Had similar issues that the event queue picked up more than sunchronously could be handled. Therefore, I used the setWatch-es non-repeated for trigger the read the status (delayed).
Initially I built this [keypad module]() the same way and then changed it to overcome these out-of-sync issues... Only afterwards I became aware of the existing one which uses a similar approach SW and HW as yours... and most likely has the same issues.
I use the two different edges in one-time setWatches and sufficient debounce... that will solve your issue... and for adding a separate layer of stability, you can place on switch change a timeout to change state again after may be 500...1000 ms.
© Espruino, powered by microcosm.
Report a problem