Because you did the save directly to flash AND did a save() too, you got two watches going on... you do either or... just not both... . Better would be to put your setWatch() into an onInit() function. That's the clean way to make sure what is going on when power cycling. You may even put your counter initialization there, because if you go with save but play a bit before executing the save() command, you save an already incremented counterand and it will start over with the already incremented counter rather than with 0 on power cycle. Take a look at conversation about simple explanation how to save code that espruino run on start? and related ones. It is not anymore all there is because Espruino has evolved and offers additional options, but the explained concepts still apply. If you want to keep the counter going beyond a single power cycle you save its value into the flash store on every increment and pick it up from there in the onInit() for resuming with last value on power cycle. I hope this helps.
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.
Because you did the save directly to flash AND did a save() too, you got two watches going on... you do either or... just not both... . Better would be to put your setWatch() into an onInit() function. That's the clean way to make sure what is going on when power cycling. You may even put your counter initialization there, because if you go with save but play a bit before executing the save() command, you save an already incremented counterand and it will start over with the already incremented counter rather than with 0 on power cycle. Take a look at conversation about simple explanation how to save code that espruino run on start? and related ones. It is not anymore all there is because Espruino has evolved and offers additional options, but the explained concepts still apply. If you want to keep the counter going beyond a single power cycle you save its value into the flash store on every increment and pick it up from there in the onInit() for resuming with last value on power cycle. I hope this helps.