widgps: move interval check to draw method

master
Erik Andresen 2022-05-07 13:26:35 +02:00
parent d20b52ee79
commit 9fa406450b
1 changed files with 10 additions and 8 deletions

View File

@ -6,14 +6,6 @@
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;
}
@ -29,6 +21,16 @@
} else {
g.setColor("#888"); // off = grey
}
// check if we need to update the widget periodically
if (Bangle.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 (!Bangle.isGPSOn() && interval !== undefined) {
clearInterval(interval);
interval = undefined;
}
g.drawImage(atob("GBiBAAAAAAAAAAAAAA//8B//+BgYGBgYGBgYGBgYGBgYGBgYGB//+B//+BgYGBgYGBgYGBgYGBgYGBgYGB//+A//8AAAAAAAAAAAAA=="), this.x, 2+this.y);
}};
})();