-
• #2
Looks good, although I think you ought to provide an icon - IIRC most clocks expect one.
I think the issue is just that you're calling
info.emit("redraw");
oninfo
, but that is a list of one or more clockinfos. Just doinginfo.items[0].emit("redraw");
should sort you out. -
• #3
Thanks for that, that worked.
I have been testing the next iteration.
I have noticed that after I have hada fix that after swiping out of the clock_info back to say the battery display that the GPS gets powered on again.My question is:
var timeout; // is this the same variable as
hide: function() { Bangle.setGPSPower(0,"clkinfo"); Bangle.removeListener("GPS", onGPS); if (this.timeout) { clearTimeout(this.timeout); /// <<<< as the variable here ? this.timeout = undefined; } resetLastFix(); }
I'm not 100% sure I understand how this.timeout gets defined in code at:
https://github.com/espruino/BangleApps/blob/master/apps/clock_info/lib.js
line 83hide : function() { Bangle.setHRMPower(0,"clkinfo"); Bangle.removeListener("HRM", hrmUpdateHandler); if (this.timeout) { clearTimeout(this.timeout); this.timeout = undefined; ////// where does timeout get declared, just seems to spring into existance } hrm = 0; }, }
-
• #4
is this
var timeout
the same variable asthis.timeout
Nope :)
I'm not 100% sure I understand how this.timeout gets defined in code at:
It's defined in
.run
just a few lines earlier: https://github.com/espruino/BangleApps/blob/master/apps/clock_info/lib.js#L83run : function() { Bangle.setHRMPower(1,"clkinfo"); if (settings.hrmOn==1/*Tap*/) { /* turn off after 1 minute. If Health HRM monitoring is enabled we will still get HRM events every so often */ this.timeout = setTimeout(function() { this.timeout = undefined; Bangle.setHRMPower(0,"clkinfo"); }, 60000); } },
-
• #5
Nope!
Thought so. Will fix to be consistent
My App is available for test at:
https://hughbarney.github.io/BangleApps/?id=clkinfogpsLatest code at:
https://github.com/hughbarney/BangleApps/tree/master/apps/clkinfogps
I'm working on a GPS clock_info. But have a few questions as I am not sure I have got the code right below.
GOAL: I am buiding a simple GPS clock_info that will show the OS map grid coordinates for use when walking. When you swipe to the gps clock info it turns on the GPS. The first time it gets a fix display the time value from the fix.time from the GPS. Once a fix is established turn off the GPS and then start a timer to turn it back on 3 minutes (I will probably choose 90 seconds later on). The goal is to be able to get a GPS fix every 3 mins or so. This is good enough when walking. As long as you have downloaded AGPS the time to first fix is a few minutes. After that it takes about 20 seconds from power to next fix providing the distance travelled is small (which it will be when on foot). In this way the battery drain of turning on the GPS is reduced to 20 seconds every 3 minutes. I have a library module that I made for GPStouch that will do the lat/lon to OS grid conversion. For now I am just displaying the lat/lon.
My code is below.
Problem is that while onGPS() is getting called the info.emit('redraw'); does not seem to result in a redraw. The only way to get an update is to tap the screen again, then it will update.
Would appreciate any feedback on the code as stuff with timers like this can go wrong.
1 Attachment