Merge pull request #3141 from nxdefiant/master

added hrm sport mode setting
pull/3150/head
Rob Pilling 2024-01-05 19:41:14 +00:00 committed by GitHub
commit d646e04b42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 81 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,58 @@
(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", remove: () => {
// nothing to do
}
},
"< Back" : () => back(),
/*LANG*/'Sport mode': {
value: settings.mode,
min: -1, max: SPORT_MODES.length-1,
format: v => v === -1 ? /*LANG*/"Auto" : SPORT_MODES[v],
onchange: v => {
settings.mode = v;
writeSettings();
Bangle.setOptions({hrmSportMode: settings.mode});
}
},
});
})