commit
392038be8a
|
|
@ -824,7 +824,7 @@
|
|||
{
|
||||
"id": "weather",
|
||||
"name": "Weather",
|
||||
"version": "0.11",
|
||||
"version": "0.12",
|
||||
"description": "Show Gadgetbridge weather report",
|
||||
"icon": "icon.png",
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
|
|
|
|||
|
|
@ -8,3 +8,4 @@
|
|||
0.09: Fix crash when weather.json is absent.
|
||||
0.10: Use new Layout library
|
||||
0.11: Bangle.js 2 support
|
||||
0.12: Allow hiding the widget
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ You can view the full report through the app:
|
|||
1. Install [Gadgetbridge for Android](https://f-droid.org/packages/nodomain.freeyourgadget.gadgetbridge/) on your phone.
|
||||
2. Set up [Gadgetbridge weather reporting](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Weather).
|
||||
|
||||
## Settings
|
||||
|
||||
* Expiration timespan can be set after which the local weather data is considered as invalid
|
||||
* Widget can be hidden
|
||||
|
||||
## Controls
|
||||
|
||||
BTN2: opens the launcher
|
||||
BTN2: opens the launcher (Bangle.js 1)
|
||||
BTN: opens the launcher (Bangle.js 2)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@
|
|||
},
|
||||
onchange: x => save('expiry', x),
|
||||
},
|
||||
'Hide Widget': {
|
||||
value: "hide" in settings ? settings.hide : false,
|
||||
format: () => (settings.hide ? 'Yes' : 'No'),
|
||||
onchange: () => {
|
||||
settings.hide = !settings.hide
|
||||
save('hide', settings.hide);
|
||||
},
|
||||
},
|
||||
'< Back': back,
|
||||
});
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,9 +1,25 @@
|
|||
(() => {
|
||||
const weather = require('weather');
|
||||
|
||||
|
||||
var dirty = false;
|
||||
|
||||
let settings;
|
||||
|
||||
function loadSettings() {
|
||||
settings = require('Storage').readJSON('weather.json', 1) || {};
|
||||
}
|
||||
|
||||
function setting(key) {
|
||||
if (!settings) { loadSettings(); }
|
||||
const DEFAULTS = {
|
||||
'expiry': 2*3600000,
|
||||
'hide': false
|
||||
};
|
||||
return (key in settings) ? settings[key] : DEFAULTS[key];
|
||||
}
|
||||
|
||||
weather.on("update", w => {
|
||||
if (setting('hide')) return;
|
||||
if (w) {
|
||||
if (!WIDGETS["weather"].width) {
|
||||
WIDGETS["weather"].width = 20;
|
||||
|
|
@ -21,7 +37,7 @@
|
|||
});
|
||||
|
||||
Bangle.on('lcdPower', on => {
|
||||
if (on && dirty) {
|
||||
if (on && dirty && !setting('hide')) {
|
||||
WIDGETS["weather"].draw();
|
||||
dirty = false;
|
||||
}
|
||||
|
|
@ -29,8 +45,9 @@
|
|||
|
||||
WIDGETS["weather"] = {
|
||||
area: "tl",
|
||||
width: weather.get() ? 20 : 0,
|
||||
width: weather.get() && !setting('hide') ? 20 : 0,
|
||||
draw: function() {
|
||||
if (setting('hide')) return;
|
||||
const w = weather.get();
|
||||
if (!w) return;
|
||||
g.reset();
|
||||
|
|
@ -47,5 +64,9 @@
|
|||
g.drawString(t, this.x+10, this.y+24);
|
||||
}
|
||||
},
|
||||
reload:function() {
|
||||
loadSettings();
|
||||
WIDGETS["weather"].redraw();
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in New Issue