From d65726d9fcb051dbbc7f3cd79c85d327faf42ae1 Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Sat, 5 Mar 2022 02:40:40 -0600 Subject: [PATCH] Fix for step notification, debug for time notification, better buzzes --- apps/run/settings.js | 16 ++++++++++++---- modules/exstats.js | 6 ++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/run/settings.js b/apps/run/settings.js index a75cc33c1..6dcbb05c0 100644 --- a/apps/run/settings.js +++ b/apps/run/settings.js @@ -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(); } } diff --git a/modules/exstats.js b/modules/exstats.js index fd6ca9042..2a22f9974 100644 --- a/modules/exstats.js +++ b/modules/exstats.js @@ -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() {