Cleanup
parent
35d1cf85e8
commit
b923423238
|
|
@ -24,8 +24,9 @@ let settings = Object.assign({
|
||||||
B5: "step",
|
B5: "step",
|
||||||
B6: "caden",
|
B6: "caden",
|
||||||
paceLength: 1000,
|
paceLength: 1000,
|
||||||
notifyDistance: false,
|
notifyDist: 0,
|
||||||
notifyTime: false,
|
notifyTime: 0,
|
||||||
|
notifySteps: 0,
|
||||||
}, require("Storage").readJSON("run.json", 1) || {});
|
}, require("Storage").readJSON("run.json", 1) || {});
|
||||||
var statIDs = [settings.B1,settings.B2,settings.B3,settings.B4,settings.B5,settings.B6].filter(s=>s!=="");
|
var statIDs = [settings.B1,settings.B2,settings.B3,settings.B4,settings.B5,settings.B6].filter(s=>s!=="");
|
||||||
var exs = ExStats.getStats(statIDs, settings);
|
var exs = ExStats.getStats(statIDs, settings);
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,9 @@
|
||||||
B5: "step",
|
B5: "step",
|
||||||
B6: "caden",
|
B6: "caden",
|
||||||
paceLength: 1000, // TODO: Default to either 1km or 1mi based on locale
|
paceLength: 1000, // TODO: Default to either 1km or 1mi based on locale
|
||||||
notifyDistance: false,
|
notifyDist: 0,
|
||||||
notifyTime: false,
|
notifyTime: 0,
|
||||||
|
notifySteps: 0,
|
||||||
}, storage.readJSON(SETTINGS_FILE, 1) || {});
|
}, storage.readJSON(SETTINGS_FILE, 1) || {});
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
storage.write(SETTINGS_FILE, settings)
|
storage.write(SETTINGS_FILE, settings)
|
||||||
|
|
@ -49,7 +50,6 @@
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ExStats.appendMenuItems(menu, settings, saveSettings);
|
ExStats.appendMenuItems(menu, settings, saveSettings);
|
||||||
Object.assign(menu,{
|
Object.assign(menu,{
|
||||||
'Box 1': getBoxChooser("B1"),
|
'Box 1': getBoxChooser("B1"),
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,8 @@ var state = {
|
||||||
// BPM // beats per minute
|
// BPM // beats per minute
|
||||||
// BPMage // how many seconds was BPM set?
|
// BPMage // how many seconds was BPM set?
|
||||||
// Notifies: 0 for disabled, otherwise how often to notify in meters and seconds
|
// Notifies: 0 for disabled, otherwise how often to notify in meters and seconds
|
||||||
notifyDistance: 0, notifyTime: 0, notifySteps: 0,
|
notifyDist: 0, notifyTime: 0, notifySteps: 0,
|
||||||
nextNotifyDistance: 0, nextNotifyTime: 0, nextNotifySteps: 0,
|
nextNotifyDist: 0, nextNotifyTime: 0, nextNotifySteps: 0,
|
||||||
};
|
};
|
||||||
// list of active stats (indexed by ID)
|
// list of active stats (indexed by ID)
|
||||||
var stats = {};
|
var stats = {};
|
||||||
|
|
@ -118,9 +118,9 @@ Bangle.on("GPS", function(fix) {
|
||||||
if (stats["pacea"]) stats["pacea"].emit("changed",stats["pacea"]);
|
if (stats["pacea"]) stats["pacea"].emit("changed",stats["pacea"]);
|
||||||
if (stats["pacec"]) stats["pacec"].emit("changed",stats["pacec"]);
|
if (stats["pacec"]) stats["pacec"].emit("changed",stats["pacec"]);
|
||||||
if (stats["speed"]) stats["speed"].emit("changed",stats["speed"]);
|
if (stats["speed"]) stats["speed"].emit("changed",stats["speed"]);
|
||||||
if (state.notifyDistance > 0 && state.nextNotifyDist < stats["dist"]) {
|
if (state.notifyDist > 0 && state.nextNotifyDist < stats["dist"]) {
|
||||||
stats["dist"].emit("notify",stats["dist"]);
|
stats["dist"].emit("notify",stats["dist"]);
|
||||||
state.nextNotifyDist = stats["dist"] + state.notifyDistance;
|
state.nextNotifyDist = stats["dist"] + state.notifyDist;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -158,7 +158,7 @@ exports.getList = function() {
|
||||||
/** Instantiate the given list of statistic IDs (see comments at top)
|
/** Instantiate the given list of statistic IDs (see comments at top)
|
||||||
options = {
|
options = {
|
||||||
paceLength : meters to measure pace over
|
paceLength : meters to measure pace over
|
||||||
notifyDistance : meters to notify have elapsed (repeats)
|
notifyDist : meters to notify have elapsed (repeats)
|
||||||
notifyTime : ms to notify have elapsed (repeats)
|
notifyTime : ms to notify have elapsed (repeats)
|
||||||
notifySteps : number of steps to notify have elapsed (repeats)
|
notifySteps : number of steps to notify have elapsed (repeats)
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +166,7 @@ exports.getList = function() {
|
||||||
exports.getStats = function(statIDs, options) {
|
exports.getStats = function(statIDs, options) {
|
||||||
options = options||{};
|
options = options||{};
|
||||||
options.paceLength = options.paceLength||1000;
|
options.paceLength = options.paceLength||1000;
|
||||||
options.notifyDistance = options.notifyDistance||0;
|
options.notifyDist = options.notifyDist||0;
|
||||||
options.notifyTime = options.notifyTime||0;
|
options.notifyTime = options.notifyTime||0;
|
||||||
options.notifySteps = options.notifySteps||0;
|
options.notifySteps = options.notifySteps||0;
|
||||||
var needGPS,needHRM;
|
var needGPS,needHRM;
|
||||||
|
|
@ -255,7 +255,7 @@ exports.getStats = function(statIDs, options) {
|
||||||
}
|
}
|
||||||
if (state.notifyTime > 0 && state.nextNotifyTime < stats["time"]) {
|
if (state.notifyTime > 0 && state.nextNotifyTime < stats["time"]) {
|
||||||
stats["time"].emit("notify",stats["time"]);
|
stats["time"].emit("notify",stats["time"]);
|
||||||
state.nextNotifyTime = stats["time"] + state.notifyDistance;
|
state.nextNotifyTime = stats["time"] + state.notifyTime;
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
function reset() {
|
function reset() {
|
||||||
|
|
@ -270,13 +270,13 @@ exports.getStats = function(statIDs, options) {
|
||||||
state.BPM = 0;
|
state.BPM = 0;
|
||||||
state.BPMage = 0;
|
state.BPMage = 0;
|
||||||
state.notifyTime = options.notifyTime;
|
state.notifyTime = options.notifyTime;
|
||||||
state.notifyDistance = options.notifyDistance;
|
state.notifyDist = options.notifyDist;
|
||||||
state.notifySteps = options.notifySteps;
|
state.notifySteps = options.notifySteps;
|
||||||
if (options.notifyTime) {
|
if (options.notifyTime) {
|
||||||
state.nextNotifyTime = state.startTime + options.notifyTime;
|
state.nextNotifyTime = state.startTime + options.notifyTime;
|
||||||
}
|
}
|
||||||
if (options.notifyDistance) {
|
if (options.notifyDist) {
|
||||||
state.nextNotifyDist = state.distance + options.notifyDistance;
|
state.nextNotifyDist = state.distance + options.notifyDist;
|
||||||
}
|
}
|
||||||
if (options.notifySteps) {
|
if (options.notifySteps) {
|
||||||
state.nextNotifySteps = state.lastSteps + options.notifySteps;
|
state.nextNotifySteps = state.lastSteps + options.notifySteps;
|
||||||
|
|
@ -311,10 +311,10 @@ exports.appendMenuItems = function(menu, settings, saveSettings) {
|
||||||
var distAmts = [0, ...paceAmts];
|
var distAmts = [0, ...paceAmts];
|
||||||
menu['Ntfy Dist'] = {
|
menu['Ntfy Dist'] = {
|
||||||
min :0, max: distNames.length-1,
|
min :0, max: distNames.length-1,
|
||||||
value: Math.max(distAmts.indexOf(settings.notifyDistance),0),
|
value: Math.max(distAmts.indexOf(settings.notifyDist),0),
|
||||||
format: v => distNames[v],
|
format: v => distNames[v],
|
||||||
onchange: v => {
|
onchange: v => {
|
||||||
settings.notifyDistance = distAmts[v];
|
settings.notifyDist = distAmts[v];
|
||||||
saveSettings();
|
saveSettings();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue