0.05: Don't poll for GPS status, override setGPSPower handler (fix #1456)

pull/1509/head
Gordon Williams 2022-02-24 11:01:37 +00:00
parent 597d1172be
commit 4143a5f105
3 changed files with 11 additions and 19 deletions

View File

@ -2,3 +2,4 @@
0.02: Don't break if running on 2v08 firmware (just don't display anything)
0.03: Fix positioning
0.04: Show GPS fix status
0.05: Don't poll for GPS status, override setGPSPower handler (fix #1456)

View File

@ -1,7 +1,7 @@
{
"id": "widgps",
"name": "GPS Widget",
"version": "0.04",
"version": "0.05",
"description": "Tiny widget to show the power and fix status of the GPS",
"icon": "widget.png",
"type": "widget",

View File

@ -1,7 +1,13 @@
(function(){
if (!Bangle.isGPSOn) return; // old firmware
// 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();
return isGPSon;
}
function draw() {
WIDGETS.gps={area:"tr",width:24,draw:function() {
g.reset();
if (Bangle.isGPSOn()) {
const gpsObject = Bangle.getGPSFix();
@ -14,20 +20,5 @@
g.setColor("#888"); // off = grey
}
g.drawImage(atob("GBiBAAAAAAAAAAAAAA//8B//+BgYGBgYGBgYGBgYGBgYGBgYGB//+B//+BgYGBgYGBgYGBgYGBgYGBgYGB//+A//8AAAAAAAAAAAAA=="), this.x, 2+this.y);
}
var timerInterval;
Bangle.on('lcdPower', function(on) {
if (on) {
WIDGETS.gps.draw();
if (!timerInterval) timerInterval = setInterval(()=>WIDGETS.gps.draw(), 2000);
} else {
if (timerInterval) {
clearInterval(timerInterval);
timerInterval = undefined;
}
}
});
WIDGETS.gps={area:"tr",width:24,draw:draw};
}};
})();