diff --git a/apps.json b/apps.json index ebafa9c97..7e3d29cdc 100644 --- a/apps.json +++ b/apps.json @@ -1501,7 +1501,7 @@ { "id": "gpsinfo", "name": "GPS Info", - "version": "0.06", + "version": "0.07", "description": "An application that displays information about altitude, lat/lon, satellites and time", "icon": "gps-info.png", "type": "app", diff --git a/apps/gpsinfo/ChangeLog b/apps/gpsinfo/ChangeLog index 3ff284cb8..a3a2fc89a 100644 --- a/apps/gpsinfo/ChangeLog +++ b/apps/gpsinfo/ChangeLog @@ -2,4 +2,5 @@ 0.03: Show number of satellites while waiting for fix 0.04: Add Maidenhead readout of GPS location 0.05: Refactor to use 'layout' library for multi-device support -0.06: Added number of satellites in view and fixed crash with GPS time +0.06: Add number of satellites in view and fix crash with GPS time +0.07: Resolve one FIFO_FULL case and exit App with button press diff --git a/apps/gpsinfo/gps-info.js b/apps/gpsinfo/gps-info.js index a16d4a04e..467d12a95 100644 --- a/apps/gpsinfo/gps-info.js +++ b/apps/gpsinfo/gps-info.js @@ -19,6 +19,7 @@ var lastFix = { var SATinView = 0; var nofBD = 0; var nofGP = 0; +var listenerGPSraw = 1; function formatTime(now) { if (now == undefined) { @@ -93,6 +94,10 @@ function onGPS(fix) { } lastFix = fix; if (fix.fix) { + if (listenerGPSraw == 1) { + Bangle.removeListener('GPS-raw', onGPSraw); + listenerGPSraw = 0; + } var locale = require("locale"); var satellites = fix.satellites; var maidenhead = getMaidenHead(fix.lat,fix.lon); @@ -104,6 +109,10 @@ function onGPS(fix) { layout.sat.label = "Satellites: "+satellites; layout.maidenhead.label = "Maidenhead: "+maidenhead; } else { + if (listenerGPSraw == 0) { + Bangle.on('GPS-raw', onGPSraw); + listenerGPSraw = 1; + } layout.sat.label = fix.satellites; layout.progress.label = "in view: " + SATinView; } @@ -111,15 +120,26 @@ function onGPS(fix) { } function onGPSraw(nmea) { - if (nmea.slice(3,6) == "GSV") { - // console.log(nmea); - if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13)); - if (nmea.slice(0,7) == "$GPGSV,") nofGP = Number(nmea.slice(11,13)); - SATinView = nofBD + nofGP; - } + if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13)); + if (nmea.slice(0,7) == "$GPGSV,") nofGP = Number(nmea.slice(11,13)); + SATinView = nofBD + nofGP; } + Bangle.loadWidgets(); Bangle.drawWidgets(); Bangle.on('GPS', onGPS); Bangle.on('GPS-raw', onGPSraw); + +function exitApp() { + Bangle.setGPSPower(0, "app"); + Bangle.removeListener('GPS-raw', onGPSraw); + Bangle.removeListener('GPS', onGPS); + load(); +} + +setWatch(_=>exitApp(), BTN1); +if (global.BTN2) { + setWatch(_=>exitApp(), BTN2); + setWatch(_=>exitApp(), BTN3); +}