You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi,

    I just uploaded this:

    Hopefully it'll give you nice easy access to nonvolatile memory, without having to faff around with pages.

    /* No arguments mean use the default, which will work on the Original Espruino or Espruino Pico
     You can supply extra arguments to choose which flash page you'll use, and even whether you
     use external flash memory - but be careful when doing this. You can accidentally overwrite
     Espruino itself! */
    var f = new (require("FlashEEPROM"))(); 
    f.write(0, "Hello");
    f.write(1, "World");
    //.. you can write to any address between 0 and 255, with any data up to 256 chars long
    // returns new Uint8Array([72, 101, 108, 108, 111])
    // returns "World"
    // returns [
    //  new Uint8Array([72, 101, 108, 108, 111]),
    //  new Uint8Array([87, 111, 114, 108, 100])
    // ]
    f.write(1, "Espruino");
    // has now overwritten 'World'
    // returns "Espruino"
    /* You can tidy up the journal if you want, removing any values that were
    overwritten by subsequent writes. It can take around a second though */

Avatar for Gordon @Gordon started