gpsrec 0.09: Change default GPS period to 10 (1 is overkill for most uses and makes things slow)

Added RAM keyword to functions & other tweaks to speed up rendering
      Going 'back' from track view now doesn't load again
pull/408/head
Gordon Williams 2020-05-08 21:58:55 +01:00
parent 743f319d85
commit 4416df1363
5 changed files with 36 additions and 37 deletions

View File

@ -314,7 +314,7 @@
{ "id": "gpsrec",
"name": "GPS Recorder",
"icon": "app.png",
"version":"0.08",
"version":"0.09",
"interface": "interface.html",
"description": "Application that allows you to record a GPS track. Can run in background",
"tags": "tool,outdoors,gps,widget",

View File

@ -7,3 +7,6 @@
0.07: Added @jeffmer's awesome track viewer
0.08: Don't overwrite existing settings on app update
Clean up recorded tracks on app removal
0.09: Change default GPS period to 10 (1 is overkill for most uses and makes things slow)
Added RAM keyword to functions & other tweaks to speed up rendering
Going 'back' from track view now doesn't load again

View File

@ -1,5 +1,5 @@
{
"recording":false,
"file":0,
"period":1
"period":10
}

View File

@ -60,7 +60,7 @@ function viewTracks() {
for (var n=0;n<36;n++) {
var f = require("Storage").open(getFN(n),"r");
if (f.readLine()!==undefined) {
menu["Track "+n] = viewTrack.bind(null,n);
menu["Track "+n] = viewTrack.bind(null,n,false);
found = true;
}
}
@ -71,6 +71,7 @@ function viewTracks() {
}
function getTrackInfo(fn) {
"ram"
var filename = getFN(fn);
var minLat = 90;
var maxLat = -90;
@ -88,8 +89,8 @@ function getTrackInfo(fn) {
// pushed this loop together to try and bump loading speed a little
while(l!==undefined) {
++nl;c=l.split(",");
n = parseFloat(c[1]);if(n>maxLat)maxLat=n;if(n<minLat)minLat=n;
n = parseFloat(c[2]);if(n>maxLong)maxLong=n;if(n<minLong)minLong=n;
n = +c[1];if(n>maxLat)maxLat=n;if(n<minLat)minLat=n;
n = +c[2];if(n>maxLong)maxLong=n;if(n<minLong)minLong=n;
l = f.readLine(f);
}
if (c) duration = parseInt(c[0]) - starttime;
@ -116,9 +117,11 @@ function asTime(v){
return ""+mins.toString()+"m "+secs.toString()+"s";
}
function viewTrack(n) {
function viewTrack(n, info) {
if (!info) {
E.showMessage("Loading...","GPS Track "+n);
var info = getTrackInfo(n);
info = getTrackInfo(n);
}
const menu = {
'': { 'title': 'GPS Track '+n }
};
@ -138,7 +141,7 @@ function viewTrack(n) {
f.erase();
viewTracks();
} else
viewTrack(n);
viewTrack(n, info);
});
};
menu['< Back'] = viewTracks;
@ -146,13 +149,7 @@ function viewTrack(n) {
}
function plotTrack(info) {
function xcoord(long){
return 30 + Math.round((long-info.minLong)*info.lfactor*info.scale);
}
function ycoord(lat){
return 210 - Math.round((lat - info.minLat)*info.scale);
}
"ram"
function radians(a) {
return a*Math.PI/180;
@ -182,27 +179,26 @@ function plotTrack(info) {
var ox=0;
var oy=0;
var olat,olong,dist=0;
var first = true;
var i=0;
while(l!==undefined) {
var c = l.split(",");
var lat = parseFloat(c[1]);
var long = parseFloat(c[2]);
var x = xcoord(long);
var y = ycoord(lat);
if (first) {
var lat = +c[1];
var long = +c[2];
var x = 30 + Math.round((long-info.minLong)*info.lfactor*info.scale);
var y = 210 - Math.round((lat - info.minLat)*info.scale);
g.moveTo(x,y);
g.setColor(0,1,0);
g.fillCircle(x,y,5);
g.setColor(1,1,1);
first = false;
} else if (x!=ox || y!=oy) {
l = f.readLine(f);
while(l!==undefined) {
c = l.split(",");
lat = +c[1];
long = +c[2];
x = 30 + Math.round((long-info.minLong)*info.lfactor*info.scale);
y = 210 - Math.round((lat - info.minLat)*info.scale);
g.lineTo(x,y);
}
if (!first) {
var d = distance(olat,olong,lat,long);
if (!isNaN(d)) dist+=d;
}
olat = lat;
olong = long;
ox = x;
@ -217,7 +213,7 @@ function plotTrack(info) {
g.setFontAlign(0,0,3);
g.drawString("Back",230,200);
setWatch(function() {
viewTrack(info.fn);
viewTrack(info.fn, info);
}, BTN3);
}

View File

@ -41,7 +41,7 @@
// Called by the GPS app to reload settings and decide what to do
function reload() {
settings = require("Storage").readJSON("gpsrec.json",1)||{};
settings.period = settings.period||1;
settings.period = settings.period||10;
settings.file |= 0;
Bangle.removeListener('GPS',onGPS);