Nice! And yes, sorry for not pulling in the bootloader change as it was.
Did you try const [discoveredApp] = allClockApps().sort((a, b) => a.sortorder - b.sortorder);? Because Espruino doesn't support destructuring so I'd have thought this might error.
Is there any way less invasive than calling load()
Actually, I think you should be able to call load("clock_app_name.js") which at least doesn't require any bootloader mods at all - so it could go in a Widget...
Bangle.on("lcdPower", function onLcdPower(on) {
if (!on && " random" === clockApp) {
// use your previous bootloader code to find a random `clockApp`
load(clockApp); //< clockApp is the filename, not the file contents
}
});
But yes, that forces the screen on. I guess potentially we could have some kind of firmware change that allows it to stay off... Other option is just to load the random clock on the lcdPoweron event?
One option is actually just to modify the clock apps themselves. If each clock app provided a unload() function that unregistered any event handlers, it would be pretty easy to call unload() and then eval() a new clock app.
Worst case you could detect if a clock didn't implement unload() and then do the load(clockFilename) command.
P.S. I was scared to load a different bootloader to my watch but I went for it!
Maybe the word 'bootloader' is overly scary! You can do what you want in JS and you'll always be able to recover the Bangle with 'install default apps' in the App Loader, so go for it!
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.
Nice! And yes, sorry for not pulling in the bootloader change as it was.
Did you try
const [discoveredApp] = allClockApps().sort((a, b) => a.sortorder - b.sortorder);
? Because Espruino doesn't support destructuring so I'd have thought this might error.Actually, I think you should be able to call
load("clock_app_name.js")
which at least doesn't require any bootloader mods at all - so it could go in a Widget...But yes, that forces the screen on. I guess potentially we could have some kind of firmware change that allows it to stay off... Other option is just to load the random clock on the
lcdPower
on
event?One option is actually just to modify the clock apps themselves. If each clock app provided a
unload()
function that unregistered any event handlers, it would be pretty easy to callunload()
and theneval()
a new clock app.Worst case you could detect if a clock didn't implement
unload()
and then do theload(clockFilename)
command.Maybe the word 'bootloader' is overly scary! You can do what you want in JS and you'll always be able to recover the Bangle with 'install default apps' in the App Loader, so go for it!