Merge pull request #3683 from bobrippling/feat/pace-reset

pace: handle GPS skew, allow reset of time/splits
master
Rob Pilling 2025-04-16 08:15:57 +01:00 committed by GitHub
commit cc051726cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 67 additions and 9 deletions

View File

@ -1,2 +1,3 @@
0.01: New app! 0.01: New app!
0.02: Show elapsed time on pause screen 0.02: Show elapsed time on pause screen
0.03: Avoid initial GPS skew and allow reset of time/splits

View File

@ -140,10 +140,12 @@
var totalDist = dist.getValue(); var totalDist = dist.getValue();
var thisSplit = totalDist - prev.dist; var thisSplit = totalDist - prev.dist;
var thisTime = exs_1.state.duration - prev.time; var thisTime = exs_1.state.duration - prev.time;
while (thisSplit > 1000) { if (thisSplit > 1000) {
if (thisTime > 0) {
if (splits_1.length || thisTime > 1000 * 60)
splits_1.push({ dist: thisSplit, time: thisTime }); splits_1.push({ dist: thisSplit, time: thisTime });
thisTime = 0; }
thisSplit -= 1000; thisSplit %= 1000;
} }
exs_1.state.notify.dist.next -= thisSplit; exs_1.state.notify.dist.next -= thisSplit;
S_1.writeJSON("pace.json", { splits: splits_1 }); S_1.writeJSON("pace.json", { splits: splits_1 });
@ -172,6 +174,30 @@
Bangle.on('twist', function () { Bangle.on('twist', function () {
Bangle.setBacklight(1); 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.loadWidgets();
Bangle.drawWidgets(); Bangle.drawWidgets();
g.clearRect(Bangle.appRect); g.clearRect(Bangle.appRect);

View File

@ -184,10 +184,15 @@ exs.stats.dist.on("notify", (dist) => {
let thisSplit = totalDist - prev.dist; let thisSplit = totalDist - prev.dist;
let thisTime = exs.state.duration - prev.time; let thisTime = exs.state.duration - prev.time;
while(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 }); 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;
thisSplit %= 1000;
} }
// subtract <how much we're over> off the next split notify // subtract <how much we're over> off the next split notify
@ -221,6 +226,32 @@ Bangle.on('twist', () => {
Bangle.setBacklight(1); 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.loadWidgets();
Bangle.drawWidgets(); Bangle.drawWidgets();

View File

@ -1,7 +1,7 @@
{ {
"id": "pace", "id": "pace",
"name": "Pace", "name": "Pace",
"version": "0.02", "version": "0.03",
"description": "Show pace and time running splits", "description": "Show pace and time running splits",
"icon": "app.png", "icon": "app.png",
"tags": "run,running,fitness,outdoors", "tags": "run,running,fitness,outdoors",