mirror of https://github.com/espruino/BangleApps
Merge pull request #1167 from HilmarSt/patch-1
GPS Info App: Added number of satellites in view and fixed crash with GPS timepull/1174/head^2^2
commit
83fcb599aa
|
@ -16,13 +16,19 @@ var lastFix = {
|
|||
time: 0,
|
||||
satellites: 0
|
||||
};
|
||||
var nofix = 0;
|
||||
var SATinView = 0;
|
||||
var nofBD = 0;
|
||||
var nofGP = 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 +83,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 +93,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 +105,21 @@ 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") {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
Bangle.on('GPS', onGPS);
|
||||
Bangle.on('GPS-raw', onGPSraw);
|
||||
|
|
Loading…
Reference in New Issue