About the delay: yes and no. You can make it very clear in the function description that this is only a rough delay, and that it may or may not be accurate (as I recall, you already do that at some points). While it does block the execution, it could be used with e.g. a setInterval to call it every 2000 milliseconds. Having a dedicated delay function would then hopefully free up that time, eg delay(1000) to do more meaningful things than just sit around and wait for that part of the code to execute. But getting a good implementation may take some time, I'm sure. Furthermore, other things might be more meaningful for the time being. For example an array sort or search? Or a binary tree structure? Such items are easy enough to implement on a low level, but would be prohibitively expensive to do in Javascript.
On the power issue: I actually though you couldn't do that. It says Espruino will only enter Deep Sleep when there are no timers in the reference and I assumed that both are timers. Well, especially the one with setInterval(). It then worsens things further by saying that * The System Timer will also pause*. Ouch :). Good to know though that this already works.
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.
Thanks for the quick response :).
About the delay: yes and no. You can make it very clear in the function description that this is only a rough delay, and that it may or may not be accurate (as I recall, you already do that at some points). While it does block the execution, it could be used with e.g. a setInterval to call it every 2000 milliseconds. Having a dedicated delay function would then hopefully free up that time, eg
delay(1000)
to do more meaningful things than just sit around and wait for that part of the code to execute. But getting a good implementation may take some time, I'm sure. Furthermore, other things might be more meaningful for the time being. For example an array sort or search? Or a binary tree structure? Such items are easy enough to implement on a low level, but would be prohibitively expensive to do in Javascript.On the power issue: I actually though you couldn't do that. It says Espruino will only enter Deep Sleep when there are no timers in the reference and I assumed that both are timers. Well, especially the one with setInterval(). It then worsens things further by saying that * The System Timer will also pause*. Ouch :). Good to know though that this already works.