mirror of https://github.com/espruino/BangleApps
Merge pull request #3192 from nxdefiant/medicalinfo
medicalinfo: Read height + weight from myprofilepull/3196/head
commit
70f91b5a6f
|
@ -1 +1,2 @@
|
||||||
0.01: Initial Medical Information application!
|
0.01: Initial Medical Information application!
|
||||||
|
0.02: Read height and weight from myprofile
|
||||||
|
|
|
@ -10,12 +10,12 @@ The file has the following contents:
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"bloodType": "",
|
"bloodType": "",
|
||||||
"height": "",
|
|
||||||
"weight": "",
|
|
||||||
"medicalAlert": [ "" ]
|
"medicalAlert": [ "" ]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Weight and height are read from myprofile.
|
||||||
|
|
||||||
## Medical information editor
|
## Medical information editor
|
||||||
|
|
||||||
Clicking on the download icon of `Medical Information` in the app loader invokes the editor.
|
Clicking on the download icon of `Medical Information` in the app loader invokes the editor.
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
const medicalinfo = require('medicalinfo').load();
|
const medicalinfo = require('medicalinfo').load();
|
||||||
|
const myprofile = require("Storage").readJSON("myprofile.json",1)||{};
|
||||||
// const medicalinfo = {
|
// const medicalinfo = {
|
||||||
// bloodType: "O+",
|
// bloodType: "O+",
|
||||||
// height: "166cm",
|
|
||||||
// weight: "73kg"
|
|
||||||
// };
|
// };
|
||||||
|
|
||||||
function hasAlert(info) {
|
function hasAlert(info) {
|
||||||
|
@ -12,7 +11,7 @@ function hasAlert(info) {
|
||||||
// No space for widgets!
|
// No space for widgets!
|
||||||
// TODO: no padlock widget visible so prevent screen locking?
|
// TODO: no padlock widget visible so prevent screen locking?
|
||||||
|
|
||||||
g.clear();
|
g.reset().clear();
|
||||||
const bodyFont = g.getFonts().includes("12x20") ? "12x20" : "6x8:2";
|
const bodyFont = g.getFonts().includes("12x20") ? "12x20" : "6x8:2";
|
||||||
g.setFont(bodyFont);
|
g.setFont(bodyFont);
|
||||||
|
|
||||||
|
@ -33,10 +32,14 @@ if (hasAlert(medicalinfo)) {
|
||||||
if (medicalinfo.bloodType) {
|
if (medicalinfo.bloodType) {
|
||||||
lines = lines.concat(g.wrapString("Blood group: " + medicalinfo.bloodType, g.getWidth() - 10));
|
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));
|
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));
|
lines = lines.concat(g.wrapString("Weight: " + medicalinfo.weight, g.getWidth() - 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@ const storage = require('Storage');
|
||||||
exports.load = function () {
|
exports.load = function () {
|
||||||
const medicalinfo = storage.readJSON('medicalinfo.json') || {
|
const medicalinfo = storage.readJSON('medicalinfo.json') || {
|
||||||
bloodType: "",
|
bloodType: "",
|
||||||
height: "",
|
|
||||||
weight: "",
|
|
||||||
medicalAlert: [""]
|
medicalAlert: [""]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
{
|
{
|
||||||
"bloodType": "",
|
"bloodType": "",
|
||||||
"height": "",
|
|
||||||
"weight": "",
|
|
||||||
"medicalAlert": [ "" ]
|
"medicalAlert": [ "" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ "id": "medicalinfo",
|
{ "id": "medicalinfo",
|
||||||
"name": "Medical Information",
|
"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",
|
"description": "Provides 'medicalinfo.json' used by various health apps, as well as a way to edit it from the App Loader",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "health,medical",
|
"tags": "health,medical",
|
||||||
|
@ -16,5 +16,6 @@
|
||||||
],
|
],
|
||||||
"data": [
|
"data": [
|
||||||
{"name":"medicalinfo.json","url":"medicalinfo.json"}
|
{"name":"medicalinfo.json","url":"medicalinfo.json"}
|
||||||
]
|
],
|
||||||
|
"dependencies": {"myprofile":"app"}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
0.01: New App!
|
||||||
|
0.02: Add weight
|
|
@ -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.<br/> If unsure set to 220-age. |
|
| HR max | maximum heart rate | BPM | BPM | 60 | Use maximum value when exercising.<br/> If unsure set to 220-age. |
|
||||||
| HR min | minimum heart rate | BPM | BPM | 200 | Measure your heart rate after waking up |
|
| 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) | - |
|
| 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 |
|
| 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
|
## Developer notes
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"shortName":"My Profile",
|
"shortName":"My Profile",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "settings",
|
"type": "settings",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"description": "Configure your personal profile. All settings are optional and only stored on the watch.",
|
"description": "Configure your personal profile. All settings are optional and only stored on the watch.",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"tags": "tool,utility",
|
"tags": "tool,utility",
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
strideLength: 0, // 0 = not set
|
strideLength: 0, // 0 = not set
|
||||||
birthday: '1970-01-01',
|
birthday: '1970-01-01',
|
||||||
height: 0, // 0 = not set
|
height: 0, // 0 = not set
|
||||||
|
weight: 0, // 0 = not set
|
||||||
}, require('Storage').readJSON(FILE, true) || {});
|
}, require('Storage').readJSON(FILE, true) || {});
|
||||||
|
|
||||||
function writeProfile() {
|
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': {
|
/*LANG*/'HR max': {
|
||||||
format: v => /*LANG*/`${v} BPM`,
|
format: v => /*LANG*/`${v} BPM`,
|
||||||
value: myprofile.maxHrm,
|
value: myprofile.maxHrm,
|
||||||
|
|
Loading…
Reference in New Issue