Cleanup, fix for starting time before track, and some debug
parent
a2a16443d6
commit
525980d7f7
|
|
@ -44,18 +44,10 @@ var exs = ExStats.getStats(statIDs, settings);
|
||||||
// Called to start/stop running
|
// Called to start/stop running
|
||||||
function onStartStop() {
|
function onStartStop() {
|
||||||
var running = !exs.state.active;
|
var running = !exs.state.active;
|
||||||
if (running) {
|
|
||||||
exs.start();
|
|
||||||
} else {
|
|
||||||
exs.stop();
|
|
||||||
}
|
|
||||||
layout.button.label = running ? "STOP" : "START";
|
|
||||||
layout.status.label = running ? "RUN" : "STOP";
|
|
||||||
layout.status.bgCol = running ? "#0f0" : "#f00";
|
|
||||||
// if stopping running, don't clear state
|
|
||||||
// so we can at least refer to what we've done
|
|
||||||
layout.render();
|
|
||||||
// start/stop recording
|
// start/stop recording
|
||||||
|
// Do this first in case recorder needs to prompt for
|
||||||
|
// an overwrite before we begin things like the total time
|
||||||
if (settings.record && WIDGETS["recorder"]) {
|
if (settings.record && WIDGETS["recorder"]) {
|
||||||
if (running) {
|
if (running) {
|
||||||
isMenuDisplayed = true;
|
isMenuDisplayed = true;
|
||||||
|
|
@ -68,6 +60,18 @@ function onStartStop() {
|
||||||
WIDGETS["recorder"].setRecording(false);
|
WIDGETS["recorder"].setRecording(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (running) {
|
||||||
|
exs.start();
|
||||||
|
} else {
|
||||||
|
exs.stop();
|
||||||
|
}
|
||||||
|
layout.button.label = running ? "STOP" : "START";
|
||||||
|
layout.status.label = running ? "RUN" : "STOP";
|
||||||
|
layout.status.bgCol = running ? "#0f0" : "#f00";
|
||||||
|
// if stopping running, don't clear state
|
||||||
|
// so we can at least refer to what we've done
|
||||||
|
layout.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
var lc = [];
|
var lc = [];
|
||||||
|
|
@ -100,28 +104,23 @@ layout.render();
|
||||||
|
|
||||||
function configureNotification(stat) {
|
function configureNotification(stat) {
|
||||||
stat.on('notify', (e)=>{
|
stat.on('notify', (e)=>{
|
||||||
|
console.log(`Got notify from ${e}`);
|
||||||
settings.notify[e.id].notifications.reduce(function (promise, buzzPattern) {
|
settings.notify[e.id].notifications.reduce(function (promise, buzzPattern) {
|
||||||
console.log(buzzPattern);
|
console.log(buzzPattern);
|
||||||
return promise.then(function () {
|
return promise.then(function () {
|
||||||
return Bangle.buzz(buzzPattern[0], buzzPattern[1]);
|
console.log('Should buzz now');
|
||||||
|
return Bangle.buzz(buzzPattern[0], buzzPattern[1]);
|
||||||
});
|
});
|
||||||
}, Promise.resolve())
|
}, Promise.resolve())
|
||||||
.then(console.log);
|
.then(console.log);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should really loop over Object.keys(settings.notify)
|
Object.keys(settings.notify).forEach((statType) => {
|
||||||
if (settings.notify.dist.increment > 0) {
|
if (settings.notify[statType].increment > 0) {
|
||||||
configureNotification(exs.stats.dist);
|
configureNotification(exs.stats[statType]);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (settings.notify.step.increment > 0) {
|
|
||||||
configureNotification(exs.stats.step);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (settings.notify.time.increment > 0) {
|
|
||||||
configureNotification(exs.stats.time);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle GPS state change for icon
|
// Handle GPS state change for icon
|
||||||
Bangle.on("GPS", function(fix) {
|
Bangle.on("GPS", function(fix) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue