mirror of https://github.com/espruino/BangleApps
pace: use duration instead of time stat
time is total (or elapsed) time, duration is active timepull/3565/head
parent
8d34e408e7
commit
25b16a1738
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
var Layout_1 = require("Layout");
|
var Layout_1 = require("Layout");
|
||||||
var exs_1 = require("exstats").getStats(["time", "dist", "pacec"], {
|
var time_utils_1 = require("time_utils");
|
||||||
|
var exs_1 = require("exstats").getStats(["dist", "pacec"], {
|
||||||
notify: {
|
notify: {
|
||||||
dist: {
|
dist: {
|
||||||
increment: 1000,
|
increment: 1000,
|
||||||
|
@ -69,7 +70,8 @@
|
||||||
else {
|
else {
|
||||||
pace = "No GPS";
|
pace = "No GPS";
|
||||||
}
|
}
|
||||||
layout_1["time"].label = exs_1.stats.time.getString();
|
var tm = time_utils_1.decodeTime(exs_1.state.duration);
|
||||||
|
layout_1["time"].label = tm.d ? time_utils_1.formatDuration(tm) : time_utils_1.formatTime(tm);
|
||||||
layout_1["pace"].label = pace;
|
layout_1["pace"].label = pace;
|
||||||
layout_1.render();
|
layout_1.render();
|
||||||
if (now - lastUnlazy_1 > 30000)
|
if (now - lastUnlazy_1 > 30000)
|
||||||
|
@ -99,7 +101,7 @@
|
||||||
g.setColor("#fff").drawString("".concat(i + 1 + splitOffset_1, " @ ").concat(splitPace.toFixed(2)), 0, y);
|
g.setColor("#fff").drawString("".concat(i + 1 + splitOffset_1, " @ ").concat(splitPace.toFixed(2)), 0, y);
|
||||||
}
|
}
|
||||||
var pace = exs_1.stats.pacec.getString();
|
var pace = exs_1.stats.pacec.getString();
|
||||||
var splitTime = exs_1.stats.time.getValue() - totalTime;
|
var splitTime = exs_1.state.duration - totalTime;
|
||||||
g.setColor("#fff").drawString("".concat(i + 1 + splitOffset_1, " @ ").concat(pace, " (").concat((splitTime / 1000).toFixed(2), ")"), 0, Bangle.appRect.y + i * (barSize + barSpacing) + barSpacing / 2);
|
g.setColor("#fff").drawString("".concat(i + 1 + splitOffset_1, " @ ").concat(pace, " (").concat((splitTime / 1000).toFixed(2), ")"), 0, Bangle.appRect.y + i * (barSize + barSpacing) + barSpacing / 2);
|
||||||
};
|
};
|
||||||
var pauseRun_1 = function () {
|
var pauseRun_1 = function () {
|
||||||
|
@ -125,7 +127,7 @@
|
||||||
var totalDist = dist.getValue();
|
var totalDist = dist.getValue();
|
||||||
var thisSplit = totalDist - prev;
|
var thisSplit = totalDist - prev;
|
||||||
var prevTime = splits_1.reduce(function (a, b) { return a + b; }, 0);
|
var prevTime = splits_1.reduce(function (a, b) { return a + b; }, 0);
|
||||||
var time = exs_1.stats.time.getValue() - prevTime;
|
var time = exs_1.state.duration - prevTime;
|
||||||
while (thisSplit > 0) {
|
while (thisSplit > 0) {
|
||||||
splits_1.push(time);
|
splits_1.push(time);
|
||||||
time = 0;
|
time = 0;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
const Layout = require("Layout");
|
const Layout = require("Layout");
|
||||||
|
const time_utils = require("time_utils");
|
||||||
const exs = require("exstats").getStats(
|
const exs = require("exstats").getStats(
|
||||||
["time", "dist", "pacec"],
|
["dist", "pacec"],
|
||||||
{
|
{
|
||||||
notify: {
|
notify: {
|
||||||
dist: {
|
dist: {
|
||||||
|
@ -81,7 +82,8 @@ const draw = () => {
|
||||||
pace = "No GPS";
|
pace = "No GPS";
|
||||||
}
|
}
|
||||||
|
|
||||||
layout["time"]!.label = exs.stats.time.getString();
|
const tm = time_utils.decodeTime(exs.state.duration);
|
||||||
|
layout["time"]!.label = tm.d ? time_utils.formatDuration(tm) : time_utils.formatTime(tm); // formatTime throws if tm.d > 0
|
||||||
layout["pace"]!.label = pace;
|
layout["pace"]!.label = pace;
|
||||||
layout.render();
|
layout.render();
|
||||||
|
|
||||||
|
@ -120,7 +122,7 @@ const drawSplits = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const pace = exs.stats.pacec.getString();
|
const pace = exs.stats.pacec.getString();
|
||||||
const splitTime = exs.stats.time.getValue() - totalTime;
|
const splitTime = exs.state.duration - totalTime;
|
||||||
|
|
||||||
g.setColor("#fff").drawString(
|
g.setColor("#fff").drawString(
|
||||||
`${i + 1 + splitOffset} @ ${pace} (${(splitTime / 1000).toFixed(2)})`,
|
`${i + 1 + splitOffset} @ ${pace} (${(splitTime / 1000).toFixed(2)})`,
|
||||||
|
@ -156,7 +158,7 @@ exs.stats.dist.on("notify", (dist) => {
|
||||||
const totalDist = dist.getValue();
|
const totalDist = dist.getValue();
|
||||||
let thisSplit = totalDist - prev;
|
let thisSplit = totalDist - prev;
|
||||||
const prevTime = splits.reduce((a, b) => a + b, 0);
|
const prevTime = splits.reduce((a, b) => a + b, 0);
|
||||||
let time = exs.stats.time.getValue() - prevTime;
|
let time = exs.state.duration - prevTime;
|
||||||
|
|
||||||
while(thisSplit > 0) {
|
while(thisSplit > 0) {
|
||||||
splits.push(time);
|
splits.push(time);
|
||||||
|
|
Loading…
Reference in New Issue