forked from FOSS/BangleApps
commit
b8f5f973c5
|
@ -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,
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
0.01: New clock!
|
||||
0.02: Load steps from Health Tracking app (if installed)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue