Nice idea removing setInterval - I'd thought you might need it to detect 0 RPM, but you're right - you can check lastTime when you go to get the RPM value.
onInit stuff doesn't make that much difference in terms of memory usage or efficiency really. I'd actually be tempted to stay with what you're doing, as it makes it easier for you to 'tweak' things later on if you want to.
The only bad point is that if you had an LCD or some external hardware that needed initialisation, you'd still need onInit to handle that.
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.
Nice idea removing
setInterval
- I'd thought you might need it to detect 0 RPM, but you're right - you can check lastTime when you go to get the RPM value.onInit
stuff doesn't make that much difference in terms of memory usage or efficiency really. I'd actually be tempted to stay with what you're doing, as it makes it easier for you to 'tweak' things later on if you want to.The only bad point is that if you had an LCD or some external hardware that needed initialisation, you'd still need onInit to handle that.