forked from FOSS/BangleApps
myprofile: Added height setting
parent
16cc803b86
commit
9f3d78cbeb
|
@ -9,6 +9,7 @@ Configure your personal profile. All settings are optional and are only stored o
|
|||
| Birthday | Used to calculate age | year, month, day | 'YYYY-MM-DD' | 01.01.1970 | - |
|
||||
| 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 |
|
||||
| Height | Body height | local length unit | meter | 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
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
maxHrm: 200,
|
||||
strideLength: 0, // 0 = not set
|
||||
birthday: '1970-01-01',
|
||||
height: 0, // 0 = not set
|
||||
}, require('Storage').readJSON(FILE, true) || {});
|
||||
|
||||
function writeProfile() {
|
||||
|
@ -20,20 +21,20 @@
|
|||
|
||||
"< Back" : () => {
|
||||
if (date != new Date(myprofile.birthday)) {
|
||||
// Birthday changed
|
||||
if (date > new Date()) {
|
||||
E.showPrompt(/*LANG*/"Birthday must not be in future!", {
|
||||
buttons : {"Ok":true},
|
||||
}).then(() => ageMenu());
|
||||
} else {
|
||||
// Birthday changed
|
||||
const age = (new Date()).getFullYear() - date.getFullYear();
|
||||
const newMaxHRM = 220-age;
|
||||
E.showPrompt(/*LANG*/`Set HR max to ${newMaxHRM} calculated from age?`).then(function(v) {
|
||||
myprofile.birthday = date.getFullYear() + "-" + (date.getMonth() + 1).toString().padStart(2, '0') + "-" + date.getDate().toString().padStart(2, '0');
|
||||
if (v) {
|
||||
myprofile.maxHrm = newMaxHRM;
|
||||
writeProfile();
|
||||
}
|
||||
writeProfile();
|
||||
mainMenu();
|
||||
});
|
||||
}
|
||||
|
@ -77,6 +78,29 @@
|
|||
|
||||
/*LANG*/"Birthday" : () => ageMenu(),
|
||||
|
||||
/*LANG*/'Height': {
|
||||
value: myprofile.height,
|
||||
min: 0, max: 300,
|
||||
step:0.01,
|
||||
format: v => v ? require("locale").distance(v, 2) : '-',
|
||||
onchange: v => {
|
||||
if (v !== myprofile.height) {
|
||||
// height changed
|
||||
myprofile.height = v;
|
||||
setTimeout(() => {
|
||||
const newStrideLength = myprofile.height * 0.414;
|
||||
E.showPrompt(/*LANG*/`Set Stride length to ${require("locale").distance(newStrideLength, 2)} calculated from height?`).then(function(v) {
|
||||
if (v) {
|
||||
myprofile.strideLength = newStrideLength;
|
||||
}
|
||||
writeProfile();
|
||||
mainMenu();
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/*LANG*/'HR max': {
|
||||
format: v => /*LANG*/`${v} BPM`,
|
||||
value: myprofile.maxHrm,
|
||||
|
|
Loading…
Reference in New Issue