How do I clear memory after a save()

Posted on
  • It appears to just replace existing functions but not remove the old ones.

  • All you need to do is a reset() then a save(). The Web IDE should do a reset before uploading code from the right-hand side though (unless you set it up not to).

    If you just do save() then you're saving the current state of the interpreter, which is the state that it last loaded from flash, plus any extra functions you defined this time around.

  • save(); will erase the current saved program, and save the current state of the Espruino to flash, and then reset the Espruino (which will then start up with the freshly saved program and call onInit() if that function is defined).

    If you want to clear the saved program, you can do reset(); (which restarts without loading saved code) and then save(); to save this clean slate.

  • That seem to work, but I lost the Espruino Banner.

  • The Espruino banner comes and goes, IME. I've never noticed a pattern in when it does or doesn't show up, though I'm sure there is one.

  • Yes, it's a bit odd, but:

    If Espruino is loading from flash (even if it is loading empty code written by save()) it doesn't display the logo... So pretty much the only way you get the logo displayed is right after you update the firmware :)

    The reason is that if you've saved anything and you connect to a PC, you want to print as little text as possible in case the PC isn't listening to what's being printed - because if the PC isn't reading data, output buffers get full, and the code halts waiting for it to empty again.

  • reset() and save() do not always work for me:­297205

  • Just to add the answer here too: If you've set the IDE to Save on Send, it saves the code in a different area (as it's saving raw JS, rather than an image of interpreter state).

    To force what you saved that way to be removed, just run E.setBootCode() without arguments.

  • oops... should be documented where the save option is can be enabled...

    Is 'auto-save on/after upload' it using E.setBootCode() internally?

  • The 'auto save' option in the IDE? That just tries to save your code into Chrome, so next time you start the IDE it remembers - it doesn't have anything to do with the board

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

How do I clear memory after a save()

Posted by Avatar for tobor @tobor