Skip to content

Commit

Permalink
Merge pull request #2978 from peerdavid/master
Browse files Browse the repository at this point in the history
[edgeclk] Option to show weather
  • Loading branch information
gfwilliams committed Aug 29, 2023
2 parents 799428a + 463a107 commit ed8d73b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/edgeclk/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0.01: Initial release.
0.02: Fix reset of progress bars on midnight. Fix display of 100k+ steps.
0.03: Added option to display weather.
7 changes: 7 additions & 0 deletions apps/edgeclk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
![Screenshot](screenshot.png)
![Screenshot](screenshot2.png)
![Screenshot](screenshot3.png)
![Screenshot](screenshot4.png)

Tinxx presents you a clock with as many straight edges as possible to allow for a crisp look and perfect readability.
It comes with a custom font to display weekday, date, time, and steps. Also displays battery percentage while charging.
Expand All @@ -15,10 +16,16 @@ The appearance is highly configurable. In the settings menu you can:
- Switch between 24h and 12h clock.
- Hide or display seconds.*
- Show AM/PM in place of the seconds.
- Show weather temperature and icon in place of the seconds.
- Set the daily step goal.
- En- or disable the individual progress bars.
- Set if your week should start with Monday or Sunday (for week progress bar).

*) Hiding seconds should further reduce power consumption as the draw interval is prolonged as well.

The clock implements Fast Loading for faster switching to and fro.

## Contributors
- [tinxx](https://github.com/tinxx)
- [peerdavid](https://github.com/peerdavid)

34 changes: 32 additions & 2 deletions apps/edgeclk/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
twentyFourH: true,
showAmPm: false,
showSeconds: true,
showWeather: false,
stepGoal: 10000,
stepBar: true,
weekBar: true,
mondayFirst: true,
dayBar: true,
}, require('Storage').readJSON('edgeclk.settings.json', true) || {});


/* Runtime Variables
------------------------------------------------------------------------------*/

Expand Down Expand Up @@ -51,6 +51,33 @@
} else {
drawSteps(stepsOnlyCount);
}

drawWeather();
};

const drawWeather = function () {
if (!settings.showWeather){
return;
}

g.setFontCustom(font, 48, 10, 512 + 12); // double size (1<<9)
g.setFontAlign(1, 1); // right bottom

try{
const weather = require('weather');
const w = weather.get();
let temp = parseInt(w.temp-273.15);
temp = temp < 0 ? '\\' + String(temp*-1) : String(temp);

g.drawString(temp, g.getWidth()-40, g.getHeight() - 1, true);

// clear icon area in case weather condition changed
g.clearRect(g.getWidth()-40, g.getHeight()-30, g.getWidth(), g.getHeight());
weather.drawIcon(w, g.getWidth()-20, g.getHeight()-15, 14);

} catch(e) {
g.drawString("???", g.getWidth()-3, g.getHeight() - 1, true);
}
};

const drawDate = function (date) {
Expand Down Expand Up @@ -135,7 +162,8 @@
g.setFontAlign(-1, 1); // left bottom

const steps = Bangle.getHealthStatus('day').steps;
g.drawString((steps < 100000 ? steps.toString() : ((steps / 1000).toFixed(0) + 'K')).padEnd(5, '_'),
const toKSteps = settings.showWeather ? 1000 : 100000;
g.drawString((steps < toKSteps ? steps.toString() : ((steps / 1000).toFixed(0) + 'K')).padEnd(5, '_'),
iconSize[0] + 6, g.getHeight() - 1, true);

if (onlyCount === true) {
Expand Down Expand Up @@ -229,12 +257,14 @@
// However, to save power while on battery only step count will get updated.
// This will update icon and progress bar as well:
if (!charging) drawSteps();
drawWeather();
};

const onHealth = function () {
if (!lcdPower || charging) return;
// This will update progress bar and icon:
drawSteps();
drawWeather();
};

const onLock = function (locked) {
Expand Down
4 changes: 2 additions & 2 deletions apps/edgeclk/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"id": "edgeclk",
"name": "Edge Clock",
"shortName": "Edge Clock",
"version": "0.02",
"version": "0.03",
"description": "Crisp clock with perfect readability.",
"readme": "README.md",
"icon": "app.png",
"screenshots": [{"url":"screenshot.png"}, {"url":"screenshot2.png"}, {"url":"screenshot3.png"}],
"screenshots": [{"url":"screenshot.png"}, {"url":"screenshot2.png"}, {"url":"screenshot3.png"}, {"url":"screenshot4.png"}],
"type": "clock",
"tags": "clock",
"supports": ["BANGLEJS2"],
Expand Down
Binary file added apps/edgeclk/screenshot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions apps/edgeclk/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
twentyFourH: true,
showAmPm: false,
showSeconds: true,
showWeather: false,
stepGoal: 10000,
stepBar: true,
weekBar: true,
Expand Down Expand Up @@ -57,6 +58,7 @@
settings.showAmPm = !settings.showAmPm;
// TODO can this be visually changed?
if (settings.showAmPm && settings.showSeconds) settings.showSeconds = false;
if (settings.showAmPm && settings.showWeather) settings.showWeather = false;
save();
},
},
Expand All @@ -66,6 +68,17 @@
settings.showSeconds = !settings.showSeconds;
// TODO can this be visually changed?
if (settings.showSeconds && settings.showAmPm) settings.showAmPm = false;
if (settings.showSeconds && settings.showWeather) settings.showWeather = false;
save();
},
},
'Show Weather': {
value: settings.showWeather,
onchange: () => {
settings.showWeather = !settings.showWeather;
// TODO can this be visually changed?
if (settings.showWeather && settings.showAmPm) settings.showAmPm = false;
if (settings.showWeather && settings.showSeconds) settings.showSeconds = false;
save();
},
},
Expand Down

0 comments on commit ed8d73b

Please sign in to comment.