1
0
Fork 0

Update gps-info.js

Show satellites "in view" separated by GNS-system
master
Hilmar Strauch 2022-01-17 16:38:44 +01:00 committed by GitHub
parent 0d0b84ff41
commit f03c566ee2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 14 deletions

View File

@ -16,9 +16,8 @@ var lastFix = {
time: 0, time: 0,
satellites: 0 satellites: 0
}; };
var SATinView = 0; var SATinView = 0, lastSATinView = -1, nofGP = 0, nofBD = 0, nofGL = 0;
var nofBD = 0; const leaveNofixLayout = 1; // 0 = stay on initial screen for debugging (default = 1)
var nofGP = 0;
var listenerGPSraw = 0; var listenerGPSraw = 0;
function formatTime(now) { function formatTime(now) {
@ -63,7 +62,7 @@ function getMaidenHead(param1,param2){
function onGPS(fix) { function onGPS(fix) {
if (lastFix.fix != fix.fix) { if (lastFix.fix != fix.fix) {
// if fix is different, change the layout // if fix is different, change the layout
if (fix.fix) { if (fix.fix && leaveNofixLayout) {
layout = new Layout( { layout = new Layout( {
type:"v", c: [ type:"v", c: [
{type:"txt", font:"6x8:2", label:"GPS Info" }, {type:"txt", font:"6x8:2", label:"GPS Info" },
@ -92,11 +91,11 @@ function onGPS(fix) {
g.clearRect(0,24,g.getWidth(),g.getHeight()); g.clearRect(0,24,g.getWidth(),g.getHeight());
layout.render(); layout.render();
} }
//lastFix = fix; if (fix.fix && leaveNofixLayout) {
if (fix.fix) {
if (listenerGPSraw == 1) { if (listenerGPSraw == 1) {
Bangle.removeListener('GPS-raw', onGPSraw); Bangle.removeListener('GPS-raw', onGPSraw);
listenerGPSraw = 0; listenerGPSraw = 0;
lastSATinView = -1;
} }
var locale = require("locale"); var locale = require("locale");
var satellites = fix.satellites; var satellites = fix.satellites;
@ -115,27 +114,31 @@ function onGPS(fix) {
layout.sat.label = fix.satellites; layout.sat.label = fix.satellites;
layout.render(layout.sat); layout.render(layout.sat);
} }
if (SATinView != lastFix.SATinView) { if (SATinView != lastSATinView) {
if (!leaveNofixLayout) SATinView = -1;
lastSATinView = SATinView;
layout.clear(layout.progress); layout.clear(layout.progress);
layout.progress.label = "in view: " + SATinView; layout.progress.label = "in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL;
// console.log("in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL);
layout.render(layout.progress); layout.render(layout.progress);
} }
} }
//layout.render();
if (listenerGPSraw == 0 && !fix.fix) { if (listenerGPSraw == 0 && !fix.fix) {
setTimeout(() => Bangle.on('GPS-raw', onGPSraw), 10); setTimeout(() => Bangle.on('GPS-raw', onGPSraw), 10);
listenerGPSraw = 1; listenerGPSraw = 1;
} }
lastFix = fix; lastFix = fix;
lastFix.SATinView = SATinView;
} }
function onGPSraw(nmea) { function onGPSraw(nmea) {
if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13)); if (nmea.slice(3,6) == "GSV") {
// console.log(nmea.slice(1,3) + " " + 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; if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13));
if (nmea.slice(0,7) == "$GLGSV,") nofGL = Number(nmea.slice(11,13));
SATinView = nofGP + nofBD + nofGL;
}
} }