1
0
Fork 0

added hrm sport mode setting

master
Erik Andresen 2023-12-30 09:26:54 +01:00
parent 75970a1aee
commit 127d331ed1
4 changed files with 77 additions and 0 deletions

BIN
apps/sportmode/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

7
apps/sportmode/boot.js Normal file
View File

@ -0,0 +1,7 @@
{
const settings = Object.assign({
mode: -1,
}, require('Storage').readJSON("sportmode.json", true) || {});
Bangle.setOptions({hrmSportMode: settings.mode});
}

View File

@ -0,0 +1,16 @@
{
"id": "sportmode",
"name": "HRM Sport mode",
"shortName":"Sport mode",
"icon": "app.png",
"version":"0.01",
"description": "Allows to set the sport mode of the Heart rate monitor in app settings.",
"type": "bootloader",
"tags": "health",
"supports": ["BANGLEJS2"],
"storage": [
{"name":"sportmode.boot.js","url":"boot.js"},
{"name":"sportmode.settings.js","url":"settings.js"}
],
"data": [{"name":"sportmode.json"}]
}

View File

@ -0,0 +1,54 @@
(function(back) {
const FILE = "sportmode.json";
const settings = Object.assign({
mode: -1,
}, require('Storage').readJSON(FILE, true) || {});
function writeSettings() {
require('Storage').writeJSON(FILE, settings);
}
// see Espruino/libs/misc/vc31_binary/algo.h
const SPORT_MODES = [
/*LANG*/"Normal",
/*LANG*/"Running",
/*LANG*/"Ride bike",
/*LANG*/"Jump rope",
/*LANG*/"Swimming",
/*LANG*/"Badminton",
/*LANG*/"Table tennis",
/*LANG*/"Tennis",
/*LANG*/"Climbing",
/*LANG*/"Walking",
/*LANG*/"Basketball",
/*LANG*/"Football",
/*LANG*/"Baseball",
/*LANG*/"Volleyball",
/*LANG*/"Cricket",
/*LANG*/"Rugby",
/*LANG*/"Hockey",
/*LANG*/"Dance",
/*LANG*/"Spinning",
/*LANG*/"Yoga",
/*LANG*/"Sit up",
/*LANG*/"Treadmill",
/*LANG*/"Gymnastics",
/*LANG*/"Boating",
/*LANG*/"Jumping jack",
/*LANG*/"Free training",
];
E.showMenu({
"" : { "title" : /*LANG*/"HRM sport mode" },
"< Back" : () => back(),
/*LANG*/'Sport mode': {
value: settings.mode,
min: -1, max: 25,
format: v => v === -1 ? /*LANG*/"Auto" : SPORT_MODES[v],
onchange: v => {
settings.mode = v;
writeSettings();
}
},
});
})