pace: show elapsed time on pause-screen

pull/3652/head
Rob Pilling 2024-11-11 12:05:56 +00:00
parent d18c0d2fd3
commit cde56d5600
4 changed files with 19 additions and 10 deletions

View File

@ -1 +1,2 @@
0.01: New app! 0.01: New app!
0.02: Show elapsed time on pause screen

View File

@ -85,26 +85,30 @@
var h = g.getHeight(); var h = g.getHeight();
var max = splits_1.reduce(function (a, s) { return Math.max(a, s.time); }, 0); var max = splits_1.reduce(function (a, s) { return Math.max(a, s.time); }, 0);
g.setFont("6x8", 2).setFontAlign(-1, -1); g.setFont("6x8", 2).setFontAlign(-1, -1);
var y = Bangle.appRect.y + barSpacing / 2;
g
.setColor(g.theme.fg)
.drawString(formatDuration_1(exs_1.state.duration), 0, y);
var i = 0; var i = 0;
for (;; i++) { for (;; i++) {
var split = splits_1[i + splitOffset_1]; var split = splits_1[i + splitOffset_1];
if (split == null) if (split == null)
break; break;
var y_1 = Bangle.appRect.y + i * (barSize + barSpacing) + barSpacing / 2; var y_1 = Bangle.appRect.y + (i + 1) * (barSize + barSpacing) + barSpacing / 2;
if (y_1 > h) if (y_1 > h)
break; break;
var size = w * split.time / max; var size = w * split.time / max;
g.setColor("#00f").fillRect(0, y_1, size, y_1 + barSize); g.setColor("#00f").fillRect(0, y_1, size, y_1 + barSize);
var splitPace = calculatePace_1(split); var splitPace = calculatePace_1(split);
g.setColor(g.theme.fg);
drawSplit_1(i, y_1, splitPace); drawSplit_1(i, y_1, splitPace);
} }
var pace = exs_1.stats.pacec.getString(); var pace = exs_1.stats.pacec.getString();
var y = Bangle.appRect.y + i * (barSize + barSpacing) + barSpacing / 2; y = Bangle.appRect.y + (i + 1) * (barSize + barSpacing) + barSpacing / 2;
drawSplit_1(i, y, pace); drawSplit_1(i, y, pace);
}; };
var drawSplit_1 = function (i, y, pace) { var drawSplit_1 = function (i, y, pace) {
g return g
.setColor(g.theme.fg)
.drawString("".concat(i + 1 + splitOffset_1, " ").concat(typeof pace === "number" ? pace.toFixed(2) : pace), 0, y); .drawString("".concat(i + 1 + splitOffset_1, " ").concat(typeof pace === "number" ? pace.toFixed(2) : pace), 0, y);
}; };
var pauseRun_1 = function () { var pauseRun_1 = function () {

View File

@ -114,36 +114,40 @@ const drawSplits = () => {
g.setFont("6x8", 2).setFontAlign(-1, -1); g.setFont("6x8", 2).setFontAlign(-1, -1);
let y = Bangle.appRect.y + barSpacing / 2;
g
.setColor(g.theme.fg)
.drawString(formatDuration(exs.state.duration), 0, y);
let i = 0; let i = 0;
for(; ; i++) { for(; ; i++) {
const split = splits[i + splitOffset]; const split = splits[i + splitOffset];
if (split == null) break; if (split == null) break;
const y = Bangle.appRect.y + i * (barSize + barSpacing) + barSpacing / 2; const y = Bangle.appRect.y + (i + 1) * (barSize + barSpacing) + barSpacing / 2;
if (y > h) break; if (y > h) break;
const size = w * split.time / max; // Scale bar height based on pace const size = w * split.time / max; // Scale bar height based on pace
g.setColor("#00f").fillRect(0, y, size, y + barSize); g.setColor("#00f").fillRect(0, y, size, y + barSize);
const splitPace = calculatePace(split); // Pace per km const splitPace = calculatePace(split); // Pace per km
g.setColor(g.theme.fg)
drawSplit(i, y, splitPace); drawSplit(i, y, splitPace);
} }
const pace = exs.stats.pacec.getString(); const pace = exs.stats.pacec.getString();
const y = Bangle.appRect.y + i * (barSize + barSpacing) + barSpacing / 2; y = Bangle.appRect.y + (i + 1) * (barSize + barSpacing) + barSpacing / 2;
drawSplit(i, y, pace); drawSplit(i, y, pace);
}; };
const drawSplit = (i: number, y: number, pace: number | string) => { const drawSplit = (i: number, y: number, pace: number | string) =>
g g
.setColor(g.theme.fg)
.drawString( .drawString(
`${i + 1 + splitOffset} ${typeof pace === "number" ? pace.toFixed(2) : pace}`, `${i + 1 + splitOffset} ${typeof pace === "number" ? pace.toFixed(2) : pace}`,
0, 0,
y y
); );
};
const pauseRun = () => { const pauseRun = () => {
exs.stop(); exs.stop();

View File

@ -1,7 +1,7 @@
{ {
"id": "pace", "id": "pace",
"name": "Pace", "name": "Pace",
"version": "0.01", "version": "0.02",
"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",