Can you show a little bit more of the code? I wonder about the connect being some async/callback thing that messes with you... Worst case - comes push to shove - it may be that the (async) code executing 'in' connect(... makes the JS interpreter loose the context and returns unable to match the break with the switch it looks to be in... (if we can trust the console output - time sync correctly...). Try this far shot by wrapping connect() into a setTimeout(...: setTimeout(connect,1); (connect() must be a globally / level 0 defined function of yours, is it?).
Btw, you can simply say if (timer) timer = clearInterval(timer); (and conversely if (!timer) { ... - in line 15) with globally declaring var timer;.
What are you using the timer for? ...update the display every second?
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.
Can you show a little bit more of the code? I wonder about the connect being some async/callback thing that messes with you... Worst case - comes push to shove - it may be that the (async) code executing 'in'
connect(...
makes the JS interpreter loose the context and returns unable to match thebreak
with theswitch
it looks to be in... (if we can trust the console output - time sync correctly...). Try this far shot by wrapping connect() into a setTimeout(...:setTimeout(connect,1);
(connect() must be a globally / level 0 defined function of yours, is it?).Btw, you can simply say
if (timer) timer = clearInterval(timer);
(and converselyif (!timer) { ...
- in line 15) with globally declaringvar timer;
.What are you using the timer for? ...update the display every second?