forked from FOSS/BangleApps
fix #485: weather: add wind direction
parent
aaadbd89f2
commit
863923a3aa
|
@ -531,7 +531,7 @@
|
||||||
{ "id": "weather",
|
{ "id": "weather",
|
||||||
"name": "Weather",
|
"name": "Weather",
|
||||||
"icon": "icon.png",
|
"icon": "icon.png",
|
||||||
"version":"0.04",
|
"version":"0.05",
|
||||||
"description": "Show Gadgetbridge weather report",
|
"description": "Show Gadgetbridge weather report",
|
||||||
"readme": "readme.md",
|
"readme": "readme.md",
|
||||||
"tags": "widget,outdoors",
|
"tags": "widget,outdoors",
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
0.02: Make minor adjustments to widget, and discard stale weather data after a configurable period.
|
0.02: Make minor adjustments to widget, and discard stale weather data after a configurable period.
|
||||||
0.03: Fix flickering last updated time.
|
0.03: Fix flickering last updated time.
|
||||||
0.04: Adjust "weather unknown" message according to Bluetooth connection.
|
0.04: Adjust "weather unknown" message according to Bluetooth connection.
|
||||||
|
0.05: Add wind direction.
|
|
@ -30,10 +30,14 @@
|
||||||
g.setFont("6x8", 1);
|
g.setFont("6x8", 1);
|
||||||
g.setFontAlign(-1, 0, 0);
|
g.setFontAlign(-1, 0, 0);
|
||||||
g.drawString("Humidity", 135, 130);
|
g.drawString("Humidity", 135, 130);
|
||||||
g.drawString("Wind", 135, 142);
|
|
||||||
g.setFontAlign(1, 0, 0);
|
g.setFontAlign(1, 0, 0);
|
||||||
g.drawString(w.hum+"%", 225, 130);
|
g.drawString(w.hum+"%", 225, 130);
|
||||||
g.drawString(locale.speed(w.wind), 225, 142);
|
if ('wind' in w) {
|
||||||
|
g.setFontAlign(-1, 0, 0);
|
||||||
|
g.drawString("Wind", 135, 142);
|
||||||
|
g.setFontAlign(1, 0, 0);
|
||||||
|
g.drawString(locale.speed(w.wind)+' '+w.wrose.toUpperCase(), 225, 142);
|
||||||
|
}
|
||||||
|
|
||||||
g.setFont("6x8", 2).setFontAlign(0, 0, 0);
|
g.setFont("6x8", 2).setFontAlign(0, 0, 0);
|
||||||
g.drawString(w.loc, 120, 170);
|
g.drawString(w.loc, 120, 170);
|
||||||
|
|
|
@ -22,6 +22,20 @@ function scheduleExpiry(json) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert numeric direction into human-readable label
|
||||||
|
*
|
||||||
|
* @param {number} deg - Direction in degrees
|
||||||
|
* @return {string|null} - Nearest compass point
|
||||||
|
*/
|
||||||
|
function compassRose(deg) {
|
||||||
|
if (typeof deg === 'undefined') return null;
|
||||||
|
while (deg<0 || deg>360) {
|
||||||
|
deg = (deg+360)%360;
|
||||||
|
}
|
||||||
|
return ['n','ne','e','se','s','sw','w','nw','n'][Math.floor((deg+22.5)/45)];
|
||||||
|
}
|
||||||
|
|
||||||
function setCurrentWeather(json) {
|
function setCurrentWeather(json) {
|
||||||
scheduleExpiry(json);
|
scheduleExpiry(json);
|
||||||
exports.current = json.weather;
|
exports.current = json.weather;
|
||||||
|
@ -30,6 +44,9 @@ function setCurrentWeather(json) {
|
||||||
function update(weatherEvent) {
|
function update(weatherEvent) {
|
||||||
let weather = Object.assign({}, weatherEvent);
|
let weather = Object.assign({}, weatherEvent);
|
||||||
weather.time = Date.now();
|
weather.time = Date.now();
|
||||||
|
if ('wdir' in weather) {
|
||||||
|
weather.wrose = compassRose(weather.wdir);
|
||||||
|
}
|
||||||
delete weather.t;
|
delete weather.t;
|
||||||
|
|
||||||
let json = storage.readJSON('weather.json')||{};
|
let json = storage.readJSON('weather.json')||{};
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 4.2 KiB |
Loading…
Reference in New Issue