From 9271c2e6ca1d78d71afd4ac409e73e516969eb30 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 11 Feb 2024 09:32:08 +0100 Subject: [PATCH 1/3] myprofile: Add weight --- apps/myprofile/ChangeLog | 2 ++ apps/myprofile/README.md | 1 + apps/myprofile/metadata.json | 2 +- apps/myprofile/settings.js | 12 ++++++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 apps/myprofile/ChangeLog diff --git a/apps/myprofile/ChangeLog b/apps/myprofile/ChangeLog new file mode 100644 index 000000000..7dd2fcc06 --- /dev/null +++ b/apps/myprofile/ChangeLog @@ -0,0 +1,2 @@ +0.01: New App! +0.02: Add weight diff --git a/apps/myprofile/README.md b/apps/myprofile/README.md index b8bb0daf0..5ff89dc25 100644 --- a/apps/myprofile/README.md +++ b/apps/myprofile/README.md @@ -10,6 +10,7 @@ Configure your personal profile. All settings are optional and are only stored o | HR max | maximum heart rate | BPM | BPM | 60 | Use maximum value when exercising.
If unsure set to 220-age. | | HR min | minimum heart rate | BPM | BPM | 200 | Measure your heart rate after waking up | | Height | Body height | local length unit | meter | 0 (=not set) | - | +| Weight | Body weight | kg | kf | 0 (=not set) | - | | Stride length | distance traveled with one step | local length unit | meter | 0 (=not set) | Walk 10 steps and divide the travelled distance by 10 | ## Developer notes diff --git a/apps/myprofile/metadata.json b/apps/myprofile/metadata.json index 79add3b5a..ca027e7ff 100644 --- a/apps/myprofile/metadata.json +++ b/apps/myprofile/metadata.json @@ -3,7 +3,7 @@ "shortName":"My Profile", "icon": "app.png", "type": "settings", - "version":"0.01", + "version":"0.02", "description": "Configure your personal profile. All settings are optional and only stored on the watch.", "readme": "README.md", "tags": "tool,utility", diff --git a/apps/myprofile/settings.js b/apps/myprofile/settings.js index 20907d383..c804b8a1e 100644 --- a/apps/myprofile/settings.js +++ b/apps/myprofile/settings.js @@ -7,6 +7,7 @@ strideLength: 0, // 0 = not set birthday: '1970-01-01', height: 0, // 0 = not set + weight: 0, // 0 = not set }, require('Storage').readJSON(FILE, true) || {}); function writeProfile() { @@ -101,6 +102,17 @@ } }, + /*LANG*/"Weight": { + value: myprofile.weight, + min:0, + step:1, + format: v => v ? v + "kg" : '-', + onchange: v => { + myprofile.weight=v; + writeProfile(); + }, + }, + /*LANG*/'HR max': { format: v => /*LANG*/`${v} BPM`, value: myprofile.maxHrm, From 2c6bc3eb4066674788dee73bd898f5b8d818e4f5 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 11 Feb 2024 09:32:52 +0100 Subject: [PATCH 2/3] medicalinfo: Read height + weight from myprofile --- apps/medicalinfo/ChangeLog | 1 + apps/medicalinfo/README.md | 4 ++-- apps/medicalinfo/app.js | 13 ++++++++----- apps/medicalinfo/lib.js | 2 -- apps/medicalinfo/medicalinfo.json | 2 -- apps/medicalinfo/metadata.json | 5 +++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/medicalinfo/ChangeLog b/apps/medicalinfo/ChangeLog index e8739a121..0d4d73b6a 100644 --- a/apps/medicalinfo/ChangeLog +++ b/apps/medicalinfo/ChangeLog @@ -1 +1,2 @@ 0.01: Initial Medical Information application! +0.02. Read height and weight from myprofile diff --git a/apps/medicalinfo/README.md b/apps/medicalinfo/README.md index 6dd19d4c6..0383aaff4 100644 --- a/apps/medicalinfo/README.md +++ b/apps/medicalinfo/README.md @@ -10,12 +10,12 @@ The file has the following contents: ``` { "bloodType": "", - "height": "", - "weight": "", "medicalAlert": [ "" ] } ``` +Weight and height are read from myprofile. + ## Medical information editor Clicking on the download icon of `Medical Information` in the app loader invokes the editor. diff --git a/apps/medicalinfo/app.js b/apps/medicalinfo/app.js index 9c4941744..0e3dfc395 100644 --- a/apps/medicalinfo/app.js +++ b/apps/medicalinfo/app.js @@ -1,8 +1,7 @@ const medicalinfo = require('medicalinfo').load(); +const myprofile = require("Storage").readJSON("myprofile.json",1)||{}; // const medicalinfo = { // bloodType: "O+", -// height: "166cm", -// weight: "73kg" // }; function hasAlert(info) { @@ -12,7 +11,7 @@ function hasAlert(info) { // No space for widgets! // TODO: no padlock widget visible so prevent screen locking? -g.clear(); +g.reset().clear(); const bodyFont = g.getFonts().includes("12x20") ? "12x20" : "6x8:2"; g.setFont(bodyFont); @@ -33,10 +32,14 @@ if (hasAlert(medicalinfo)) { if (medicalinfo.bloodType) { lines = lines.concat(g.wrapString("Blood group: " + medicalinfo.bloodType, g.getWidth() - 10)); } -if (medicalinfo.height) { +if (myprofile.height) { // Prefer height from myprofile if set + lines = lines.concat(g.wrapString("Height: " + require("locale").distance(myprofile.height, 2), g.getWidth() - 10)); +} else if (medicalinfo.height) { // read height from own settings if previously stored here lines = lines.concat(g.wrapString("Height: " + medicalinfo.height, g.getWidth() - 10)); } -if (medicalinfo.weight) { +if (myprofile.weight) { // Prefer weight from myprofile if set + lines = lines.concat(g.wrapString("Weight: " + myprofile.weight + "kg", g.getWidth() - 10)); +} else if (medicalinfo.weight) { // read weight from own settings if previously stored here lines = lines.concat(g.wrapString("Weight: " + medicalinfo.weight, g.getWidth() - 10)); } diff --git a/apps/medicalinfo/lib.js b/apps/medicalinfo/lib.js index 683005359..6ecafd0fd 100644 --- a/apps/medicalinfo/lib.js +++ b/apps/medicalinfo/lib.js @@ -3,8 +3,6 @@ const storage = require('Storage'); exports.load = function () { const medicalinfo = storage.readJSON('medicalinfo.json') || { bloodType: "", - height: "", - weight: "", medicalAlert: [""] }; diff --git a/apps/medicalinfo/medicalinfo.json b/apps/medicalinfo/medicalinfo.json index 8b49725cb..868011657 100644 --- a/apps/medicalinfo/medicalinfo.json +++ b/apps/medicalinfo/medicalinfo.json @@ -1,6 +1,4 @@ { "bloodType": "", - "height": "", - "weight": "", "medicalAlert": [ "" ] } diff --git a/apps/medicalinfo/metadata.json b/apps/medicalinfo/metadata.json index f1a0c145f..485cc9984 100644 --- a/apps/medicalinfo/metadata.json +++ b/apps/medicalinfo/metadata.json @@ -1,6 +1,6 @@ { "id": "medicalinfo", "name": "Medical Information", - "version":"0.01", + "version":"0.02", "description": "Provides 'medicalinfo.json' used by various health apps, as well as a way to edit it from the App Loader", "icon": "app.png", "tags": "health,medical", @@ -16,5 +16,6 @@ ], "data": [ {"name":"medicalinfo.json","url":"medicalinfo.json"} - ] + ], + "dependencies": {"myprofile":"app"} } From 37232ba954b2ea18371c5ff830e28e4bbcb592f2 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sun, 11 Feb 2024 09:36:52 +0100 Subject: [PATCH 3/3] medicalinfo: Fix ChangeLog --- apps/medicalinfo/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/medicalinfo/ChangeLog b/apps/medicalinfo/ChangeLog index 0d4d73b6a..de548df92 100644 --- a/apps/medicalinfo/ChangeLog +++ b/apps/medicalinfo/ChangeLog @@ -1,2 +1,2 @@ 0.01: Initial Medical Information application! -0.02. Read height and weight from myprofile +0.02: Read height and weight from myprofile