diff --git a/apps/pace/ChangeLog b/apps/pace/ChangeLog index 74f863e2cc..687ac8bc01 100644 --- a/apps/pace/ChangeLog +++ b/apps/pace/ChangeLog @@ -1,2 +1,3 @@ 0.01: New app! 0.02: Show elapsed time on pause screen +0.03: Avoid initial GPS skew and allow reset of time/splits diff --git a/apps/pace/app.js b/apps/pace/app.js index 9fc6dfc425..5954ca5412 100644 --- a/apps/pace/app.js +++ b/apps/pace/app.js @@ -140,10 +140,12 @@ var totalDist = dist.getValue(); var thisSplit = totalDist - prev.dist; var thisTime = exs_1.state.duration - prev.time; - while (thisSplit > 1000) { - splits_1.push({ dist: thisSplit, time: thisTime }); - thisTime = 0; - thisSplit -= 1000; + if (thisSplit > 1000) { + if (thisTime > 0) { + if (splits_1.length || thisTime > 1000 * 60) + splits_1.push({ dist: thisSplit, time: thisTime }); + } + thisSplit %= 1000; } exs_1.state.notify.dist.next -= thisSplit; S_1.writeJSON("pace.json", { splits: splits_1 }); @@ -172,6 +174,30 @@ Bangle.on('twist', function () { Bangle.setBacklight(1); }); + Bangle.on('tap', function (_e) { + if (exs_1.state.active) + return; + var menu = { + "": { + remove: function () { + draw_1(); + }, + }, + "< Back": function () { + Bangle.setUI(); + }, + "Zero time": function () { + exs_1.start(); + exs_1.stop(); + Bangle.setUI(); + }, + "Clear splits": function () { + splits_1.splice(0, splits_1.length); + Bangle.setUI(); + }, + }; + E.showMenu(menu); + }); Bangle.loadWidgets(); Bangle.drawWidgets(); g.clearRect(Bangle.appRect); diff --git a/apps/pace/app.ts b/apps/pace/app.ts index de1930a49f..6d4fd5112c 100644 --- a/apps/pace/app.ts +++ b/apps/pace/app.ts @@ -184,10 +184,15 @@ exs.stats.dist.on("notify", (dist) => { let thisSplit = totalDist - prev.dist; let thisTime = exs.state.duration - prev.time; - while(thisSplit > 1000) { - splits.push({ dist: thisSplit as Dist, time: thisTime as Time }); - thisTime = 0; // if we've jumped more than 1k, credit the time to the first split - thisSplit -= 1000; + if (thisSplit > 1000) { + if (thisTime > 0) { + // if we have splits, or time isn't ridiculous, store the split + // (otherwise we're initialising GPS and it's inaccurate) + if (splits.length || thisTime > 1000 * 60) + splits.push({ dist: thisSplit as Dist, time: thisTime as Time }); + } + + thisSplit %= 1000; } // subtract off the next split notify @@ -221,6 +226,32 @@ Bangle.on('twist', () => { Bangle.setBacklight(1); }); +Bangle.on('tap', _e => { + if(exs.state.active) return; + + const menu: Menu = { + "": { + remove: () => { + draw(); + }, + }, + "< Back": () => { + Bangle.setUI(); // calls `remove`, which handles redrawing + }, + "Zero time": () => { + exs.start(); // calls reset + exs.stop(); // re-pauses + Bangle.setUI(); + }, + "Clear splits": () => { + splits.splice(0, splits.length); + Bangle.setUI(); + }, + }; + + E.showMenu(menu); +}); + Bangle.loadWidgets(); Bangle.drawWidgets(); diff --git a/apps/pace/metadata.json b/apps/pace/metadata.json index bff3e2397d..6d098a66ef 100644 --- a/apps/pace/metadata.json +++ b/apps/pace/metadata.json @@ -1,7 +1,7 @@ { "id": "pace", "name": "Pace", - "version": "0.02", + "version": "0.03", "description": "Show pace and time running splits", "icon": "app.png", "tags": "run,running,fitness,outdoors",