You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • 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.


Avatar for allObjects @allObjects started