• Using the memory location you get that way is always inside the memory area reserved for JS, so it'll always get cleared on restart. Potentially you could write to somewhere right at the top of stack - I think process.memory() might give you some addresses you could use.

    Is there another way ? Like some other memory location

    You could potentially find some piece of on-chip hardware that's not used (let's say QDEC the quadrature decoder): https://infocenter.nordicsemi.com/index.­jsp?topic=%2Fcom.nordic.infocenter.nrf52­832.ps.v1.1%2Fnvmc.html

    And then write to one of the registers that won't do anything unless it's enabled like SAMPLEPER - so address 0x40012508 - and then you'd be ok to peek/poke.

    Do I understand this correctly: long-pressing button 3 (or using load) will completely reset the js interpreter, and read all .boot files and so on ?

    Correct, yes.

    Would it be possible to use a saved state of the interpreter (saved with http://www.espruino.com/Reference#l__glo­bal_save) which gets loaded at the beginning of a .boot script and contains a Int8Array ?

    Yes, you could, but that's still saved to Storage... So it'll be a lot slower and more inefficient than just writing a single bool to Storage explicitly.

    Or is there really no way to achieve this ?

    There's no way to preserve data in RAM inside the JS interpreter between apps, no. I guess potentially something could be added, but it seems like with the kill event you've really got what you want - especially as it's a bool, if you write the same value Storage is smart enough to know and not change the file, so it's really not going to be wearing out your flash.

About

Avatar for Gordon @Gordon started