diff --git a/apps/clicompleteclk/app.js b/apps/clicompleteclk/app.js index 89dbce919..77dc22db6 100644 --- a/apps/clicompleteclk/app.js +++ b/apps/clicompleteclk/app.js @@ -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++; } @@ -128,6 +128,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 @@ -166,21 +190,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();