From 947731a129fdb72281a69556df33c246b4d3280a Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 8 Dec 2020 15:56:53 +0000 Subject: [PATCH] openstmap: Show currently active gpsrec GPS trace (fix #395) --- apps.json | 4 ++-- apps/gpsrec/ChangeLog | 1 + apps/gpsrec/widget.js | 18 ++++++++++++++++++ apps/openstmap/ChangeLog | 1 + apps/openstmap/app.js | 4 ++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index 697c78dc9..2458646a4 100644 --- a/apps.json +++ b/apps.json @@ -363,7 +363,7 @@ { "id": "gpsrec", "name": "GPS Recorder", "icon": "app.png", - "version":"0.14", + "version":"0.15", "interface": "interface.html", "description": "Application that allows you to record a GPS track. Can run in background", "tags": "tool,outdoors,gps,widget", @@ -1326,7 +1326,7 @@ "name": "OpenStreetMap", "shortName":"OpenStMap", "icon": "app.png", - "version":"0.04", + "version":"0.05", "description": "[BETA] Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are", "tags": "outdoors,gps", "custom": "custom.html", diff --git a/apps/gpsrec/ChangeLog b/apps/gpsrec/ChangeLog index ddb7e7dc4..b0d94f230 100644 --- a/apps/gpsrec/ChangeLog +++ b/apps/gpsrec/ChangeLog @@ -16,3 +16,4 @@ 0.13: Increase GPS recording accuracy by one decimal place Ensure default time period is 10 0.14: Now use the openstmap lib for map plotting +0.15: Add plotTrack method to allow current track to be plotted on a map (#395) diff --git a/apps/gpsrec/widget.js b/apps/gpsrec/widget.js index f07c9e43a..9ad1754c6 100644 --- a/apps/gpsrec/widget.js +++ b/apps/gpsrec/widget.js @@ -66,6 +66,24 @@ WIDGETS["gpsrec"]={area:"tl",width:24,draw:draw,reload:function() { reload(); Bangle.drawWidgets(); // relayout all widgets + },plotTrack:function(m) { // m=instance of openstmap module + settings = require("Storage").readJSON("gpsrec.json",1)||{}; + settings.file |= 0; + var n = settings.file.toString(36); + var f = require("Storage").open(".gpsrc"+n,"r"); + var l = f.readLine(f); + if (l===undefined) return; + var c = l.split(","); + var mp = m.latLonToXY(+c[1], +c[2]); + g.moveTo(mp.x,mp.y); + l = f.readLine(f); + while(l!==undefined) { + c = l.split(","); + mp = m.latLonToXY(+c[1], +c[2]); + g.lineTo(mp.x,mp.y); + g.fillCircle(mp.x,mp.y,2); // make the track more visible + l = f.readLine(f); + } }}; // load settings, set correct widget width reload(); diff --git a/apps/openstmap/ChangeLog b/apps/openstmap/ChangeLog index 1fbfd4c50..64b39b509 100644 --- a/apps/openstmap/ChangeLog +++ b/apps/openstmap/ChangeLog @@ -2,3 +2,4 @@ 0.02: Fix marker position, color, and map scaling 0.03: Show widgets (mainly so we can use the GPS recorder widget) 0.04: Move map rendering to a module (fix #396) +0.05: Show currently active gpsrec GPS trace (fix #395) diff --git a/apps/openstmap/app.js b/apps/openstmap/app.js index b678eca33..940557361 100644 --- a/apps/openstmap/app.js +++ b/apps/openstmap/app.js @@ -7,6 +7,10 @@ function redraw() { g.setClipRect(0,y1,g.getWidth()-1,y2); m.draw(); drawMarker(); + if (WIDGETS["gpsrec"] && WIDGETS["gpsrec"].plotTrack) { + g.setColor(0.75,0.2,0); + WIDGETS["gpsrec"].plotTrack(m); + } g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1); }