OK. Thanks for your help. I'll just summarize all this for future reference:
function loadSettings() { Util.showModal("Loading..."); Puck.eval(`require("Storage").read(${JSON.stringify("myapp.json")})`,data=>{ Util.hideModal(); try { settings = JSON.parse(data); } catch { settings = defaultSettings; } }); } function saveSettings() { Util.showModal("Saving..."); Puck.write(`\x10require("Storage").write(${JSON.stringify("myapp.json")},${JSON.stringify(settings)})\n`,()=>{ Util.hideModal(); }); }
@andrewg_oz started
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.
OK. Thanks for your help. I'll just summarize all this for future reference: