1
0
Fork 0

Merge pull request #1 from HilmarSt/HilmarSt-patch-1

Update GPS Info App
master
Hilmar Strauch 2022-01-05 23:36:29 +01:00 committed by GitHub
commit b53a08fd9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 8 deletions

View File

@ -1501,7 +1501,7 @@
{ {
"id": "gpsinfo", "id": "gpsinfo",
"name": "GPS Info", "name": "GPS Info",
"version": "0.06", "version": "0.07",
"description": "An application that displays information about altitude, lat/lon, satellites and time", "description": "An application that displays information about altitude, lat/lon, satellites and time",
"icon": "gps-info.png", "icon": "gps-info.png",
"type": "app", "type": "app",

View File

@ -2,4 +2,5 @@
0.03: Show number of satellites while waiting for fix 0.03: Show number of satellites while waiting for fix
0.04: Add Maidenhead readout of GPS location 0.04: Add Maidenhead readout of GPS location
0.05: Refactor to use 'layout' library for multi-device support 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

View File

@ -19,6 +19,7 @@ var lastFix = {
var SATinView = 0; var SATinView = 0;
var nofBD = 0; var nofBD = 0;
var nofGP = 0; var nofGP = 0;
var listenerGPSraw = 1;
function formatTime(now) { function formatTime(now) {
if (now == undefined) { if (now == undefined) {
@ -93,6 +94,10 @@ function onGPS(fix) {
} }
lastFix = fix; lastFix = fix;
if (fix.fix) { if (fix.fix) {
if (listenerGPSraw == 1) {
Bangle.removeListener('GPS-raw', onGPSraw);
listenerGPSraw = 0;
}
var locale = require("locale"); var locale = require("locale");
var satellites = fix.satellites; var satellites = fix.satellites;
var maidenhead = getMaidenHead(fix.lat,fix.lon); var maidenhead = getMaidenHead(fix.lat,fix.lon);
@ -104,6 +109,10 @@ function onGPS(fix) {
layout.sat.label = "Satellites: "+satellites; layout.sat.label = "Satellites: "+satellites;
layout.maidenhead.label = "Maidenhead: "+maidenhead; layout.maidenhead.label = "Maidenhead: "+maidenhead;
} else { } else {
if (listenerGPSraw == 0) {
Bangle.on('GPS-raw', onGPSraw);
listenerGPSraw = 1;
}
layout.sat.label = fix.satellites; layout.sat.label = fix.satellites;
layout.progress.label = "in view: " + SATinView; layout.progress.label = "in view: " + SATinView;
} }
@ -111,15 +120,26 @@ function onGPS(fix) {
} }
function onGPSraw(nmea) { 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) == "$BDGSV,") nofBD = Number(nmea.slice(11,13));
if (nmea.slice(0,7) == "$GPGSV,") nofGP = Number(nmea.slice(11,13)); if (nmea.slice(0,7) == "$GPGSV,") nofGP = Number(nmea.slice(11,13));
SATinView = nofBD + nofGP; SATinView = nofBD + nofGP;
}
} }
Bangle.loadWidgets(); Bangle.loadWidgets();
Bangle.drawWidgets(); Bangle.drawWidgets();
Bangle.on('GPS', onGPS); Bangle.on('GPS', onGPS);
Bangle.on('GPS-raw', onGPSraw); 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);
}