Can I toggle widget display on/off? #5320
Replies: 1 comment
-
Posted at 2022-10-26 by @gfwilliams There's nothing built-in, and it seems every clock that needs it implements their own hacks. ... but to try and avoid this, I just added a library. Developing with libraries requires a few tweaks: https://github.com/espruino/BangleApps/tree/master/modules but once that is done, you can just do Posted at 2022-10-26 by BillV Thanks for the quick reply - it sounds good but I can't get the module to work. Uploading the module to storage gave Uncaught ReferenceError: "exports" is not defined at line 4 col 8 in widget_utils followed by Module widget_utils not found when I ran it (and also when I changed the IDE search path ). But if I try require("wear_detect").isWorn().then(worn => { I must be missing something! Posted at 2022-10-26 by @gfwilliams Did you read what was mentioned on https://github.com/espruino/BangleApps/tree/master/modules ? If you upload it to a file called Adding the search path won't work right now as since I just added the module it's not uploaded to the main banglejs.com/apps site yet Posted at 2022-10-26 by BillV I did read that and definitely loaded to widget_utils without the .js, just tried it again and got the same result. I also tried loading wear_detect into storage and got the same "exports not defined" error although it works fine when loaded from the site. Sorry to be making heavy weather of this...is there something else I need to do to get my watch to look for a local copy? Thanks. Posted at 2022-10-26 by BillV ...but in the meantime I've just copied your code into my app and it works beautifully. Thanks again - I'm a new user of Bangle.js and I love it! Posted at 2022-10-27 by myxor When i try to use the new widget_utils library i see the following in the Web IDE:
Posted at 2022-10-27 by @gfwilliams
Yes - that's expected because it's not on the main website yet. @myxor did you read https://github.com/espruino/BangleApps/blob/master/modules/README.md and upload the file to I just tried this and it works great:
Posted at 2022-10-27 by myxor I am sorry, i didn't read the README in total. I now understand why this is expected. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2022-10-26 by BillV
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.
Beta Was this translation helpful? Give feedback.
All reactions