From 392866d2de1e5777896b08be545797be79f94773 Mon Sep 17 00:00:00 2001 From: Stiralbios Date: Sat, 20 Aug 2022 16:11:10 +0200 Subject: [PATCH] [ActivityReminder] New app screen --- apps/activityreminder/ChangeLog | 2 +- apps/activityreminder/app.js | 54 +++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/apps/activityreminder/ChangeLog b/apps/activityreminder/ChangeLog index f03227f71..c913481ff 100644 --- a/apps/activityreminder/ChangeLog +++ b/apps/activityreminder/ChangeLog @@ -6,4 +6,4 @@ 0.06: Add a temperature threshold to detect (and not alert) if the BJS isn't worn. Better support for the peoples using the app at night 0.07: Fix bug on the cutting edge firmware 0.08: Use default Bangle formatter for booleans -0.09: Optimisations \ No newline at end of file +0.09: New app screen (instead of showing settings or the alert) and some optimisations \ No newline at end of file diff --git a/apps/activityreminder/app.js b/apps/activityreminder/app.js index 62065556e..97f03ce97 100644 --- a/apps/activityreminder/app.js +++ b/apps/activityreminder/app.js @@ -1,20 +1,54 @@ (function () { - // todo do something more interesting than just showing the settings - /* // load variable before defining functions cause it can trigger a ReferenceError const activityreminder = require("activityreminder"); - const storage = require("Storage"); - const activityreminder_settings = activityreminder.loadSettings(); let activityreminder_data = activityreminder.loadData(); - */ + let W = g.getWidth(); + // let H = g.getHeight(); - function run() { - eval(storage.read("activityreminder.settings.js"))(() => load()); + function getHoursMins(date){ + var h = date.getHours(); + var m = date.getMinutes(); + return (""+h).substr(-2) + ":" + ("0"+m).substr(-2); + } + + function drawData(name, value, y){ + g.drawString(name, 10, y); + g.drawString(value, 100, y); + } + + function drawInfo() { + var h=18, y = h; + g.setColor(g.theme.fg); + g.setFont("Vector",h).setFontAlign(-1,-1); + + // Header + g.drawLine(0,25,W,25); + g.drawLine(0,26,W,26); + + g.drawString("Current Cycle", 10, y+=h); + drawData("Start", getHoursMins(activityreminder_data.stepsDate), y+=h); + drawData("Steps", getCurrentSteps(), y+=h); + + /* + g.drawString("Button Press", 10, y+=h*2); + drawData("Ok", getHoursMins(activityreminder_data.okDate), y+=h); + drawData("Dismiss", getHoursMins(activityreminder_data.dismissDate), y+=h); + drawData("Pause", getHoursMins(activityreminder_data.pauseDate), y+=h); + */ + } + + function getCurrentSteps(){ + let health = Bangle.getHealthStatus("day"); + return health.steps - activityreminder_data.stepsOnDate; + } + + function run() { + g.clear(); + Bangle.loadWidgets(); + Bangle.drawWidgets(); + drawInfo(); } - g.clear(); - Bangle.loadWidgets(); - Bangle.drawWidgets(); run(); })(); \ No newline at end of file