forked from FOSS/BangleApps
run 0.04: Use the exstats module, and make what is displayed configurable
parent
30d038324a
commit
d2ec2ce3e6
|
@ -2,3 +2,4 @@
|
||||||
0.02: Set pace format to mm:ss, time format to h:mm:ss,
|
0.02: Set pace format to mm:ss, time format to h:mm:ss,
|
||||||
added settings to opt out of GPS and HRM
|
added settings to opt out of GPS and HRM
|
||||||
0.03: Fixed distance calculation, tested against Garmin Etrex, Amazfit GTS 2
|
0.03: Fixed distance calculation, tested against Garmin Etrex, Amazfit GTS 2
|
||||||
|
0.04: Use the exstats module, and make what is displayed configurable
|
||||||
|
|
|
@ -32,7 +32,7 @@ that, and then start the `Run` app.
|
||||||
|
|
||||||
Under `Settings` -> `App` -> `Run` you can change settings for this app.
|
Under `Settings` -> `App` -> `Run` you can change settings for this app.
|
||||||
|
|
||||||
* `Pace` is the distance that pace should be shown over - 1km, 1 mile, 1/2 Marathon or 1 Maraton
|
* `Pace` is the distance that pace should be shown over - 1km, 1 mile, 1/2 Marathon or 1 Marathon
|
||||||
* `Box 1/2/3/4/5/6` are what should be shown in each of the 6 boxes on the display. From the top left, down.
|
* `Box 1/2/3/4/5/6` are what should be shown in each of the 6 boxes on the display. From the top left, down.
|
||||||
If you set it to `-` nothing will be displayed, so you can display only 4 boxes of information
|
If you set it to `-` nothing will be displayed, so you can display only 4 boxes of information
|
||||||
if you wish by setting the last 2 boxes to `-`.
|
if you wish by setting the last 2 boxes to `-`.
|
||||||
|
@ -41,3 +41,11 @@ Under `Settings` -> `App` -> `Run` you can change settings for this app.
|
||||||
|
|
||||||
* Allow this app to trigger the `Recorder` app on and off directly.
|
* Allow this app to trigger the `Recorder` app on and off directly.
|
||||||
* Keep a log of each run's stats (distance/steps/etc)
|
* Keep a log of each run's stats (distance/steps/etc)
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
This app uses the [`exstats` module](/modules/exstats.js). When uploaded via the
|
||||||
|
app loader, the module is automatically included in the app's source. However
|
||||||
|
when developing via the IDE the module won't get pulled in by default.
|
||||||
|
|
||||||
|
There are some options to fix this easily - please check out the [modules README.md file](/modules/README.md)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ "id": "run",
|
{ "id": "run",
|
||||||
"name": "Run",
|
"name": "Run",
|
||||||
"version":"0.03",
|
"version":"0.04",
|
||||||
"description": "Displays distance, time, steps, cadence, pace and more for runners.",
|
"description": "Displays distance, time, steps, cadence, pace and more for runners.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "run,running,fitness,outdoors,gps",
|
"tags": "run,running,fitness,outdoors,gps",
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
B6 : "caden",
|
B6 : "caden",
|
||||||
paceLength : 1000
|
paceLength : 1000
|
||||||
}, storage.readJSON(SETTINGS_FILE, 1) || {});
|
}, storage.readJSON(SETTINGS_FILE, 1) || {});
|
||||||
function save() {
|
function saveSettings() {
|
||||||
storage.write(SETTINGS_FILE, settings)
|
storage.write(SETTINGS_FILE, settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,31 +28,23 @@
|
||||||
format: v => statsList[v].name,
|
format: v => statsList[v].name,
|
||||||
onchange: v => {
|
onchange: v => {
|
||||||
settings[boxID] = statsIDs[v];
|
settings[boxID] = statsIDs[v];
|
||||||
save();
|
saveSettings();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var paceNames = ["1000m","1 mile","1/2 Mthn", "Marathon",];
|
var menu = {
|
||||||
var paceAmts = [1000,1609,21098,42195];
|
|
||||||
E.showMenu({
|
|
||||||
'': { 'title': 'Run' },
|
'': { 'title': 'Run' },
|
||||||
'< Back': back,
|
'< Back': back
|
||||||
'Pace': {
|
};
|
||||||
min :0, max: paceNames.length-1,
|
ExStats.appendMenuItems(menu, settings, saveSettings);
|
||||||
value: Math.max(paceAmts.indexOf(settings.paceLength),0),
|
Object.assign(menu,{
|
||||||
format: v => paceNames[v],
|
|
||||||
onchange: v => {
|
|
||||||
settings.paceLength = paceAmts[v];
|
|
||||||
print(settings);
|
|
||||||
save();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'Box 1': getBoxChooser("B1"),
|
'Box 1': getBoxChooser("B1"),
|
||||||
'Box 2': getBoxChooser("B2"),
|
'Box 2': getBoxChooser("B2"),
|
||||||
'Box 3': getBoxChooser("B3"),
|
'Box 3': getBoxChooser("B3"),
|
||||||
'Box 4': getBoxChooser("B4"),
|
'Box 4': getBoxChooser("B4"),
|
||||||
'Box 5': getBoxChooser("B5"),
|
'Box 5': getBoxChooser("B5"),
|
||||||
'Box 6': getBoxChooser("B6"),
|
'Box 6': getBoxChooser("B6"),
|
||||||
})
|
});
|
||||||
|
E.showMenu(menu);
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
/* Copyright (c) 2022 Bangle.js contibutors. See the file LICENSE for copying permission. */
|
||||||
/* Exercise Stats module
|
/* Exercise Stats module
|
||||||
|
|
||||||
|
Take a look at README.md for hints on developing with this library.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -39,6 +42,12 @@ var exs = ExStats.getStats(["dist", "time", "pacea","bpm","step","caden"], optio
|
||||||
stop : function, // call to stop exercise
|
stop : function, // call to stop exercise
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Or you can display a menu where the settings can be configured - these are passed as the 'options' argument of getStats
|
||||||
|
|
||||||
|
var menu = { ... };
|
||||||
|
ExStats.appendMenuItems(menu, settings, saveSettingsFunction);
|
||||||
|
E.showMenu(menu);
|
||||||
|
|
||||||
*/
|
*/
|
||||||
var state = {
|
var state = {
|
||||||
active : false, // are we working or not?
|
active : false, // are we working or not?
|
||||||
|
@ -237,3 +246,17 @@ exports.getStats = function(statIDs, options) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.appendMenuItems = function(menu, settings, saveSettings) {
|
||||||
|
var paceNames = ["1000m","1 mile","1/2 Mthn", "Marathon",];
|
||||||
|
var paceAmts = [1000,1609,21098,42195];
|
||||||
|
menu['Pace'] = {
|
||||||
|
min :0, max: paceNames.length-1,
|
||||||
|
value: Math.max(paceAmts.indexOf(settings.paceLength),0),
|
||||||
|
format: v => paceNames[v],
|
||||||
|
onchange: v => {
|
||||||
|
settings.paceLength = paceAmts[v];
|
||||||
|
saveSettings();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue