-
Hello,
I recently upgraded my Bangle1 to 2v20 and discovered that the writeJSON optimization that skips quotes on alphanumeric field names broke my apps. My use case is probably uncommon but I thought I'd mention the workaround I came up with just in case it ever helps anybody else.
Basically, I gather data on my Bangle and save it to JSON formatted files. Using the IDE I export the files to my computer, then import them back into the Bangle emulator. I then run different Bangle apps in the emulator to graph the data (and take screenshots of the graphs).
Anyway, starting with 2v20, writeJSON skips the quotes on alphanumeric field names and because of this, when I used readJSON in the emulator to load the files imported from my Bangle I got a syntax error complaining about the missing quotes. I guess it would be nice for there to be an option added to writeJSON to still include the quotes but until then a simple workaround is just to use write("filename", JSON.stringify("json value")) in lieu of writeJSON("filename", "json value").
I've uploaded a sample script to replicate the problem with my workaround commented out.
As always, many thanks to Gordon and the Espruino team for all their amazing and wonderful work!
-
Great, thank you very much for the clarification! At the risk of complicating the first "Bangle.js Development" tutorial too much, it would have been helpful if "'edge' : 'falling'" were included in the setWatch() example.
Indeed, it must have been the case that my Bangle locked just before I pressed the button. I guess it might be helpful to display a 'locked' indicator in the widget area on the Bangle 1 as on the Bangle 2. I had assumed that on the Bangle 1, the screen was unlocked whenever the display was on.
Finally, on my Bangle 1 I am able to observe the same behavior seen in the Emulator with the above code if I press, briefly hold, then release the button on the 'data' screen. But if I press and release the button quickly on my Bangle 1, showMenu evidently doesn't get the button 'up' event as the menu remains active, waiting for a selection.
Thank you very much for looking into this, hopefully the info in this post will turn out to be useful to other Bangle developers as well.
-
Sorry, I should have provided a complete test case to reproduce the behavior but didn't think it was that big of a deal since I found an easy workaround. But since you kindly already went ahead and investigated it, here is code to demonstrate the issue in the Emulator.
After the menu appears, please click on BTN2 to show the 'data' screen. On the 'data' screen, clicking on BTN2 used to return to the menu, but as you'll see, the menu appears on the mouse button down, and when the mouse button is released, the 'data' screen appears again.
Hmm... I had naively assumed this was because the watch function was being called on the mouse up and mouse down events, but as you've verified and I see now, there's actually something more going on. Could it be that showMenu is responding to the mouse up event?
function showMainMenu() { E.showMenu(); let menu = { '' : { 'title' : '-- Menu --', }, 'Show Data' : function() { showDataScreen(); }, '< Back' : function() { // '<Back' : function() { // hide red back button }, }; E.showMenu(menu); } function showDataScreen() { E.showMenu(); setWatch(() => { g.clear(); showMainMenu(); }, BTN2); // }, BTN2, {edge:'falling'}); displayData(); } function displayData() { g.clear(); g.setFont("Vector", 30); let title = 'Data'; g.drawString(title, 120 - (g.stringWidth(title) / 2), 40); } showMainMenu();
Oh, I just noticed and remembered something that may be related! With 2v15 on my Bangle 1, there have been times when a BTN2 press on a showMenu doesn't select a menu item. Pressing BTN2 again works as expected so I figured it was a minor hardware issue (though I've never experienced this behavior before 2v15). But the ignored BTN2 press just happened again when I ran the above code on my Bangle 1 and resulted in the same behavior happening in the Emulator. And strangely, I uploaded and ran the code again on my Bangle 1, and this time showMenu responded to the first BTN2 press and the code worked as intended (i.e., pressing BTN2 while on the 'data' screen didn't briefly show the menu and unexpectedly return to the 'data' screen).
Well suddenly this got a lot more interesting! Thank you in advance for looking into this and I hope you'll be able to reproduce and resolve the inconsistent behavior on the Bangle 1.
-
I just noticed that there's a difference in the way BTN clicks/presses behave in the Emulator/Bangle.js 1 for the same code. In my app, I have a watch similar to the following when BTN2 is 'pressed':
setWatch(() => { doSomething(); }, BTN2);
My app used to function identically in both the Emulator and on my Bangle.js 1. But now, my watch function gets called twice when I click on BTN2 in the Emulator--once on mouse button up and once on mouse button down. The double call changes the behavior of my app in the Emulator but surprisingly the same code works as it always has on my Bangle.js 1 (2v15), suggesting the function is only being invoked once on my Bangle.js 1.
To make my app work the same in the Emulator and on my Bangle (an 'xdotool' script I made to capture app screenshots using the Emulator broke because of this change) I changed the code to the following:
setWatch(() => { doSomething(); }, BTN2, { edge: 'falling' });
So it's not really a problem at all but I thought I'd mention it in case anybody else gets puzzled by this as well. I suspect this change may have occurred in 2v13 ("Bangle.js1: setUI button handlers now work on falling edge") and I just didn't notice it until now.
Happy Bangle-ing/Developing Everyone!
-
Just wanted to say that I love both my Bangle 1 and Bangle 2 and use them for different activities that each is more suitable for. FWIW, here are features I wish could be added or improved in a Bangle 3:
- gyroscope (would be useful for improving accuracy of apps that analyze movement, such as gesture or step tracking)
- better GPS (Bangle 1 is acceptable, Bangle 2 disappointing though temporarily resolvable via A-GPS)
- brighter screen (I use the Bangle 1 for certain activities because the Bangle 2 screen is just too dim to use under low-light conditions)
- 3 physical buttons (I designed an app to make use of the left/right touchscreen of the Bangle 1, but never imagined that sweat on my fingertips would make using a touch-based UI impractical--thank goodness for Bangle 1's 3 buttons! Also, being able to "double-click" Bangle 1's buttons for input has been quite useful, so having high-quality buttons is a must)
Keeping my fingers crossed for a Bangle 3 someday--many thanks to Gordon for making Bangle 1 and Bangle 2 such amazingly useful and capable devices!
- gyroscope (would be useful for improving accuracy of apps that analyze movement, such as gesture or step tracking)
-
Well, FWIW here's the type of replacement band I got that I'm very pleased with:
https://www.ebay.com/itm/293495192890
I guess some people wouldn't be pleased if you didn't include a band but I would be fine with that.
-
-
Thank you @fewieden!
I guess it takes a while for updates to make their way into the App Loader but look forward having that watchface on my Bangle again soon.
-
Bravo @Gordon for your brilliant analysis (as always) and thank you very much for the tip about doing load() to resolve my problem!
The "Stardate Clock" app is my default watchface and it erroneously defines globally referenced constants within an 'if' block, resulting in undefined value errors later in the code:
if (g.getWidth() < 200) { // Bangle.js 2 const baseUnit1 = 3; ... } else { const baseUnit1 = 5; ... } ... const outRad = baseUnit1 * 5; // baseUnit1 is not defined
I'd create a pull request for this but being a JavaScript newbie I'm not sure what the proper fix for this would be, sorry.
Thanks so much again for your help with this! Hopefully your debugging tip will also help others running into problems with subsequent firmware updates.
-
Well I just tried updating the firmware again and got the same result. BTW, I noticed that the instructions on the Bangle.js "Firmware Updates" page say to release BTN1 a moment after BTN2 when holding down both to enter DFU mode but the IDE Flasher instructions say to release both buttons at the same time. In any case, I reverted back to 2v13 again and it worked as expected so it doesn't seem like a button issue.
A relevant difference, perhaps: After installation of the 2v13 firmware completes my Bangle automatically restarts and shows my default watchface. But after installation of 2v14 completes I see "Reloading..." centered on the screen with "-->Bluetooth" on the bottom. I waited about a minute and nothing happened so then I long-pressed BTN3 and the "Loading..." box appeared but my watch never restarted. So I ended up long pressing BTN1 and BTN2 to restart the watch and that leads to the logo screen with "-->Bluetooth" on the bottom as I explained earlier.
-
Interesting--perhaps the AGPS data "expired" while my watch was turned off then? I noticed that the AGPS app for Bangle.js 1 gives the user the option to select how much data to download but that option isn't provided for Bangle.js 2. I think it had been a couple of days since I last uploaded AGPS data so perhaps only a couple days' worth of data is uploaded to Bangle.js 2.
Regardless, using the AGPS app on days when I need to use GPS is easy so it's a non-issue. Thanks! -
-
Has anybody been able to successfully update their Bangle 1 to the 2v14 firmware? I tried to update mine using both the NRF Toolbox app and the IDE and in both cases the result was the same. The update says it completed but on reboot the watch gets stuck on the logo screen with "-->Bluetooth" at the bottom.
Since it could still connect to the App Loader I tried uninstalling and reinstalling the bootloader and launcher apps but that didn't make any difference. One unusual thing was that when I tried to connect to it via the IDE (to turn it off) I noticed that a "DFU Targ" connection was listed, as though it was still in DFU mode for some reason.
Anyway, I have reverted back to the 2v13 firmware for now (and fortunately all my existing apps are still there).
-
Just thought I'd mention that my Bangle 1 seems to acquire a GPS lock much more quickly and reliably than my Bangle 2 as well. In particular, my Bangle 2 usually takes somewhere between 15-30 minutes to get a lock, outside with an unobstructed view of the sky (while I'm walking my dog).
Because of the discussion about BeiDou reception possibly having been turned off, I thought I'd mention that today--for the first time since I started experimenting with GPS about a week ago--the GPS Info app (BTW, many thanks to its author--it's very neat!) indicated it detected a BeiDou signal:
-
-
I have only "Wake on Touch" and "Wake on BTN1" enabled and noticed recently that my Bangle 2 will wake even if I haven't touched the screen or button. After some experimentation I determined that"Wake on Touch" doesn't actually require touching the screen at all. For example, just "double-tapping" on the back of my (watch) hand strongly enough will unlock the screen. Conversely, softly touching the display doesn't unlock it. It's not really that big of a problem but seems to cause unexpected battery drain and phantom touches.
So, would it be possible to make "Wake on Touch" check that the screen has actually been touched? If not, perhaps the setting should be renamed to "Wake on Tap"?
(Thanks so much to Gordon and all the app developers for making my Bangle 1 & 2 such fun, useful, and amazing devices!)
-
Thank you very much for your helpful reply Gordon!
I recently upgraded to 2v12 and can confirm the new 'stroke' event works on my Bangle.js 2. I think I understand now how to implement letter recognition thanks to your example code but I guess the accuracy will depend on how forgiving your stroke matching algorithm is (hopefully I'll be able to learn more about that from the source code...).
Thank you as always for all your help and hard work!
-
Can somebody please tell me what became of the first unlocked stretch goal, "Character/gesture recognition"? I had hoped it would become a module I could use within an app to input letters.
Or perhaps it became the "Pattern Launcher" app? If so, it might be a good idea to note that on the Bangle.js 2 Implementation Status wiki page.
Many thanks to Gordon and all the developers who've made both of my Bangle.js watches such fun and useful devices!
-
Just thought I'd better point out that I had very similar problems until I upgraded to the latest firmware version, 2v11. After upgrading to 2v11, the battery life has been much better (and stable). The firmware upgrade can be a little problematic, however, so be sure to read the posts related to updating the firmware if you run into any issues.
-
-
Unfortunately I've encountered the same problem trying to update my Bangle 2's firmware as well on iOS.
Some additional info: The error message displayed in the nRF Toolbox app is "##### bytes were sent while 0 byte were reported as received" while every attempt to transmit the firmware shows "CONNECT" then "DISCONNECT" on the Bangle2 display. FWIW, I've attached a screenshot of the nRF Toolbox app log below. BTW, this is the first time I've tried to update the firmware of my Bangle 2, but I've updated the firmware of my Bangle 1 twice and did not encounter any problems (and I'm still using the same version of iOS). Many thanks in advance to whoever can help solve this! -
Thanks very much for adding the ability to take screenshots of the emulator to the Web IDE!
I just wanted to share a tip I learned automating the taking of screenshots generated by my app. I run the emulator on Ubuntu and wanted to use 'xdotool' to take screenshots. I couldn't figure out why 'xdotool click 1' wasn't doing anything when attempting to click on BTN1, BTN2, or BTN3, so I looked into the emulator source code and discovered those areas are listening for 'mousedown' events. So by replacing 'xdotool click 1' in my bash script with 'xdotool mousedown 1', 'sleep 0.5', 'xdotool mouseup 1' I was able to get the emulator to recognize button presses. 'xdotool click 1' does work fine on the screenshot button, however.
-
I post this just as a reference. The Web IDE certainly works in that case...
Thanks for chiming in with another reassuring reference point about large apps. It seems there's something odd about my Chrome/Ubuntu setup, which is very strange because I installed Chrome only to use the Web IDE. Regardless, Gordon's catch of the exception seems to have fixed the problem for me in the beta IDE.
-
Oh--I hadn't noticed that the emulator was out of date, thank you @Gordon for updating it and resolving my issue! And thank you @user140377 for advising me about Util.readStorageJSON().