From 6252dc89828d2fec9f73e4733270dd1ee57b75d1 Mon Sep 17 00:00:00 2001 From: David Peer Date: Sun, 19 Dec 2021 22:42:47 +0100 Subject: [PATCH] Use health app also for steps overview. --- apps/lcars/README.md | 7 ++----- apps/lcars/lcars.app.js | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/lcars/README.md b/apps/lcars/README.md index 7c56f5481..b7a692c96 100644 --- a/apps/lcars/README.md +++ b/apps/lcars/README.md @@ -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 diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 53849e840..8d86c09d1 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -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() {