From c4529d5c0a527c10b63c1403aefb6cacb29ad7a1 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 13:22:53 +0100 Subject: [PATCH 01/20] Step counter widget (#2) * Create README.md * Add files via upload * Update metadata.json --- apps/widstep/ChangeLog | 1 + apps/widstep/README.md | 4 +++ apps/widstep/icons8-winter-boots-48.png | Bin 0 -> 1359 bytes apps/widstep/metadata.json | 15 ++++++++++ apps/widstep/widstep-dark.png | Bin 0 -> 3910 bytes apps/widstep/widstep-light.png | Bin 0 -> 3834 bytes apps/widstep/widstep.wid.js | 36 ++++++++++++++++++++++++ 7 files changed, 56 insertions(+) create mode 100644 apps/widstep/ChangeLog create mode 100644 apps/widstep/README.md create mode 100644 apps/widstep/icons8-winter-boots-48.png create mode 100644 apps/widstep/metadata.json create mode 100644 apps/widstep/widstep-dark.png create mode 100644 apps/widstep/widstep-light.png create mode 100644 apps/widstep/widstep.wid.js diff --git a/apps/widstep/ChangeLog b/apps/widstep/ChangeLog new file mode 100644 index 000000000..55cda0f21 --- /dev/null +++ b/apps/widstep/ChangeLog @@ -0,0 +1 @@ +0.01: New widget diff --git a/apps/widstep/README.md b/apps/widstep/README.md new file mode 100644 index 000000000..3441755e3 --- /dev/null +++ b/apps/widstep/README.md @@ -0,0 +1,4 @@ +# Step counter widget +This is my step counter widget. There are many like it, but this one is mine. +Designed to be as narrow as possible, but still easy to read, by sacrificing accuracy and only showing to the nearest 100 steps (0.1k). +Shows a subtle fill colour in the background for progress to the goal. The goal is picked up from the health tracker settings. diff --git a/apps/widstep/icons8-winter-boots-48.png b/apps/widstep/icons8-winter-boots-48.png new file mode 100644 index 0000000000000000000000000000000000000000..7dceceef03b8ef0f6bcb33d7665a6ce948171d71 GIT binary patch literal 1359 zcmV-V1+e;wP)1ra;L`?Keltif}y2K#G7%=h0Ck1>WXi98Sc_PG6K*gBGr0Vv<%@RxN7I!Xj$}mxZ>XEt}fh7U}^2D5vkZr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eyTH3 zClX%0^~BIbS+kk<`hOkI&Jc-o-p`5weTb2Q-3a=gB(_)J>(&yag%1-;Gh3|bTHh0=2^$}M z>DHHTKM9EfP3kg7I=9Wt;73Ww?htH=_sPNdNG*L5nY9pU`-k2gX>v+{yU^JuW(!_u z)kY$jy4><~T~l6o1w)UL(z%fj4c}~NtX3P&z_iXE=py}|E2HR=-hP^Cx(=C(&b*e6 ztErpEi8=<|bJVYC#Fo6I_@su~UWc-Q^VxAVHg61!yE>@)-Ni_`@o!~^>t2J3=pkrg zB1pW=XnImjMaRtISzc&%*5IFJ&21$2t15X25atC9pALXC%6zIV4|T%bXdB-b^;H

Rv!x&QQG@HEMGwvCn_>@}?r)gpm_T$yVTlVa4bpW=i?ZwSr+AZ@FFmCJVcp>dk2f zpNCRfKB-+yGdG%)e@tVT_MZ_wMk-Fb?QgHPdDV^Gqg5M}0}K5Mh8f2)kja_={MFg^ z(qF`t{XVVq^k-*9?I!sEcMw;D{FTs)I!g3QF~1@@a6*J_;low7I6GH`} zQ@!9DVv;mAhoxQX0K2CLN1sD!ij zQ33{A`QZS7gOh*_QKG3lkW8h~nU09bUvD8mdW0h)XuB82i|s-^NcRwOsC$Lp0Tf|0 z1s8#E+NtFrz$*n9R2~Eh7%@yPUf_uMtczEUmzL28@N)<++7S`#R)`*>2paUl&67NrR`y!#7IU)}7cx*fx&FAw`{B0-}hla-Da5yx^8f|TjR7N1V zaZDa0Kr*@JOA`OlAX2#$4xP=TvzXwLCPZe%@*EKe(4P-0PvJcvt_z37c0{;AF Date: Tue, 19 Apr 2022 15:10:51 +0100 Subject: [PATCH 02/20] Update metadata.json --- apps/widstep/metadata.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/widstep/metadata.json b/apps/widstep/metadata.json index 09e0efac9..ea108e0f1 100644 --- a/apps/widstep/metadata.json +++ b/apps/widstep/metadata.json @@ -3,12 +3,14 @@ "name": "Step counter widget", "version": "0.01", "description": "Step counter widget, narrow but clearly readable", + "readme": "README.md", "icon": "icons8-winter-boots-48.png", + "screenshots": [{"url":"widstep-light.png"},{"url":"widstep-dark.png"}], "type": "widget", "tags": "widget,health", "supports": ["BANGLEJS","BANGLEJS2"], "dependencies" : {"health":"app"}, - "allow_emulator":true, + "allow_emulator":false, "storage": [ {"name":"widstep.wid.js","url":"widstep.wid.js"} ] From 207dfadc58deb18c16061bd14a41874b53e54107 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:14:38 +0100 Subject: [PATCH 03/20] Update README.md --- apps/widstep/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/widstep/README.md b/apps/widstep/README.md index 3441755e3..498f2ebd9 100644 --- a/apps/widstep/README.md +++ b/apps/widstep/README.md @@ -2,3 +2,7 @@ This is my step counter widget. There are many like it, but this one is mine. Designed to be as narrow as possible, but still easy to read, by sacrificing accuracy and only showing to the nearest 100 steps (0.1k). Shows a subtle fill colour in the background for progress to the goal. The goal is picked up from the health tracker settings. + + +![](widstep-light.png) +![](widstep-dark.png) From beb81356bc1598499fe6cc9ffc94ef321be4d9cb Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:24:32 +0100 Subject: [PATCH 04/20] Update app.js --- apps/health/app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/health/app.js b/apps/health/app.js index 64640603e..415edb7c5 100644 --- a/apps/health/app.js +++ b/apps/health/app.js @@ -31,6 +31,11 @@ function menuSettings() { min : 0, max : 3, format : v=>["Off","3 mins","10 mins","Always"][v], onchange : v => { s.hrm=v;setSettings(s); } + }, + "Daily Step Goal":{ + value : 0|s.stepGoal, + min : 0, max : 20000, step : 100, + onchange : v => { s.stepGoal=v;setSettings(s); } } }); } From 08045075cc7c61c04a2b799f16a4fa5e074cadd1 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:25:08 +0100 Subject: [PATCH 05/20] Update metadata.json --- apps/health/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/health/metadata.json b/apps/health/metadata.json index 8bb986c57..5d096dc07 100644 --- a/apps/health/metadata.json +++ b/apps/health/metadata.json @@ -1,7 +1,7 @@ { "id": "health", "name": "Health Tracking", - "version": "0.11", + "version": "0.12", "description": "Logs health data and provides an app to view it", "icon": "app.png", "tags": "tool,system,health", From f318fb005d1af5617849a434e8a7221cd4dab9ba Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:25:35 +0100 Subject: [PATCH 06/20] Update ChangeLog --- apps/health/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/health/ChangeLog b/apps/health/ChangeLog index 1e4864af8..7dbb9c458 100644 --- a/apps/health/ChangeLog +++ b/apps/health/ChangeLog @@ -10,3 +10,4 @@ 0.09: Fix file naming so months are 1-based (not 0) (fix #1119) 0.10: Adds additional 3 minute setting for HRM 0.11: Pre-minified boot&lib - folds constants and saves RAM +0.12: Add setting for Daily Step Goal From c74cd9bf367817905531b1a8059c6bcd7c6cfa6b Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:25:58 +0100 Subject: [PATCH 07/20] Update app.js --- apps/health/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/health/app.js b/apps/health/app.js index 415edb7c5..ae5a313f6 100644 --- a/apps/health/app.js +++ b/apps/health/app.js @@ -33,7 +33,7 @@ function menuSettings() { onchange : v => { s.hrm=v;setSettings(s); } }, "Daily Step Goal":{ - value : 0|s.stepGoal, + value : 10000|s.stepGoal, min : 0, max : 20000, step : 100, onchange : v => { s.stepGoal=v;setSettings(s); } } From e04f574f928569fc1bf60b6cf26bef6194aed26e Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:28:04 +0100 Subject: [PATCH 08/20] Update README.md --- apps/health/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/health/README.md b/apps/health/README.md index f44854e3e..c6b379c0a 100644 --- a/apps/health/README.md +++ b/apps/health/README.md @@ -24,6 +24,7 @@ Stores: * **Off** - Don't turn HRM on, but record heart rate if the HRM was turned on by another app/widget * **10 Min** - Turn HRM on every 10 minutes (for each heath entry) and turn it off after 2 minutes, or when a good reading is found * **Always** - Keep HRM on all the time (more accurate recording, but reduces battery life to ~36 hours) +* **Daily Step Goal** - Default 10000, daily step goal for pedometer apps to use ## Technical Info From 702cd09f793e600e62205564c085c2d20123f547 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 16:19:05 +0100 Subject: [PATCH 09/20] Update widstep.wid.js --- apps/widstep/widstep.wid.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/widstep/widstep.wid.js b/apps/widstep/widstep.wid.js index 84c7bf843..0499384d7 100644 --- a/apps/widstep/widstep.wid.js +++ b/apps/widstep/widstep.wid.js @@ -1,9 +1,9 @@ -let settings; +let wsSettings; function loadSettings() { - settings = require('Storage').readJSON("health.json", 1) || {}; - if( settings.stepGoal === undefined ) { - settings.stepGoal = 10000; + wsSettings = require('Storage').readJSON("health.json", 1) || {}; + if( wsSettings.stepGoal === undefined ) { + wsSettings.stepGoal = 10000; } } @@ -20,7 +20,7 @@ WIDGETS["widstep"]={area:"tl", sortorder:-1, width:28, g.setColor(g.theme.bg); g.fillRect(this.x, this.y, this.x + this.width, this.y + 23); g.setColor(g.theme.dark ? '#00f' : '#0ff'); - var progress = this.width * Math.min(steps/settings.stepGoal, 1); + var progress = this.width * Math.min(steps/wsSettings.stepGoal, 1); g.fillRect(this.x+1, this.y+1, this.x + progress -1, this.y + 23); g.setColor(g.theme.fg); g.setFontAlign(0, -1); From ea95dbfbf43366d83cd0336f460d896f6fad7c8d Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 16:20:01 +0100 Subject: [PATCH 10/20] Update widstep.wid.js --- apps/widstep/widstep.wid.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/widstep/widstep.wid.js b/apps/widstep/widstep.wid.js index 0499384d7..79e3fe766 100644 --- a/apps/widstep/widstep.wid.js +++ b/apps/widstep/widstep.wid.js @@ -14,8 +14,8 @@ Bangle.on('lcdPower', function(on) { WIDGETS["widstep"]={area:"tl", sortorder:-1, width:28, draw:function() { if (!Bangle.isLCDOn()) return; // dont redraw if LCD is off - //var steps = Bangle.getHealthStatus("day").steps; - var steps = 5285; + var steps = Bangle.getHealthStatus("day").steps; + //var steps = 5285; g.reset(); g.setColor(g.theme.bg); g.fillRect(this.x, this.y, this.x + this.width, this.y + 23); From 20f9f2ad86c27a88076b3c2215353fec7e1715f1 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 16:26:56 +0100 Subject: [PATCH 11/20] Update README.md --- apps/widstep/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/widstep/README.md b/apps/widstep/README.md index 498f2ebd9..c41b025cd 100644 --- a/apps/widstep/README.md +++ b/apps/widstep/README.md @@ -1,6 +1,7 @@ # Step counter widget -This is my step counter widget. There are many like it, but this one is mine. -Designed to be as narrow as possible, but still easy to read, by sacrificing accuracy and only showing to the nearest 100 steps (0.1k). +This is my step counter. There are many like it, but this one is mine. + +A pedometer widget designed to be as narrow as possible, but still easy to read, by sacrificing accuracy and only showing to the nearest 100 steps (0.1k). Shows a subtle fill colour in the background for progress to the goal. The goal is picked up from the health tracker settings. From aedb3a0b2600be62a2e254cbd24dd3d3aceec43a Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 16:36:17 +0100 Subject: [PATCH 12/20] Update app.js --- apps/health/app.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/health/app.js b/apps/health/app.js index ae5a313f6..7b52216b0 100644 --- a/apps/health/app.js +++ b/apps/health/app.js @@ -31,11 +31,6 @@ function menuSettings() { min : 0, max : 3, format : v=>["Off","3 mins","10 mins","Always"][v], onchange : v => { s.hrm=v;setSettings(s); } - }, - "Daily Step Goal":{ - value : 10000|s.stepGoal, - min : 0, max : 20000, step : 100, - onchange : v => { s.stepGoal=v;setSettings(s); } } }); } @@ -43,11 +38,17 @@ function menuSettings() { function menuStepCount() { swipe_enabled = false; clearButton(); + var s=getSettings(); E.showMenu({ "":{title:"Step Counting"}, "< Back":()=>menuMain(), "per hour":()=>stepsPerHour(), - "per day":()=>stepsPerDay() + "per day":()=>stepsPerDay(), + "Daily Step Goal":{ + value : 10000|s.stepGoal, + min : 0, max : 20000, step : 100, + onchange : v => { s.stepGoal=v;setSettings(s); } + } }); } From 4a960430487c1f710309b9b1b6d0fc2a2f4d4aef Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 17:04:56 +0100 Subject: [PATCH 13/20] Update app.js --- apps/health/app.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/health/app.js b/apps/health/app.js index 7b52216b0..75e46a1e8 100644 --- a/apps/health/app.js +++ b/apps/health/app.js @@ -2,8 +2,8 @@ function getSettings() { return require("Storage").readJSON("health.json",1)||{}; } -function setSettings(s) { - require("Storage").writeJSON("health.json",s); +function setSettings(healthSettings) { + require("Storage").writeJSON("health.json",healthSettings); } function menuMain() { @@ -22,15 +22,15 @@ function menuMain() { function menuSettings() { swipe_enabled = false; clearButton(); - var s=getSettings(); + var healthSettings=getSettings(); E.showMenu({ "":{title:"Health Tracking"}, "< Back":()=>menuMain(), "Heart Rt":{ - value : 0|s.hrm, + value : 0|healthSettings.hrm, min : 0, max : 3, format : v=>["Off","3 mins","10 mins","Always"][v], - onchange : v => { s.hrm=v;setSettings(s); } + onchange : v => { healthSettings.hrm=v;setSettings(healthSettings); } } }); } @@ -38,16 +38,16 @@ function menuSettings() { function menuStepCount() { swipe_enabled = false; clearButton(); - var s=getSettings(); + var healthSettings=getSettings(); E.showMenu({ "":{title:"Step Counting"}, "< Back":()=>menuMain(), "per hour":()=>stepsPerHour(), "per day":()=>stepsPerDay(), "Daily Step Goal":{ - value : 10000|s.stepGoal, + value : 10000|healthSettings.stepGoal, min : 0, max : 20000, step : 100, - onchange : v => { s.stepGoal=v;setSettings(s); } + onchange : v => { healthSettings.stepGoal=v;setSettings(healthSettings); } } }); } From f0ba8ac6eaf6988177d3b7d9025fb7d831712f82 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 19 Apr 2022 20:35:04 +0100 Subject: [PATCH 14/20] Update app.js --- apps/health/app.js | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/apps/health/app.js b/apps/health/app.js index 75e46a1e8..20c7f9fd7 100644 --- a/apps/health/app.js +++ b/apps/health/app.js @@ -2,8 +2,8 @@ function getSettings() { return require("Storage").readJSON("health.json",1)||{}; } -function setSettings(healthSettings) { - require("Storage").writeJSON("health.json",healthSettings); +function setSettings(s) { + require("Storage").writeJSON("health.json",s); } function menuMain() { @@ -15,39 +15,22 @@ function menuMain() { "Step Counting":()=>menuStepCount(), "Movement":()=>menuMovement(), "Heart Rate":()=>menuHRM(), - "Settings":()=>menuSettings() - }); -} - -function menuSettings() { - swipe_enabled = false; - clearButton(); - var healthSettings=getSettings(); - E.showMenu({ - "":{title:"Health Tracking"}, - "< Back":()=>menuMain(), - "Heart Rt":{ - value : 0|healthSettings.hrm, - min : 0, max : 3, - format : v=>["Off","3 mins","10 mins","Always"][v], - onchange : v => { healthSettings.hrm=v;setSettings(healthSettings); } - } }); } function menuStepCount() { swipe_enabled = false; clearButton(); - var healthSettings=getSettings(); + var s=getSettings(); E.showMenu({ "":{title:"Step Counting"}, "< Back":()=>menuMain(), "per hour":()=>stepsPerHour(), "per day":()=>stepsPerDay(), "Daily Step Goal":{ - value : 10000|healthSettings.stepGoal, + value : (s.stepGoal ? s.stepGoal : 10000), min : 0, max : 20000, step : 100, - onchange : v => { healthSettings.stepGoal=v;setSettings(healthSettings); } + onchange : v => { s.stepGoal=v;setSettings(s); } } }); } @@ -66,11 +49,18 @@ function menuMovement() { function menuHRM() { swipe_enabled = false; clearButton(); + var s=getSettings(); E.showMenu({ "":{title:"Heart Rate"}, "< Back":()=>menuMain(), "per hour":()=>hrmPerHour(), "per day":()=>hrmPerDay(), + "Log interval":{ + value : 0|s.hrm, + min : 0, max : 3, + format : v=>["Off","3 mins","10 mins","Always"][v], + onchange : v => { s.hrm=v;setSettings(s); } + } }); } From 51c285b39cf9adc6fb8010f94ee7438d816648d4 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Wed, 20 Apr 2022 12:38:09 +0100 Subject: [PATCH 15/20] Update widstep.wid.js --- apps/widstep/widstep.wid.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/widstep/widstep.wid.js b/apps/widstep/widstep.wid.js index 79e3fe766..39c825521 100644 --- a/apps/widstep/widstep.wid.js +++ b/apps/widstep/widstep.wid.js @@ -1,11 +1,4 @@ -let wsSettings; - -function loadSettings() { - wsSettings = require('Storage').readJSON("health.json", 1) || {}; - if( wsSettings.stepGoal === undefined ) { - wsSettings.stepGoal = 10000; - } -} +let wsSettingsGoal; Bangle.on('step', function(s) { WIDGETS["widstep"].draw(); }); Bangle.on('lcdPower', function(on) { @@ -15,12 +8,11 @@ WIDGETS["widstep"]={area:"tl", sortorder:-1, width:28, draw:function() { if (!Bangle.isLCDOn()) return; // dont redraw if LCD is off var steps = Bangle.getHealthStatus("day").steps; - //var steps = 5285; g.reset(); g.setColor(g.theme.bg); g.fillRect(this.x, this.y, this.x + this.width, this.y + 23); g.setColor(g.theme.dark ? '#00f' : '#0ff'); - var progress = this.width * Math.min(steps/wsSettings.stepGoal, 1); + var progress = this.width * Math.min(steps/wsSettingsGoal, 1); g.fillRect(this.x+1, this.y+1, this.x + progress -1, this.y + 23); g.setColor(g.theme.fg); g.setFontAlign(0, -1); @@ -29,7 +21,7 @@ WIDGETS["widstep"]={area:"tl", sortorder:-1, width:28, g.setFont('4x6').drawString('steps', this.x+this.width/2, this.y + 2); //g.drawRect(this.x, this.y, this.x + this.width, this.y + 23); }, reload:function() { - loadSettings(); + wsSettingsGoal = (require('Storage').readJSON("health.json", 1) || {}).stepGoal || 10000; WIDGETS["widstep"].draw(); } }; From 7621776a833a18057feb5ed53d702bc3ff9adb5a Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Wed, 20 Apr 2022 12:39:41 +0100 Subject: [PATCH 16/20] Update app.js --- apps/health/app.js | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/apps/health/app.js b/apps/health/app.js index 20c7f9fd7..efd18c4e1 100644 --- a/apps/health/app.js +++ b/apps/health/app.js @@ -15,23 +15,39 @@ function menuMain() { "Step Counting":()=>menuStepCount(), "Movement":()=>menuMovement(), "Heart Rate":()=>menuHRM(), + "Settings":()=>menuSettings() + }); +} + +function menuSettings() { + swipe_enabled = false; + clearButton(); + var s=getSettings(); + E.showMenu({ + "":{title:"Health Tracking"}, + "< Back":()=>menuMain(), + "Heart Rt":{ + value : 0|s.hrm, + min : 0, max : 3, + format : v=>["Off","3 mins","10 mins","Always"][v], + onchange : v => { s.hrm=v;setSettings(s); } + }, + "Daily Step Goal":{ + value : (s.stepGoal ? s.stepGoal : 10000), + min : 0, max : 20000, step : 100, + onchange : v => { s.stepGoal=v;setSettings(s); } + } }); } function menuStepCount() { swipe_enabled = false; clearButton(); - var s=getSettings(); E.showMenu({ "":{title:"Step Counting"}, "< Back":()=>menuMain(), "per hour":()=>stepsPerHour(), - "per day":()=>stepsPerDay(), - "Daily Step Goal":{ - value : (s.stepGoal ? s.stepGoal : 10000), - min : 0, max : 20000, step : 100, - onchange : v => { s.stepGoal=v;setSettings(s); } - } + "per day":()=>stepsPerDay() }); } @@ -49,18 +65,11 @@ function menuMovement() { function menuHRM() { swipe_enabled = false; clearButton(); - var s=getSettings(); E.showMenu({ "":{title:"Heart Rate"}, "< Back":()=>menuMain(), "per hour":()=>hrmPerHour(), "per day":()=>hrmPerDay(), - "Log interval":{ - value : 0|s.hrm, - min : 0, max : 3, - format : v=>["Off","3 mins","10 mins","Always"][v], - onchange : v => { s.hrm=v;setSettings(s); } - } }); } From 7bfe23d809627ca5d690419f133477977bcf4330 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Wed, 20 Apr 2022 12:48:28 +0100 Subject: [PATCH 17/20] Update widstep.wid.js --- apps/widstep/widstep.wid.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/widstep/widstep.wid.js b/apps/widstep/widstep.wid.js index 39c825521..1defcb146 100644 --- a/apps/widstep/widstep.wid.js +++ b/apps/widstep/widstep.wid.js @@ -1,4 +1,4 @@ -let wsSettingsGoal; +let wsSettingsGoal = 10000; Bangle.on('step', function(s) { WIDGETS["widstep"].draw(); }); Bangle.on('lcdPower', function(on) { @@ -25,4 +25,3 @@ WIDGETS["widstep"]={area:"tl", sortorder:-1, width:28, WIDGETS["widstep"].draw(); } }; -loadSettings(); From c377a4f194670f65e8e1b61c1616f6fa97b51973 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Wed, 20 Apr 2022 14:32:23 +0100 Subject: [PATCH 18/20] Update app.js --- apps/health/app.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/health/app.js b/apps/health/app.js index efd18c4e1..e39590e2d 100644 --- a/apps/health/app.js +++ b/apps/health/app.js @@ -2,8 +2,8 @@ function getSettings() { return require("Storage").readJSON("health.json",1)||{}; } -function setSettings(s) { - require("Storage").writeJSON("health.json",s); +function setSettings(healthSettings) { + require("Storage").writeJSON("health.json",healthSettings); } function menuMain() { @@ -22,20 +22,21 @@ function menuMain() { function menuSettings() { swipe_enabled = false; clearButton(); - var s=getSettings(); + var healthSettings=getSettings(); + //print(healthSettings); E.showMenu({ "":{title:"Health Tracking"}, "< Back":()=>menuMain(), "Heart Rt":{ - value : 0|s.hrm, + value : 0|healthSettings.hrm, min : 0, max : 3, format : v=>["Off","3 mins","10 mins","Always"][v], - onchange : v => { s.hrm=v;setSettings(s); } + onchange : v => { healthSettings.hrm=v;setSettings(healthSettings); } }, "Daily Step Goal":{ - value : (s.stepGoal ? s.stepGoal : 10000), + value : (healthSettings.stepGoal ? healthSettings.stepGoal : 10000), min : 0, max : 20000, step : 100, - onchange : v => { s.stepGoal=v;setSettings(s); } + onchange : v => { healthSettings.stepGoal=v;setSettings(healthSettings); } } }); } @@ -204,7 +205,7 @@ function drawBarChart() { for (bar = 1; bar < 10; bar++) { if (bar == 5) { g.setFont('6x8', 2); - g.setFontAlign(0,-1) + g.setFontAlign(0,-1); g.setColor(g.theme.fg); g.drawString(chart_label + " " + (chart_index + bar -1) + " " + chart_data[chart_index + bar - 1], g.getWidth()/2, 150); g.setColor("#00f"); From 09bd9bb252ace4c8aed40993d38ba06f2dbd33c2 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Wed, 20 Apr 2022 15:15:55 +0100 Subject: [PATCH 19/20] Update widstep.wid.js Looks like reload was never being called, so just read in the important setting at the top of the file. --- apps/widstep/widstep.wid.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/widstep/widstep.wid.js b/apps/widstep/widstep.wid.js index 1defcb146..74c5a59ea 100644 --- a/apps/widstep/widstep.wid.js +++ b/apps/widstep/widstep.wid.js @@ -1,4 +1,4 @@ -let wsSettingsGoal = 10000; +let wsSettingsGoal = (require('Storage').readJSON("health.json", 1) || {}).stepGoal || 10000; Bangle.on('step', function(s) { WIDGETS["widstep"].draw(); }); Bangle.on('lcdPower', function(on) { @@ -8,6 +8,7 @@ WIDGETS["widstep"]={area:"tl", sortorder:-1, width:28, draw:function() { if (!Bangle.isLCDOn()) return; // dont redraw if LCD is off var steps = Bangle.getHealthStatus("day").steps; + print('draw', wsSettingsGoal, steps); g.reset(); g.setColor(g.theme.bg); g.fillRect(this.x, this.y, this.x + this.width, this.y + 23); @@ -19,9 +20,5 @@ WIDGETS["widstep"]={area:"tl", sortorder:-1, width:28, var steps_k = (steps/1000).toFixed(1) + 'k'; g.setFont('6x15').drawString(steps_k, this.x+this.width/2, this.y + 10); g.setFont('4x6').drawString('steps', this.x+this.width/2, this.y + 2); - //g.drawRect(this.x, this.y, this.x + this.width, this.y + 23); - }, reload:function() { - wsSettingsGoal = (require('Storage').readJSON("health.json", 1) || {}).stepGoal || 10000; - WIDGETS["widstep"].draw(); } }; From f59f2872e6b2d7beb85b97d7f9f74f903109e898 Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Wed, 20 Apr 2022 15:16:19 +0100 Subject: [PATCH 20/20] Update widstep.wid.js Remove stray print statement! --- apps/widstep/widstep.wid.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/widstep/widstep.wid.js b/apps/widstep/widstep.wid.js index 74c5a59ea..6ad971af7 100644 --- a/apps/widstep/widstep.wid.js +++ b/apps/widstep/widstep.wid.js @@ -8,7 +8,6 @@ WIDGETS["widstep"]={area:"tl", sortorder:-1, width:28, draw:function() { if (!Bangle.isLCDOn()) return; // dont redraw if LCD is off var steps = Bangle.getHealthStatus("day").steps; - print('draw', wsSettingsGoal, steps); g.reset(); g.setColor(g.theme.bg); g.fillRect(this.x, this.y, this.x + this.width, this.y + 23);