Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@
{ "id": "weather",
"name": "Weather",
"icon": "icon.png",
"version":"0.03",
"version":"0.05",
"description": "Show Gadgetbridge weather report",
"readme": "readme.md",
"tags": "widget,outdoors",
Expand Down
4 changes: 3 additions & 1 deletion apps/weather/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
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.05: Add wind direction.
16 changes: 12 additions & 4 deletions apps/weather/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@
g.setFont("6x8", 1);
g.setFontAlign(-1, 0, 0);
g.drawString("Humidity", 135, 130);
g.drawString("Wind", 135, 142);
g.setFontAlign(1, 0, 0);
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.drawString(w.loc, 120, 170);
Expand All @@ -56,10 +60,14 @@
}

function update() {
NRF.removeListener("connect", update);
if (weather.current) {
draw();
} else if (NRF.getSecurityStatus().connected) {
E.showMessage("Weather unknown\n\nIs Gadgetbridge\nweather reporting\nset up on your\nphone?");
} else {
E.showMessage('Weather unknown\n\nIs Gadgetbridge\nconnected?');
E.showMessage("Weather unknown\n\nGadgetbridge\nnot connected");
NRF.on("connect", update);
}
}

Expand All @@ -77,7 +85,7 @@

weather.on("update", update);

update(weather.current);
update();

// Show launcher when middle button pressed
setWatch(Bangle.showLauncher, BTN2, {repeat: false, edge: 'falling'});
Expand Down
17 changes: 17 additions & 0 deletions apps/weather/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
scheduleExpiry(json);
exports.current = json.weather;
Expand All @@ -30,6 +44,9 @@ function setCurrentWeather(json) {
function update(weatherEvent) {
let weather = Object.assign({}, weatherEvent);
weather.time = Date.now();
if ('wdir' in weather) {
weather.wrose = compassRose(weather.wdir);
}
delete weather.t;

let json = storage.readJSON('weather.json')||{};
Expand Down
8 changes: 4 additions & 4 deletions apps/weather/readme.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Weather

Shows Gadgetbridge weather reports.
This allows your Bangle.js to display weather reports from the Gadgetbridge app on an Android phone.

This adds a widget with a weather pictogram and the temperature.
It adds a widget with a weather pictogram and the temperature.
You can view the full report through the app:
![Screenshot](screenshot.png)

## Setup

See [this guide](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Weather)
to setup Gadgetbridge weather reporting.
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).

## Controls

Expand Down
Binary file modified apps/weather/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.