widgps: add intervall to update the widget

Periodically update so the always on display does show current GPS fix
pull/1800/head
Erik Andresen 2022-05-07 10:39:28 +02:00
parent d1873ad166
commit d20b52ee79
3 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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",

View File

@ -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;
}