I wonder what happens if an application is terminated or replaced, while a sensor is powered on.
It's fine. If an app was using something and you change app, the sensor is powered off.
Espruino waits about 1 second after the new app has loaded, and then turns off anything that's not used by the new app. The reasoning is especially for stuff like GPS that can take a while to 'warm up' it's good to leave it running between apps if we can so it's ready to use as soon as possible.
Any kind of atExit() callback, in order to clean up things properly before terminating?
Yep, E.on('kill',...) - but no need to turn off the sensor (in fact because of the above, it may be a bad thing to do)
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.
It's fine. If an app was using something and you change app, the sensor is powered off.
Espruino waits about 1 second after the new app has loaded, and then turns off anything that's not used by the new app. The reasoning is especially for stuff like GPS that can take a while to 'warm up' it's good to leave it running between apps if we can so it's ready to use as soon as possible.
Yep,
E.on('kill',...)
- but no need to turn off the sensor (in fact because of the above, it may be a bad thing to do)