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