Use health app also for steps overview.

master
David Peer 2021-12-19 22:42:47 +01:00
parent 91a3b5feef
commit 6252dc8982
2 changed files with 16 additions and 11 deletions

View File

@ -1,11 +1,8 @@
# LCARS clock
A simple LCARS inspired clock.
Note: To display the steps, its necessary to install
the [Pedometer widget](https://banglejs.com/apps/#pedometer%20widget).
To display the month graphs on screen 2, the health app is required.
Nevertheless, lcars can also be used, with limited functionality, without
installing those apps.
Note: To display the steps, the health app is required.
If this app is not installed, the data will not be shown.
## Features

View File

@ -271,14 +271,15 @@ function drawPosition1(){
}
// Plot HRM graph
var data = new Uint16Array(31);
var cnt = new Uint8Array(31);
var data = new Uint16Array(32);
var cnt = new Uint8Array(32);
health.readDailySummaries(new Date(), h=>{
data[h.day]+=h.bpm;
if (h.bpm) cnt[h.day]++;
});
require("graph").drawBar(g, data, {
axes : true,
minx: 1,
gridx : 4,
gridy : 100,
width : 140,
@ -288,10 +289,11 @@ function drawPosition1(){
});
// Plot step graph
var data = new Uint16Array(31);
var data = new Uint16Array(32);
health.readDailySummaries(new Date(), h=>data[h.day]+=h.steps/1000);
require("graph").drawBar(g, data, {
axes : true,
minx: 1,
gridx : 4,
gridy : 5,
width : 140,
@ -341,9 +343,15 @@ function draw(){
* Step counter via widget
*/
function getSteps() {
if (stepsWidget() !== undefined)
return stepsWidget().getSteps();
return 0;
var steps = 0
try {
health = require("health");
} catch(ex) {
return steps;
}
health.readDay(new Date(), h=>steps+=h.steps);
return steps;
}
function stepsWidget() {