widhrzone: Read maximum HRM from myprofile

drop own settings
pull/3131/head
Erik Andresen 2023-12-15 20:12:53 +01:00
parent aea3033f52
commit 6d56a8512b
4 changed files with 11 additions and 38 deletions

2
apps/widhrzone/ChangeLog Normal file
View File

@ -0,0 +1,2 @@
0.01: New App!
0.02: Read maximum HRM from myprofile

View File

@ -2,7 +2,7 @@
"id": "widhrzone", "id": "widhrzone",
"name": "Heart rate zone widget", "name": "Heart rate zone widget",
"shortName": "HRzone widget", "shortName": "HRzone widget",
"version": "0.01", "version": "0.02",
"description": "Widget that displays the current out of five heart rate training zones 1. HEALTH (50-60% of max. HR, Recovery, grey), 2. FAT-B (60-70% of max. HR, burns fat, blue), 3. AROBIC (70-80% of max. HR, Endurance, green), 4. ANAROB (80-90% of max. HR, Speed, yellow), 5. MAX (90-100% of max. HR, red). Only visible when heart rate monitor is active and inside one of the zones. Requires to set the maximum heart rate in settings (if unsure set to 220-age).", "description": "Widget that displays the current out of five heart rate training zones 1. HEALTH (50-60% of max. HR, Recovery, grey), 2. FAT-B (60-70% of max. HR, burns fat, blue), 3. AROBIC (70-80% of max. HR, Endurance, green), 4. ANAROB (80-90% of max. HR, Speed, yellow), 5. MAX (90-100% of max. HR, red). Only visible when heart rate monitor is active and inside one of the zones. Requires to set the maximum heart rate in settings (if unsure set to 220-age).",
"icon": "widget.png", "icon": "widget.png",
"type": "widget", "type": "widget",
@ -10,8 +10,7 @@
"supports": ["BANGLEJS","BANGLEJS2"], "supports": ["BANGLEJS","BANGLEJS2"],
"screenshots" : [ { "url":"screenshot.png" } ], "screenshots" : [ { "url":"screenshot.png" } ],
"storage": [ "storage": [
{"name":"widhrzone.wid.js","url":"widget.js"}, {"name":"widhrzone.wid.js","url":"widget.js"}
{"name":"widhrzone.settings.js","url":"settings.js"}
], ],
"data": [{"name":"widhrzone.json"}] "dependencies": {"myprofile":"app"}
} }

View File

@ -1,26 +0,0 @@
(function(back) {
const CONFIGFILE = "widhrzone.json";
// Load settings
const settings = Object.assign({
maxHrm: 200,
}, require("Storage").readJSON(CONFIGFILE,1) || {});
function writeSettings() {
require('Storage').writeJSON(CONFIGFILE, settings);
}
// Show the menu
E.showMenu({
"" : { "title" : "HRzone widget" },
"< Back" : () => back(),
/*LANG*/'HR max': {
format: v => v,
value: settings.maxHrm,
min: 30, max: 220,
onchange: v => {
settings.maxHrm = v;
writeSettings();
}
},
});
});

View File

@ -1,20 +1,18 @@
(() => { (() => {
const config = Object.assign({ const myprofile = require("Storage").readJSON("myprofile.json",1)||{};
maxHrm: 200,
}, require("Storage").readJSON("widhrzone.json",1) || {});
require("FontTeletext5x9Ascii").add(Graphics); require("FontTeletext5x9Ascii").add(Graphics);
const calczone = (bpm) => { const calczone = (bpm) => {
if (bpm <= config.maxHrm*0.5) { if (bpm <= myprofile.maxHrm*0.5) {
return 0; return 0;
} else if (bpm <= config.maxHrm*0.60) { } else if (bpm <= myprofile.maxHrm*0.60) {
return 1; return 1;
} else if (bpm <= config.maxHrm*0.70) { } else if (bpm <= myprofile.maxHrm*0.70) {
return 2; return 2;
} else if (bpm <= config.maxHrm*0.80) { } else if (bpm <= myprofile.maxHrm*0.80) {
return 3; return 3;
} else if (bpm <= config.maxHrm*0.90) { } else if (bpm <= myprofile.maxHrm*0.90) {
return 4; return 4;
} else { // > 0.9 } else { // > 0.9
return 5; return 5;