Forgot to add that 'mistakes' I noticed are setting up (especially) setInterval(). For example, the uploading onto the board already sets one (which 'never ever should be done), then the code is saved, and for some logic reason on power up the setInterval() is called again when power is cycled. Therefore, the abcIId variable to hold the Id of the interval can be used too to prevent that. I the function is (the same and) with the same parameters, the setup() can be skipped. Otherwise, it has to be cleared and set again.
NB: If just the time of the interval changes, you do not need to clear and setup the function again: you can just change the interval:
changeInterval(abcIId,newTimeInMS); // change rime of running abc interval
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.
Forgot to add that 'mistakes' I noticed are setting up (especially)
setInterval()
. For example, the uploading onto the board already sets one (which 'never ever should be done), then the code is saved, and for some logic reason on power up thesetInterval()
is called again when power is cycled. Therefore, theabcIId
variable to hold theId
of the interval can be used too to prevent that. I the function is (the same and) with the same parameters, thesetup()
can be skipped. Otherwise, it has to be cleared and set again.NB: If just the time of the interval changes, you do not need to clear and setup the function again: you can just change the interval: