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
f.read(0)
// returns new Uint8Array([72, 101, 108, 108, 111])
E.toString(f.read(1))
// returns "World"
f.readAll();
// returns [
// new Uint8Array([72, 101, 108, 108, 111]),
// new Uint8Array([87, 111, 114, 108, 100])
// ]
f.write(1, "Espruino");
// has now overwritten 'World'
E.toString(f.read(1))
// 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 */
f.cleanup();
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.
Hi,
I just uploaded this: http://www.espruino.com/FlashEEPROM
Hopefully it'll give you nice easy access to nonvolatile memory, without having to faff around with pages.