Merge pull request #3131 from nxdefiant/master

widhrzone: Read maximum HRM from myprofile
pull/3133/head
Rob Pilling 2023-12-16 11:34:41 +00:00 committed by GitHub
commit 76c6bd858f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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",
"name": "Heart rate zone 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).",
"icon": "widget.png",
"type": "widget",
@ -10,8 +10,7 @@
"supports": ["BANGLEJS","BANGLEJS2"],
"screenshots" : [ { "url":"screenshot.png" } ],
"storage": [
{"name":"widhrzone.wid.js","url":"widget.js"},
{"name":"widhrzone.settings.js","url":"settings.js"}
{"name":"widhrzone.wid.js","url":"widget.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({
maxHrm: 200,
}, require("Storage").readJSON("widhrzone.json",1) || {});
const myprofile = require("Storage").readJSON("myprofile.json",1)||{};
require("FontTeletext5x9Ascii").add(Graphics);
const calczone = (bpm) => {
if (bpm <= config.maxHrm*0.5) {
if (bpm <= myprofile.maxHrm*0.5) {
return 0;
} else if (bpm <= config.maxHrm*0.60) {
} else if (bpm <= myprofile.maxHrm*0.60) {
return 1;
} else if (bpm <= config.maxHrm*0.70) {
} else if (bpm <= myprofile.maxHrm*0.70) {
return 2;
} else if (bpm <= config.maxHrm*0.80) {
} else if (bpm <= myprofile.maxHrm*0.80) {
return 3;
} else if (bpm <= config.maxHrm*0.90) {
} else if (bpm <= myprofile.maxHrm*0.90) {
return 4;
} else { // > 0.9
return 5;