Turns out setWatch and setTimeout IDs are shared so that's where value 2 is coming from (watch ID is 1).
If I add another watch for btnPin (falling) then the timeout ID has value 3 and it's growing +3 every time. That means the ID's value can grow very fast if I have a bunch of timers/watches that I want to add or remove dynamically.
And that's just the ID's value growing, the number of timers is the same as far as I understand.
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.
Turns out
setWatch
andsetTimeout
IDs are shared so that's where value 2 is coming from (watch ID is 1).If I add another watch for
btnPin
(falling) then the timeout ID has value 3 and it's growing +3 every time. That means the ID's value can grow very fast if I have a bunch of timers/watches that I want to add or remove dynamically.And that's just the ID's value growing, the number of timers is the same as far as I understand.