diff --git a/apps/gpsinfo/gps-info.js b/apps/gpsinfo/gps-info.js index df888651a..cca7e8e0f 100644 --- a/apps/gpsinfo/gps-info.js +++ b/apps/gpsinfo/gps-info.js @@ -16,13 +16,17 @@ var lastFix = { time: 0, satellites: 0 }; -var nofix = 0; +var SATinView = 0; function formatTime(now) { - var fd = now.toUTCString().split(" "); - var time = fd[4].substr(0, 5); - var date = [fd[0], fd[1], fd[2]].join(" "); - return time + " - " + date; + if (now == undefined) { + return "no GPS time available"; + } else { + var fd = now.toUTCString().split(" "); + var time = fd[4].substr(0, 5); + var date = [fd[0], fd[1], fd[2]].join(" "); + return time + " - " + date; + } } function getMaidenHead(param1,param2){ var lat=-100.0; @@ -77,9 +81,9 @@ function onGPS(fix) { {type:"txt", font:"6x8", label:"Waiting for GPS" }, {type:"h", c: [ {type:"txt", font:"10%", label:fix.satellites, pad:2, id:"sat" }, - {type:"txt", font:"6x8", pad:3, label:"Satellites" } + {type:"txt", font:"6x8", pad:3, label:"Satellites used" } ]}, - {type:"txt", font:"6x8", label:"", id:"progress" } + {type:"txt", font:"6x8", label:"", fillx:true, id:"progress" } ]},{lazy:true}); } g.clearRect(0,24,g.getWidth(),g.getHeight()); @@ -87,7 +91,6 @@ function onGPS(fix) { } lastFix = fix; if (fix.fix) { - nofix = 0; var locale = require("locale"); var satellites = fix.satellites; var maidenhead = getMaidenHead(fix.lat,fix.lon); @@ -100,12 +103,18 @@ function onGPS(fix) { layout.maidenhead.label = "Maidenhead: "+maidenhead; } else { layout.sat.label = fix.satellites; - nofix = (nofix+1) % 4; - layout.progress.label = ".".repeat(nofix) + " ".repeat(4-nofix); + layout.progress.label = "in view: " + SATinView; } layout.render(); } +function onGPSraw(nmea) { + if (nmea.slice(3,6) == "GSV") { + SATinView = nmea.slice(11,13); + } +} + Bangle.loadWidgets(); Bangle.drawWidgets(); Bangle.on('GPS', onGPS); +Bangle.on('GPS-raw', onGPSraw);