When you open an app, basically the whole watch is reset and then loads the app, so you'll definitely need to store those values to flash.
I think you're looking for the E.kill event, although if you only sample once or twice an hour it might not be worth bothering with, and just write to flash immediately.
I also think you might want to change it from a widget into boot code: that runs at every boot, instead of only for apps that load widgets.
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.
When you open an app, basically the whole watch is reset and then loads the app, so you'll definitely need to store those values to flash.
I think you're looking for the
E.kill
event, although if you only sample once or twice an hour it might not be worth bothering with, and just write to flash immediately.I also think you might want to change it from a widget into
boot
code: that runs at every boot, instead of only for apps that load widgets.Edit: well, malaire beat me to it ;-)