GPS needs more speed!

Some tweaks to the GPS info app:
 - Speed is shown on the screen
 - "Animation" on the "Waiting for GPS" screen
 - With 10px padding feels a bit nicer :)
pull/60/head
Ákos Lukács 2019-12-05 11:10:20 +01:00 committed by GitHub
parent 0f95313c9d
commit 5ed970abc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 11 deletions

View File

@ -8,15 +8,16 @@ var lastFix = {
alt: 0,
lat: 0,
lon: 0,
speed: 0,
time: 0,
satellites: 0
};
var nofix = 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(" ");
var year = now.getFullYear();
return time + " - " + date;
}
@ -24,30 +25,33 @@ function onGPS(fix) {
lastFix = fix;
g.clear();
g.setFontAlign(-1, -1);
g.drawImage(img, 30, -6);
g.drawImage(img, 20, -12);
g.setFont("6x8");
g.setFontVector(22);
g.drawString("GPS Info", 80, 6);
g.drawString("GPS Info", 70, 0);
if (fix.fix) {
nofix = 0;
var alt = fix.alt;
var lat = fix.lat;
var lon = fix.lon;
var speed = fix.speed;
var time = formatTime(fix.time);
var satellites = fix.satellites;
var s = 12;
g.setFontVector(s+4);
g.drawString("Altitude: "+alt+" m",0,60);
var s = 15;
g.setFontVector(s);
g.drawString("Lat: "+lat, 0, 60+20+s/2);
g.drawString("Lon: "+lon,0,60+40+s/2);
g.drawString("Time: "+time, 0, 60+60+s/2);
g.drawString("Satellites: "+satellites,0,60+80+s/2);
g.drawString("Altitude: "+alt+" m",10,44);
g.drawString("Lat: "+lat,10,44+20);
g.drawString("Lon: "+lon,10,44+40);
g.drawString("Speed: "+speed.toFixed(1)+" km/h",10,44+60);
g.drawString("Time: "+time,10,44+80);
g.drawString("Satellites: "+satellites,10,44+100);
} else {
g.setFontAlign(0, 1);
g.setFont("6x8", 2);
g.drawString("Waiting for GPS", 120, 80);
nofix = (nofix+1) % 4;
g.drawString(".".repeat(nofix) + " ".repeat(4-nofix), 120, 120)
}
g.flip();
}