From 8a4a2cee5a1ab2b7b195783b9bab15368490211c Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 9 Oct 2023 12:50:06 +0100 Subject: [PATCH] recorder/openstmap 0.31: Ensure that background-drawn tracks can get cancelled, and draw less at a time to make updates smoother plotTrack now draws the current track even if you're not actively recording --- apps/openstmap/ChangeLog | 3 ++- apps/openstmap/app.js | 4 ++++ apps/openstmap/metadata.json | 2 +- apps/recorder/ChangeLog | 2 ++ apps/recorder/metadata.json | 2 +- apps/recorder/widget.js | 6 +++--- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/openstmap/ChangeLog b/apps/openstmap/ChangeLog index 32951bda7..10b29fd3b 100644 --- a/apps/openstmap/ChangeLog +++ b/apps/openstmap/ChangeLog @@ -29,4 +29,5 @@ 0.22: Replace position marker with direction arrow 0.23: Bugfix: Enable Compass if needed 0.24: Allow zooming by clicking the screen -0.25: Enable scaled image filtering on 2v19+ firmware \ No newline at end of file +0.25: Enable scaled image filtering on 2v19+ firmware +0.26: Ensure that when redrawing, we always cancel any in-progress track draw \ No newline at end of file diff --git a/apps/openstmap/app.js b/apps/openstmap/app.js index 9b53077ab..1f4b0b8b7 100644 --- a/apps/openstmap/app.js +++ b/apps/openstmap/app.js @@ -30,6 +30,10 @@ if (settings.dirSrc === undefined) { // Redraw the whole page function redraw() { + // ensure we do cancel track drawing + if (plotTrack && plotTrack.stop) + plotTrack.stop(); + // set clip rect so we don't overwrite widgets g.setClipRect(R.x,R.y,R.x2,R.y2); const count = m.draw(); if (checkMapPos && count === 0) { diff --git a/apps/openstmap/metadata.json b/apps/openstmap/metadata.json index 05dcf2709..29278cbc3 100644 --- a/apps/openstmap/metadata.json +++ b/apps/openstmap/metadata.json @@ -2,7 +2,7 @@ "id": "openstmap", "name": "OpenStreetMap", "shortName": "OpenStMap", - "version": "0.25", + "version": "0.26", "description": "Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are. Once installed this also adds map functionality to `GPS Recorder` and `Recorder` apps", "readme": "README.md", "icon": "app.png", diff --git a/apps/recorder/ChangeLog b/apps/recorder/ChangeLog index 5f4d1f8b4..9e78bc7a2 100644 --- a/apps/recorder/ChangeLog +++ b/apps/recorder/ChangeLog @@ -36,3 +36,5 @@ 0.28: Automatically create new track if the filename is different 0.29: When plotting with OpenStMap scale map to track width & height 0.30: Add clock info for showing and toggling recording state +0.31: Ensure that background-drawn tracks can get cancelled, and draw less at a time to make updates smoother + plotTrack now draws the current track even if you're not actively recording \ No newline at end of file diff --git a/apps/recorder/metadata.json b/apps/recorder/metadata.json index 15ba165d1..b47fb9ded 100644 --- a/apps/recorder/metadata.json +++ b/apps/recorder/metadata.json @@ -2,7 +2,7 @@ "id": "recorder", "name": "Recorder", "shortName": "Recorder", - "version": "0.30", + "version": "0.31", "description": "Record GPS position, heart rate and more in the background, then download to your PC.", "icon": "app.png", "tags": "tool,outdoors,gps,widget,clkinfo", diff --git a/apps/recorder/widget.js b/apps/recorder/widget.js index e34fecfbc..2525a96e4 100644 --- a/apps/recorder/widget.js +++ b/apps/recorder/widget.js @@ -288,8 +288,8 @@ } */ options = options||{}; - if (!activeRecorders.length) return; // not recording var settings = loadSettings(); + if (!settings.file) return; // no file specified // keep function to draw track in RAM function plot(g) { "ram"; var f = require("Storage").open(settings.file,"r"); @@ -311,7 +311,7 @@ mp = m.latLonToXY(+c[la], +c[lo]); g.moveTo(mp.x,mp.y).setColor(color); l = f.readLine(f); - var n = options.async ? 20 : 200; // only plot first 200 points to keep things fast(ish) + var n = options.async ? 10 : 200; // only plot first 200 points to keep things fast(ish) while(l && n--) { c = l.split(","); if (c[la]) { @@ -333,7 +333,7 @@ } }; } - plot(g); + return plot(g); }}; // load settings, set correct widget width reload();