forked from espruino/BangleApps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}, | ||
}); | ||
}) |