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, powered by microcosm.
Report a problem