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); require("Storage").writeJSON("health.json", settings);
} }
function settingsMenu() { E.showMenu({
E.showMenu({ "": { title: /*LANG*/"Health Tracking" },
"": { title: /*LANG*/"Health Tracking" },
/*LANG*/"< Back": () => back(), /*LANG*/"< Back": () => back(),
/*LANG*/"HRM Interval": { /*LANG*/"HRM Interval": {
value: settings.hrm, value: settings.hrm,
min: 0, min: 0,
max: 3, max: 3,
format: v => [ format: v => [
/*LANG*/"Off", /*LANG*/"Off",
/*LANG*/"3 min", /*LANG*/"3 min",
/*LANG*/"10 min", /*LANG*/"10 min",
/*LANG*/"Always" /*LANG*/"Always"
][v], ][v],
onchange: v => { onchange: v => {
settings.hrm = 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" : () => {
setSettings(); setSettings();
settingsMenu(); }
}, },
"x 0.01" : { /*LANG*/"Daily Step Goal": {
value : settings.strideLength === undefined ? 0 : settings.strideLength, value: settings.stepGoal,
min:0, min: 0,
step:0.01, max: 20000,
format: v => require("locale").distance(v, 2), step: 250,
onchange : v => { onchange: v => {
settings.strideLength=v; settings.stepGoal = v;
menu["x 0.1"].value = v; setSettings();
}, }
}, },
"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);
}
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();
},
},
});
}) })