Fix for step notification, debug for time notification, better buzzes

pull/1545/head
Salim Blume 2022-03-05 02:40:40 -06:00
parent afd4bc697d
commit d65726d9fc
2 changed files with 16 additions and 6 deletions

View File

@ -48,6 +48,14 @@
}
}
function sampleBuzz(buzzTimes) {
buzzTimes.reduce(function (promise, buzzTime) {
return promise.then(function () {
return Bangle.buzz(buzzTime);
});
}, Promise.resolve());
}
var menu = {
'': { 'title': 'Run' },
'< Back': back,
@ -63,14 +71,14 @@
};
ExStats.appendMenuItems(menu, settings, saveSettings);
var vibPatterns = [/*LANG*/"Off", ".", "-", "--", "-.-", "---"];
var vibTimes = [[], [100], [500],[500,500],[500,100,500],[500,500,500]];
var vibTimes = [[], [[100, 1]], [[500, 1]],[[500, 1], [50, 0], [500, 1]],[[500, 1],[50, 0], [100, 1], [50, 0], [500, 1]],[[500, 1],[50,0],[500, 1],[50,0],[500, 1]]];
menu[/*LANG*/"Dist Notifctn"] = {
value: Math.max(0,vibPatterns.indexOf(settings.notify.dist.notification)),
min: 0, max: vibPatterns.length,
format: v => vibPatterns[v]||"Off",
onchange: v => {
settings.notify.dist.notification = vibTimes[v];
vibTimes[v].forEach((b) => Bangle.buzz(b));
sampleBuzz(vibTimes[v]);
saveSettings();
}
}
@ -80,7 +88,7 @@
format: v => vibPatterns[v]||"Off",
onchange: v => {
settings.notify.steps.notification = vibTimes[v];
vibTimes[v].forEach((b) => Bangle.buzz(b));
sampleBuzz(vibTimes[v]);
saveSettings();
}
}
@ -90,7 +98,7 @@
format: v => vibPatterns[v]||"Off",
onchange: v => {
settings.notify.time.notification = vibTimes[v];
vibTimes[v].forEach((b) => Bangle.buzz(b));
sampleBuzz(vibTimes[v]);
saveSettings();
}
}

View File

@ -145,7 +145,7 @@ Bangle.on("step", function(steps) {
state.stepHistory[0] += steps-state.lastStepCount;
state.lastStepCount = steps;
if (state.notify.steps.increment > 0 && state.notify.steps.next < steps) {
stats["steps"].emit("notify",stats["steps"]);
stats["step"].emit("notify",stats["step"]);
state.notify.steps.next = steps + state.notify.steps.increment;
}
});
@ -277,9 +277,11 @@ exports.getStats = function(statIDs, options) {
state.BPM = 0;
if (stats["bpm"]) stats["bpm"].emit("changed",stats["bpm"]);
}
console.log(now);
console.log(state.notify.time.next);
if (state.notify.time.increment > 0 && state.notify.time.next < now) {
stats["time"].emit("notify",stats["time"]);
state.notify.time.next = stats["time"] + state.notify.time.increment;
state.notify.time.next = now + state.notify.time.increment;
}
}, 1000);
function reset() {