I'm working on a watch face that fills the whole screen including the widget area. I don't miss widgets because I find them too small to read at a glance, but I have added a second screen that briefly shows battery and step count (in a large font!) when I tap the watch face. I'm wondering if it's possible to include widgets just on that second screen.
I've tried to do this by running Bangle.loadWidgets() and saving a copy of WIDGETS when the app is loaded, immediately before g.clear(). When the second screen is displayed I restore WIDGETS and run Bangle.drawWidgets(). After a timeout I set WIDGETS=[] before the original display is redrawn. This all works but I get an error message:
Uncaught Error: Cannot read property 'width' of undefined
at line 1 col 65 in widlock.wid.js
WIDGETS["lock"].width=Bangle.isLocked()?16:0;Bangle.drawWidg...
in function called from system
The restored copy of WIDGETS does contain ["lock"].width and anyway I get the same message if I run loadWidgets() again instead of restore plus drawWidgets(). The error doesn't seem to stop the watch running but I'd like to get rid of it. Is there a better way to toggle the widget display on/off?
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.
I'm working on a watch face that fills the whole screen including the widget area. I don't miss widgets because I find them too small to read at a glance, but I have added a second screen that briefly shows battery and step count (in a large font!) when I tap the watch face. I'm wondering if it's possible to include widgets just on that second screen.
I've tried to do this by running Bangle.loadWidgets() and saving a copy of WIDGETS when the app is loaded, immediately before g.clear(). When the second screen is displayed I restore WIDGETS and run Bangle.drawWidgets(). After a timeout I set WIDGETS=[] before the original display is redrawn. This all works but I get an error message:
Uncaught Error: Cannot read property 'width' of undefined
at line 1 col 65 in widlock.wid.js
WIDGETS["lock"].width=Bangle.isLocked()?16:0;Bangle.drawWidg...
in function called from system
The restored copy of WIDGETS does contain ["lock"].width and anyway I get the same message if I run loadWidgets() again instead of restore plus drawWidgets(). The error doesn't seem to stop the watch running but I'd like to get rid of it. Is there a better way to toggle the widget display on/off?
Thanks for any help.