mirror of https://github.com/espruino/BangleApps
gpsautotime: Add setting to hide the widget
parent
2a0cf8e44e
commit
73f976c86b
|
@ -1,2 +1,3 @@
|
|||
0.01: New App!
|
||||
0.02: Set Bangle.js 2 compatible
|
||||
0.03: Add setting to hide the widget
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
"id": "gpsautotime",
|
||||
"name": "GPS auto time",
|
||||
"shortName": "GPS auto time",
|
||||
"version": "0.02",
|
||||
"version": "0.03",
|
||||
"description": "A widget that automatically updates the Bangle.js time to the GPS time whenever there is a valid GPS fix.",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
"tags": "widget,gps",
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"gpsautotime.wid.js","url":"widget.js"}
|
||||
]
|
||||
{"name":"gpsautotime.wid.js","url":"widget.js"},
|
||||
{"name":"gpsautotime.settings.js","url":"settings.js"}
|
||||
],
|
||||
"data": [{"name":"gpsautotime.json"}]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
(() => {
|
||||
var lastTimeSet = 0;
|
||||
|
||||
var settings = Object.assign({
|
||||
// default values
|
||||
show: true,
|
||||
}, require('Storage').readJSON("gpsautotime.json", true) || {});
|
||||
const show = settings.show;
|
||||
delete settings;
|
||||
|
||||
Bangle.on('GPS',function(fix) {
|
||||
if (fix.fix) {
|
||||
var curTime = fix.time.getTime()/1000;
|
||||
|
@ -14,8 +21,9 @@
|
|||
// add your widget
|
||||
WIDGETS["gpsAutoTime"]={
|
||||
area:"tl", // tl (top left), tr (top right), bl (bottom left), br (bottom right)
|
||||
width: 28, // width of the widget
|
||||
width: show ? 4*6+2 : 0, // width of the widget
|
||||
draw: function() {
|
||||
if (!show) return;
|
||||
g.reset(); // reset the graphics context to defaults (color/font/etc)
|
||||
g.setFont("6x8");
|
||||
if ((getTime() - lastTimeSet) <= 60) {
|
||||
|
@ -27,7 +35,9 @@
|
|||
}
|
||||
};
|
||||
|
||||
setInterval(function() {
|
||||
WIDGETS["gpsAutoTime"].draw(WIDGETS["gpsAutoTime"]);
|
||||
}, 1*60000); // update every minute
|
||||
})()
|
||||
if (show) {
|
||||
setInterval(function() {
|
||||
WIDGETS["gpsAutoTime"].draw(WIDGETS["gpsAutoTime"]);
|
||||
}, 1*60000); // update every minute
|
||||
}
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue