Add ability to hide icon when GPS is disabled

master
Stanislav Khromov 2022-08-10 23:39:43 +02:00
parent 17fde110a2
commit a7257129ee
5 changed files with 15 additions and 6 deletions

View File

@ -14,6 +14,7 @@ There are two icons which can be used to visualize the GPS/GNSS status:
- Shows in green when the GPS is on and has a fix - Shows in green when the GPS is on and has a fix
2. Different place markers depending on GPS/GNSS status 2. Different place markers depending on GPS/GNSS status
You can also choose to hide the icon when the GPS is off in the settings.
Written by: [Hugh Barney](https://github.com/hughbarney) For support Written by: [Hugh Barney](https://github.com/hughbarney) For support
and discussion please post in the [Bangle JS and discussion please post in the [Bangle JS
@ -21,4 +22,6 @@ Forum](http://forum.espruino.com/microcosms/1424/)
Extended by Marco ([myxor](https://github.com/myxor)) Extended by Marco ([myxor](https://github.com/myxor))
Extended by khromov ([myxor](https://github.com/khromov))
Place marker icons from [icons8.com](https://icons8.com/icon/set/maps/material-outlined). Place marker icons from [icons8.com](https://icons8.com/icon/set/maps/material-outlined).

View File

@ -1 +1 @@
{"crossIcon": "true"} {"crossIcon": true, "hideWhenGpsOff": false}

View File

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

View File

@ -23,6 +23,10 @@ var mainmenu = {
value : !!settings.crossIcon , value : !!settings.crossIcon ,
onchange : v => { writeSettings("crossIcon", v); } onchange : v => { writeSettings("crossIcon", v); }
}, },
"Hide icon when GPS off" : {
value : !!settings.hideWhenGpsOff ,
onchange : v => { writeSettings("hideWhenGpsOff", v); }
},
}; };
E.showMenu(mainmenu); E.showMenu(mainmenu);
}); });

View File

@ -1,6 +1,6 @@
(function() { (function() {
let settings = let settings =
require("Storage").readJSON("widgps.json", 1) || {crossIcon : true}; require("Storage").readJSON("widgps.json", 1) || {crossIcon: true, hideWhenGpsOff: false};
var interval; var interval;
@ -59,11 +59,13 @@ WIDGETS.gps = {
} }
} else { } else {
// GNSS off // GNSS off
if(!settings.hideWhenGpsOff) {
g.drawImage( g.drawImage(
atob("GBiBAAAAAAAAAAB+ABj/ABxDgA4AwAcAwAeMYAfEYAbgYAZwYAM4wAMcQAOOAAGHAAHDgADDwABm4AB+cAA8OAAYGAAAAAAAAAAAAA=="), atob("GBiBAAAAAAAAAAB+ABj/ABxDgA4AwAcAwAeMYAfEYAbgYAZwYAM4wAMcQAOOAAGHAAHDgADDwABm4AB+cAA8OAAYGAAAAAAAAAAAAA=="),
this.x, 2 + this.y); this.x, 2 + this.y);
} }
} }
} }
}
}; };
})(); })();