health: calculate distance from steps

Simplify stride length setting, remove locale
master
Erik Andresen 2023-12-04 19:02:45 +01:00
parent 8fe9bf1b64
commit e37b7c804a
1 changed files with 46 additions and 75 deletions

View File

@ -9,84 +9,55 @@
require("Storage").writeJSON("health.json", settings);
}
function settingsMenu() {
E.showMenu({
"": { title: /*LANG*/"Health Tracking" },
E.showMenu({
"": { title: /*LANG*/"Health Tracking" },
/*LANG*/"< Back": () => back(),
/*LANG*/"< Back": () => back(),
/*LANG*/"HRM Interval": {
value: settings.hrm,
min: 0,
max: 3,
format: v => [
/*LANG*/"Off",
/*LANG*/"3 min",
/*LANG*/"10 min",
/*LANG*/"Always"
][v],
onchange: v => {
settings.hrm = v;
setSettings();
}
},
/*LANG*/"Daily Step Goal": {
value: settings.stepGoal,
min: 0,
max: 20000,
step: 250,
onchange: v => {
settings.stepGoal = v;
setSettings();
}
},
/*LANG*/"Step Goal Notification": {
value: "stepGoalNotification" in settings ? settings.stepGoalNotification : false,
format: () => (settings.stepGoalNotification ? 'Yes' : 'No'),
onchange: () => {
settings.stepGoalNotification = !settings.stepGoalNotification;
setSettings();
}
},
/*LANG*/"Stride length": () => strideLengthMenu()
});
}
function strideLengthMenu() {
const menu = {
"" : { title : /*LANG*/"Stride length" },
"< Back" : () => {
/*LANG*/"HRM Interval": {
value: settings.hrm,
min: 0,
max: 3,
format: v => [
/*LANG*/"Off",
/*LANG*/"3 min",
/*LANG*/"10 min",
/*LANG*/"Always"
][v],
onchange: v => {
settings.hrm = v;
setSettings();
settingsMenu();
},
}
},
"x 0.01" : {
value : settings.strideLength === undefined ? 0 : settings.strideLength,
min:0,
step:0.01,
format: v => require("locale").distance(v, 2),
onchange : v => {
settings.strideLength=v;
menu["x 0.1"].value = v;
},
},
"x 0.1" : {
value : settings.strideLength === undefined ? 0 : settings.strideLength,
min:0,
step:0.1,
format: v => require("locale").distance(v, 2),
onchange : v => {
settings.strideLength=v;
menu["x 0.01"].value = v;
},
},
};
E.showMenu(menu);
}
/*LANG*/"Daily Step Goal": {
value: settings.stepGoal,
min: 0,
max: 20000,
step: 250,
onchange: v => {
settings.stepGoal = v;
setSettings();
}
},
settingsMenu();
/*LANG*/"Step Goal Notification": {
value: "stepGoalNotification" in settings ? settings.stepGoalNotification : false,
format: () => (settings.stepGoalNotification ? 'Yes' : 'No'),
onchange: () => {
settings.stepGoalNotification = !settings.stepGoalNotification;
setSettings();
}
},
/*LANG*/"Stride length": {
value : settings.strideLength || 0.0,
min:0.01,
step:0.01,
onchange : v => {
settings.strideLength=v;
setSettings();
},
},
});
})