mirror of https://github.com/espruino/BangleApps
widgps: add intervall to update the widget
Periodically update so the always on display does show current GPS fixpull/1800/head
parent
d1873ad166
commit
d20b52ee79
|
@ -3,3 +3,4 @@
|
|||
0.03: Fix positioning
|
||||
0.04: Show GPS fix status
|
||||
0.05: Don't poll for GPS status, override setGPSPower handler (fix #1456)
|
||||
0.06: Periodically update so the always on display does show current GPS fix
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "widgps",
|
||||
"name": "GPS Widget",
|
||||
"version": "0.05",
|
||||
"version": "0.06",
|
||||
"description": "Tiny widget to show the power and fix status of the GPS",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
(function(){
|
||||
var interval;
|
||||
|
||||
// override setGPSPower so we know if GPS is on or off
|
||||
var oldSetGPSPower = Bangle.setGPSPower;
|
||||
Bangle.setGPSPower = function(on,id) {
|
||||
var isGPSon = oldSetGPSPower(on,id);
|
||||
WIDGETS.gps.draw();
|
||||
if (isGPSon && interval === undefined) {
|
||||
interval = setInterval(function() {
|
||||
WIDGETS.gps.draw(WIDGETS.gps);
|
||||
}, 10*1000); // update every 10 seconds to show gps fix/no fix
|
||||
} else if (!isGPSon && interval !== undefined) {
|
||||
clearInterval(interval);
|
||||
interval = undefined;
|
||||
}
|
||||
return isGPSon;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue