1
0
Fork 0

Merge pull request #1050 from myxor/clicompleteclk_v0.2

CLI complete clock v0.02
master
Gordon Williams 2021-12-10 12:46:48 +00:00 committed by GitHub
commit b8f5f973c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 25 deletions

View File

@ -4845,7 +4845,7 @@
{ "id": "clicompleteclk",
"name": "CLI complete clock",
"shortName":"CLI cmplt clock",
"version":"0.01",
"version":"0.02",
"description": "Command line styled clock with lots of information",
"icon": "app.png",
"allow_emulator": true,

View File

@ -1 +1,2 @@
0.01: New clock!
0.02: Load steps from Health Tracking app (if installed)

View File

@ -6,9 +6,8 @@ It can show the following (depending on availability) information:
* Time
* Day of week
* Date
* Weather condition (requires weather app)
* Temperature (requires weather app)
* Steps (requires a step widget)
* Weather conditions and temperature (requires app [Weather](https://banglejs.com/apps/#weather))
* Steps (requires app [Health Tracking](https://banglejs.com/apps/#health%20tracking) or a step widget)
* Heart rate (when screen is on and unlocked)
## TODO

View File

@ -68,7 +68,7 @@ function drawInfo(now) {
*/
// weather
var weatherJson = getWeather();
const weatherJson = getWeather();
if(weatherJson && weatherJson.weather){
const currentWeather = weatherJson.weather;
@ -84,9 +84,9 @@ function drawInfo(now) {
}
// steps
if (stepsWidget() != undefined) {
const steps = getSteps();
if (steps != undefined) {
writeLineTopic("STEP", i);
const steps = stepsWidget().getSteps();
writeLine(steps, i);
i++;
}
@ -103,8 +103,6 @@ function drawHeartRate(i) {
writeLine(hrtValue,i);
else
writeLine(hrtValue,i, topicColor);
} else {
writeLine("...",i);
}
lastHeartRateRowIndex = i;
}
@ -128,6 +126,30 @@ function writeLine(str,line,pColor){
g.drawString(str,marginLeftData,y);
}
function getSteps() {
var steps = 0;
let health;
try {
health = require("health");
} catch (e) {
// Module health not found
}
if (health != undefined) {
health.readDay(new Date(), h=>steps+=h.steps);
} else if (WIDGETS.wpedom !== undefined) {
return WIDGETS.wpedom.getSteps();
} else if (WIDGETS.activepedom !== undefined) {
return WIDGETS.activepedom.getSteps();
}
return steps;
}
function getWeather() {
let jsonWeather = storage.readJSON('weather.json');
return jsonWeather;
}
// EVENTS:
// turn on HRM when the LCD is unlocked
@ -138,11 +160,11 @@ Bangle.on('lock', function(isLocked) {
hrtValue = "...";
else
hrtValueIsOld = true;
drawHeartRate();
} else {
hrtValueIsOld = true;
Bangle.setHRMPower(0,"clicompleteclk");
}
drawHeartRate();
});
Bangle.on('lcdPower',function(on) {
@ -166,21 +188,6 @@ Bangle.on('HRM', function(hrm) {
//}
});
function stepsWidget() {
if (WIDGETS.activepedom !== undefined) {
return WIDGETS.activepedom;
} else if (WIDGETS.wpedom !== undefined) {
return WIDGETS.wpedom;
}
return undefined;
}
function getWeather() {
let jsonWeather = storage.readJSON('weather.json');
return jsonWeather;
}
g.clear();
Bangle.setUI("clock");
Bangle.loadWidgets();