-
I'm trying to use basic widget example from Bangle.js Widgets.
Using it in IDE with this works:
WIDGETS = {}; (() => { function draw() { g.reset(); g.drawString("X", this.x, this.y); } WIDGETS["mywidget"] = { area: "tl", width: 28, draw: draw }; })() Bangle.drawWidgets();
But when I remove first/last lines and upload resulting code to Bangle.js 2 using my local copy of https://banglejs.com/apps the widget is not loaded.
How can I debug why it is not loaded?
-
I tried this code to edit same number with steps of 10, 1 or 0.1 but when I edit number e.g. in "number x10" menu, that value it not updated to other menus. How can I fix this?
var number = 50.0; var menu = { "" : { "title" : "-- Menu --" }, "number x10" : { value : number, format: v => v.toFixed(1), step: 10, onchange : v => { number=v; } }, "number x1" : { value : number, format: v => v.toFixed(1), step: 1, onchange : v => { number=v; } }, "number x0.1" : { value : number, format: v => v.toFixed(1), step: 0.1, onchange : v => { number=v; } }, "Exit" : function() { E.showMenu(); }, }; E.showMenu(menu);
-
I've noticed new problem with Bangle.js 2 and
Bangle.getPressure()
:Once "I2C Error: Arbitration (start)" happens, all future calls to
Bangle.getPressure()
will fail with "Uncaught Error: Conversion in progress".This never happened with earlier firmwares but I'm now seeing this quite often with 2v12.40
-
Actually I just got an idea to make delay+setTime corrections more accurate. Main problem with delay+setTime is that delays aren't accurate, but what if I check current time again after the delay to see how long the delay actually was? I'll need to test this a bit before sharing any code.
ps .While more accurate
setTime
would be nice, I'm not sure if that is actually needed. -
There is no other way currently - you can get time at millisecond accuracy but can't set time that accurately.
@Gordon Would it be possible to add
setTime
with better accuracy than one second?EDIT: That's not actually needed, current
setTime
can reach better than 10 ms accuracy when used with delay and some checks. -
That may be too small adjustment.
setTime
has 1 second accuracy and with the delay-trick I'm using it's much better, but still I think adjustment should be well over 100 ms.Otherwise the error from setting time can be larger than the adjustment and it would actually make clock accuracy worse than without any adjustment.
-
-
Well my actual code is more complex but the basic idea is this:
setInterval(function() { // adjust by 630 milliseconds let adjusted_time = Date.now() - 630; let delay = 1000 - (adjusted_time % 1000); setTimeout(function() { setTime((adjusted_time + delay) / 1000); }, delay); // adjust every 3 hours }, 3 * 60 * 60 * 1000);
Every 3 hours:
- get current watch time
- calculate adjusted time
- calculate delay until adjusted time is exact second
- wait that delay and then set watch time in seconds
Only one running app must do this or else there will be too much adjustment. I'm currently using code like this in my clock app, but it would be best if it were run in a widget (however I havn't yet learned how to make widgets).
- get current watch time
-
-
-
-
4) is not possible that accurately.
Bangle.js 2 can only set time with one second accuracy but with following trick you can get more accuracy: If current time is e.g. x.3 seconds then wait 700 ms and set time to x+1 seconds. This is somewhat accurate, but the problem is that accuracy varies a bit and after setting time you want to check again how much clock is off becuase it will have changed.
5) keep offset, slowing down shown time, not actual watch time
More accurate solution is to not set watch time but instead keep an offset of how much clock is off and apply that offset to shown time, i.e. don't show actual watch time but time-offset. That 35ms (or whatever) every 10 minutes would then be just added to offset. Unfortunately this would require each app to keep track of that offset.
Hybrid solution is also possible, e.g. one app keeps offset and if offset is over e.g. 300 ms then it changes watch time so other apps will also have correct time.
ps. That 35ms (or whatever) also depends on temperature. If you wear watch on wrist all the time it's not that significant, but if you e.g. like to wear watch over the clothing in winter then temperature should also be taken into account.
-
I want to do it programmatically ...
Looks like you need to edit "setting.json" and set "log" field to "0" - source of settings app
-
-
-
-
You mean launcher vs. in-app menus? If so, yes-ish - they will both behave the same way at least.
I meant that top launcher menu (Messages, Android, Settings, About, ...) is different than submenus (e.g. Settings submenu).
That is confusing and also the submenus don't work that well: I often get item-click when I meant to scroll.
-
-
-
Right now the app loader warns users on every connection if their firmware isn't at the current latest release (2v12), so they'll be getting warnings anyway.
Could you add link to "Firmware update" app to that warning? Currently I need to dismiss that warning and then manually search for that app as it can't even be set as favorite.
-
-
-
-
ok, the problem was that I had
"mywidget.app.js"
in metadata.json when it needs to be"mywidget.wid.js"
.I don't think this is documented, at least not in the widget tutorial.