-
• #2
Not sure if ClockFace and Layout libs do that automatically because I'm currently not using them, but are you drawing the screen every minute or so? If you draw the screen every cycle, it may be the reason.
Refer to e.g. https://github.com/alessandrococco/BangleApps/blob/3bddcd402d8e3dd3e9474e022bfe86478cebf811/apps/hworldclock/app.js#L113 -
• #3
Not sure if ClockFace and Layout libs do that automatically because I'm currently not using them, but are you drawing the screen every minute or so?
Yes, I configured Clockface with a "precision" of 60 seconds.
If you draw the screen every cycle, it may be the reason.
Damn, I didn't notice I forgot to redraw my topbar only if something changed .-. I'll fix asap!
Thanks!
-
• #4
I updated the
renderTopBar()
method to draw the "widgets" only if its value has been changed but there's something wrong. Last night battery drop from 70% to 30% :-(let prevLocked = undefined; let prevConnected = undefined; function renderTopBar() { const itemW = 10; const itemH = 2; let locked = Bangle.isLocked(); if (locked != prevLocked) { const lockColor = locked ? g.theme.fg : g.theme.bg; g.setColor(lockColor).fillRect(0, 0, itemW, itemH).setColor(g.theme.fg); prevLocked = locked; } let connected = NRF.getSecurityStatus().connected; if (connected != prevConnected) { const bluetoothColor = connected ? (g.theme.dark ? "#0ff" : "#00f") : (g.theme.dark ? "#666" : "#999"); g.setColor(bluetoothColor).fillRect(itemW + 1, 0, 1 + itemW * 2, itemH).setColor(g.theme.fg); prevConnected = connected; } } Bangle.on("lock", b => { renderTopBar(); }); NRF.on("connect", () => { renderTopBar(); }); NRF.on("disconnect", () => { renderTopBar(); });
Am I missing anything else?
-
• #5
Calling
this.layout.update();
every minute might be expensive?You could try removing lazy rendering, and do something like this:
if (changed.d) { // check days first: may need to update layout this.layout.update(); // dayStr could be a different size now this.layout.render(this.layout.date); this.layout.render(this.layout.dayStr); } if (changed.h) this.layout.render(this.layout.hour); if (changed.m) { this.layout.render(this.layout.minutes); this.layout.render(this.layout.steps); }
-
• #6
Thanks, I can try it but I'm not sure about it: without the
renderTopBar()
method the battery lasts at least 10 days. Now it lasts 2/3 days :-(I have no widgets installed: only alarms, messages & android app.
Hello!
Lately I have little free time but I am trying to work on my own clock using ClockFace and Layout libs.
My goals are:
After I added the top bar I noticed a HUGE battery drain (30-40% per day!) but I don't undestand why.
What's wrong with my code?
The code is in my fork: https://github.com/alessandrococco/BangleApps/blob/poc-my-clock/apps/patclock/app.js
Thank you! :-)
1 Attachment