Skip to content

Commit

Permalink
added hrm sport mode setting
Browse files Browse the repository at this point in the history
  • Loading branch information
nxdefiant committed Dec 30, 2023
1 parent 75970a1 commit 127d331
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
Binary file added apps/sportmode/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions apps/sportmode/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
const settings = Object.assign({
mode: -1,
}, require('Storage').readJSON("sportmode.json", true) || {});

Bangle.setOptions({hrmSportMode: settings.mode});
}
16 changes: 16 additions & 0 deletions apps/sportmode/metadata.json
Original file line number Diff line number Diff line change
@@ -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"}]
}
54 changes: 54 additions & 0 deletions apps/sportmode/settings.js
Original file line number Diff line number Diff line change
@@ -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();
}
},
});
})

0 comments on commit 127d331

Please sign in to comment.