From 711acc68017a26ec2068a065035b0919b633faad Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 3 Dec 2024 12:18:10 +0000 Subject: [PATCH 1/4] pace: avoid initial GPS skew --- apps/pace/app.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/pace/app.ts b/apps/pace/app.ts index de1930a49f..25e78760f9 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 From 1c4eaed61cd71980541f58fd74e195c3004fa005 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 3 Dec 2024 12:18:21 +0000 Subject: [PATCH 2/4] pace: allow reset of time and splits --- apps/pace/app.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/apps/pace/app.ts b/apps/pace/app.ts index 25e78760f9..6d4fd5112c 100644 --- a/apps/pace/app.ts +++ b/apps/pace/app.ts @@ -226,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(); From c2f9f3e9b10290203b0b308caac71ede9a748318 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 3 Dec 2024 12:15:32 +0000 Subject: [PATCH 3/4] pace: generate JS --- apps/pace/app.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) 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); From 040ddb7746517399229b88e7e81661a8c00b5731 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 3 Dec 2024 12:12:19 +0000 Subject: [PATCH 4/4] pace: bump version --- apps/pace/ChangeLog | 1 + apps/pace/metadata.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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/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",