• Seemed to sort itself out!

    Not quite. I did it :)

    My process was to upload the code, then press the button, then save()

    Yes, so it saved the state of the board after you'd pressed the button :)

    Am I right is saying that the current value of the vars is written to flash...

    Yes, that's basically right - except reset() resets everything - it doesn't load your code at all.

    So:

    • save() : save the current contents of RAM into flash
    • power on/hard reset/load() : load image from flash into RAM, run onInit()
    • reset() : reset everything to 'factory fresh'

    It's a bit different to a compiled language, but it makes sense as there isn't space for it to store both the original state and the new state at once.

    There is some at the bottom of the Quick Start:

    The save() command saves the current state of the pins and on-chip peripherals, as well as all your functions, variables, watches and timers. The commands that you typed in previously won't be executed again though. If you want to execute some code when Espruino starts (for example you may need to initialise some external bit of hardware like an LCD), create a function called onInit.

    and it's touched on slightly in Troubleshooting. It's hard to know where people will look for it though! It seems most people (like me) don't read much of the documentation until they actually have a problem!

About

Avatar for Gordon @Gordon started