I am now storing the widget state in the SAMPLER register, with these two functions (and not setting it to false on boot):
function getAlertsStoredState() {
var addr = 0x40012508;
var val = peek8(addr);
val = val & 1;
return val == 1;
}
function setAlertsStoredState( state ) {
var addr = 0x40012508;
var val = peek8(addr) & 254;
if( state == true )
{
val = val + 1;
}
poke8(addr,val);
}
So far it looks like it works the way I intended.
I would be interested to know if there is a way to make some code run only on first boot, but not on bnt3 long presses, but otherwise it works as expected.
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.
I am now storing the widget state in the SAMPLER register, with these two functions (and not setting it to false on boot):
So far it looks like it works the way I intended.
I would be interested to know if there is a way to make some code run only on first boot, but not on bnt3 long presses, but otherwise it works as expected.
Thanks for all the advice and replies.