Merge branch 'espruino:master' into master

master
Peer David 2022-04-20 17:10:05 +02:00 committed by GitHub
commit 66a8f4dcb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 65 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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,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 : (healthSettings.stepGoal ? healthSettings.stepGoal : 10000),
min : 0, max : 20000, step : 100,
onchange : v => { healthSettings.stepGoal=v;setSettings(healthSettings); }
}
});
}
@ -199,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");

View File

@ -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",

1
apps/widstep/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: New widget

9
apps/widstep/README.md Normal file
View File

@ -0,0 +1,9 @@
# Step counter widget
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.
![](widstep-light.png)
![](widstep-dark.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,17 @@
{
"id": "widstep",
"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":false,
"storage": [
{"name":"widstep.wid.js","url":"widstep.wid.js"}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,23 @@
let wsSettingsGoal = (require('Storage').readJSON("health.json", 1) || {}).stepGoal || 10000;
Bangle.on('step', function(s) { WIDGETS["widstep"].draw(); });
Bangle.on('lcdPower', function(on) {
if (on) WIDGETS["widstep"].draw();
});
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;
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/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);
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);
}
};