Added myprofile

pull/3120/head
Erik Andresen 2023-12-10 09:39:13 +01:00
parent b723512dce
commit 7fc2ce0375
4 changed files with 81 additions and 0 deletions

11
apps/myprofile/README.md Normal file
View File

@ -0,0 +1,11 @@
# My Profile
Configure your personal profile. All settings are optional and are only stored on the watch.
## Available settings
| Setting | Description | Displayed in | Stored in | Default value | How to measure |
| ------------- | ----------------------------- | ------------------- | --------- | ------------- | ----------------------------------------------------------------- |
| 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 |
| Stride length | distance travel with one step | local length unit | meter | 0 (=not set) | Walk 10 steps and divide the travelled distance by 10 |

BIN
apps/myprofile/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,18 @@
{ "id": "myprofile",
"name": "My Profile",
"shortName":"My Profile",
"icon": "app.png",
"type": "settings",
"version":"0.01",
"description": "Configure your personal profile. All settings are optional and only stored on the watch.",
"readme": "README.md",
"tags": "tool,utility",
"supports": ["BANGLEJS", "BANGLEJS2"],
"storage": [
{"name":"myprofile.settings.js","url":"settings.js"}
],
"data": [
{"name":"myprofile.json"}
]
}

View File

@ -0,0 +1,52 @@
(function(back) {
const FILE = "myprofile.json";
const myprofile = Object.assign({
minHrm: 60,
maxHrm: 200,
strideLength: 0, // 0 = not set
}, require('Storage').readJSON(FILE, true) || {});
function writeProfile() {
require('Storage').writeJSON(FILE, myprofile);
}
// Show the menu
E.showMenu({
"" : { "title" : /*LANG*/"My Profile" },
"< Back" : () => back(),
/*LANG*/'HR max': {
format: v => /*LANG*/`${v} BPM`,
value: myprofile.maxHrm,
min: 30, max: 220,
onchange: v => {
myprofile.maxHrm = v;
writeProfile();
}
},
/*LANG*/'HR min': {
format: v => /*LANG*/`${v} BPM`,
value: myprofile.minHrm,
min: 30, max: 220,
onchange: v => {
myprofile.minHrm = v;
writeProfile();
}
},
/*LANG*/"Stride length": {
value: myprofile.strideLength,
min:0.00,
step:0.01,
format: v => v ? require("locale").distance(v, 2) : '-',
onchange: v => {
console.log(v);
myprofile.strideLength=v;
writeProfile();
},
},
});
})