diff --git a/apps/pace/app.js b/apps/pace/app.js index 49322e2e4..3a4eac043 100644 --- a/apps/pace/app.js +++ b/apps/pace/app.js @@ -12,13 +12,12 @@ var _a; var S_1 = require("Storage"); var drawTimeout_1; var menuShown_1 = false; - var latestGps_1; var splits_1 = ((_a = S_1.readJSON("pace.json", 1)) === null || _a === void 0 ? void 0 : _a.splits) || []; var splitOffset_1 = 0, splitOffsetPx_1 = 0; var GPS_TIMEOUT_MS_1 = 30000; var drawGpsLvl = function (l) { var _a; - var gps = latestGps_1; + var gps = l.gps; var nsats = (_a = gps === null || gps === void 0 ? void 0 : gps.satellites) !== null && _a !== void 0 ? _a : 0; if (!gps || !gps.fix) g.setColor("#FF0000"); @@ -42,7 +41,6 @@ var _a; filly: 1, width: 10, bgCol: g.theme.bg, - redraw: -1, }, { type: "v", @@ -240,11 +238,9 @@ var _a; Bangle.drawWidgets(); Bangle.setGPSPower(1, "pace"); Bangle.on("GPS", function (gps) { - var newSats = gps === null || gps === void 0 ? void 0 : gps.satellites; var l = layout_1["gpslvl"]; - if (l && newSats !== (latestGps_1 === null || latestGps_1 === void 0 ? void 0 : latestGps_1.satellites)) - l.redraw = newSats; - latestGps_1 = gps; + if (l) + l.gps = gps; }); g.clearRect(Bangle.appRect); draw_1(); diff --git a/apps/pace/app.ts b/apps/pace/app.ts index 0931c3812..71225aa78 100644 --- a/apps/pace/app.ts +++ b/apps/pace/app.ts @@ -15,7 +15,6 @@ const S = require("Storage"); let drawTimeout: TimeoutId | undefined; let menuShown = false; -let latestGps: GPSFix | undefined; type Dist = number & { brand: 'dist' }; type Time = number & { brand: 'time' }; @@ -25,6 +24,8 @@ type Split = { time: Time, }; +type LayoutWithGPS = Layout.RenderedHierarchy & { gps?: GPSFix }; + type PaceState = { splits: Split[] }; const splits: PaceState["splits"] = @@ -35,7 +36,7 @@ let splitOffset = 0, splitOffsetPx = 0; const GPS_TIMEOUT_MS = 30000; const drawGpsLvl = (l: Layout.RenderedHierarchy) => { - const gps = latestGps; + const gps = (l as LayoutWithGPS).gps; const nsats = gps?.satellites ?? 0; if (!gps || !gps.fix) @@ -67,7 +68,6 @@ const layout = new Layout({ filly: 1, width: 10, bgCol: g.theme.bg, // automatically clears before render() - redraw: -1, // see below gps updating } as unknown as { // hack to avoid a more complex id-mapping Layout inference type: "custom", @@ -309,11 +309,8 @@ Bangle.loadWidgets(); Bangle.drawWidgets(); Bangle.setGPSPower(1, "pace"); Bangle.on("GPS", gps => { - const newSats = gps?.satellites; - const l = layout["gpslvl"] as unknown as Layout.RenderedHierarchy | undefined; - if(l && newSats !== latestGps?.satellites) - (l as any).redraw = newSats; // force a redraw - latestGps = gps; + const l = layout["gpslvl"] as unknown as LayoutWithGPS | undefined; + if(l) l.gps = gps; // force a redraw }); g.clearRect(Bangle.appRect);