mirror of https://github.com/espruino/BangleApps
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 againpull/408/head
parent
743f319d85
commit
4416df1363
|
@ -314,7 +314,7 @@
|
||||||
{ "id": "gpsrec",
|
{ "id": "gpsrec",
|
||||||
"name": "GPS Recorder",
|
"name": "GPS Recorder",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version":"0.08",
|
"version":"0.09",
|
||||||
"interface": "interface.html",
|
"interface": "interface.html",
|
||||||
"description": "Application that allows you to record a GPS track. Can run in background",
|
"description": "Application that allows you to record a GPS track. Can run in background",
|
||||||
"tags": "tool,outdoors,gps,widget",
|
"tags": "tool,outdoors,gps,widget",
|
||||||
|
|
|
@ -7,3 +7,6 @@
|
||||||
0.07: Added @jeffmer's awesome track viewer
|
0.07: Added @jeffmer's awesome track viewer
|
||||||
0.08: Don't overwrite existing settings on app update
|
0.08: Don't overwrite existing settings on app update
|
||||||
Clean up recorded tracks on app removal
|
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
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"recording":false,
|
"recording":false,
|
||||||
"file":0,
|
"file":0,
|
||||||
"period":1
|
"period":10
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ function viewTracks() {
|
||||||
for (var n=0;n<36;n++) {
|
for (var n=0;n<36;n++) {
|
||||||
var f = require("Storage").open(getFN(n),"r");
|
var f = require("Storage").open(getFN(n),"r");
|
||||||
if (f.readLine()!==undefined) {
|
if (f.readLine()!==undefined) {
|
||||||
menu["Track "+n] = viewTrack.bind(null,n);
|
menu["Track "+n] = viewTrack.bind(null,n,false);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ function viewTracks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTrackInfo(fn) {
|
function getTrackInfo(fn) {
|
||||||
|
"ram"
|
||||||
var filename = getFN(fn);
|
var filename = getFN(fn);
|
||||||
var minLat = 90;
|
var minLat = 90;
|
||||||
var maxLat = -90;
|
var maxLat = -90;
|
||||||
|
@ -88,8 +89,8 @@ function getTrackInfo(fn) {
|
||||||
// pushed this loop together to try and bump loading speed a little
|
// pushed this loop together to try and bump loading speed a little
|
||||||
while(l!==undefined) {
|
while(l!==undefined) {
|
||||||
++nl;c=l.split(",");
|
++nl;c=l.split(",");
|
||||||
n = parseFloat(c[1]);if(n>maxLat)maxLat=n;if(n<minLat)minLat=n;
|
n = +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[2];if(n>maxLong)maxLong=n;if(n<minLong)minLong=n;
|
||||||
l = f.readLine(f);
|
l = f.readLine(f);
|
||||||
}
|
}
|
||||||
if (c) duration = parseInt(c[0]) - starttime;
|
if (c) duration = parseInt(c[0]) - starttime;
|
||||||
|
@ -116,9 +117,11 @@ function asTime(v){
|
||||||
return ""+mins.toString()+"m "+secs.toString()+"s";
|
return ""+mins.toString()+"m "+secs.toString()+"s";
|
||||||
}
|
}
|
||||||
|
|
||||||
function viewTrack(n) {
|
function viewTrack(n, info) {
|
||||||
|
if (!info) {
|
||||||
E.showMessage("Loading...","GPS Track "+n);
|
E.showMessage("Loading...","GPS Track "+n);
|
||||||
var info = getTrackInfo(n);
|
info = getTrackInfo(n);
|
||||||
|
}
|
||||||
const menu = {
|
const menu = {
|
||||||
'': { 'title': 'GPS Track '+n }
|
'': { 'title': 'GPS Track '+n }
|
||||||
};
|
};
|
||||||
|
@ -138,7 +141,7 @@ function viewTrack(n) {
|
||||||
f.erase();
|
f.erase();
|
||||||
viewTracks();
|
viewTracks();
|
||||||
} else
|
} else
|
||||||
viewTrack(n);
|
viewTrack(n, info);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
menu['< Back'] = viewTracks;
|
menu['< Back'] = viewTracks;
|
||||||
|
@ -146,13 +149,7 @@ function viewTrack(n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function plotTrack(info) {
|
function plotTrack(info) {
|
||||||
function xcoord(long){
|
"ram"
|
||||||
return 30 + Math.round((long-info.minLong)*info.lfactor*info.scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ycoord(lat){
|
|
||||||
return 210 - Math.round((lat - info.minLat)*info.scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
function radians(a) {
|
function radians(a) {
|
||||||
return a*Math.PI/180;
|
return a*Math.PI/180;
|
||||||
|
@ -182,27 +179,26 @@ function plotTrack(info) {
|
||||||
var ox=0;
|
var ox=0;
|
||||||
var oy=0;
|
var oy=0;
|
||||||
var olat,olong,dist=0;
|
var olat,olong,dist=0;
|
||||||
var first = true;
|
|
||||||
var i=0;
|
var i=0;
|
||||||
while(l!==undefined) {
|
|
||||||
var c = l.split(",");
|
var c = l.split(",");
|
||||||
var lat = parseFloat(c[1]);
|
var lat = +c[1];
|
||||||
var long = parseFloat(c[2]);
|
var long = +c[2];
|
||||||
var x = xcoord(long);
|
var x = 30 + Math.round((long-info.minLong)*info.lfactor*info.scale);
|
||||||
var y = ycoord(lat);
|
var y = 210 - Math.round((lat - info.minLat)*info.scale);
|
||||||
if (first) {
|
|
||||||
g.moveTo(x,y);
|
g.moveTo(x,y);
|
||||||
g.setColor(0,1,0);
|
g.setColor(0,1,0);
|
||||||
g.fillCircle(x,y,5);
|
g.fillCircle(x,y,5);
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
first = false;
|
l = f.readLine(f);
|
||||||
} else if (x!=ox || y!=oy) {
|
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);
|
g.lineTo(x,y);
|
||||||
}
|
|
||||||
if (!first) {
|
|
||||||
var d = distance(olat,olong,lat,long);
|
var d = distance(olat,olong,lat,long);
|
||||||
if (!isNaN(d)) dist+=d;
|
if (!isNaN(d)) dist+=d;
|
||||||
}
|
|
||||||
olat = lat;
|
olat = lat;
|
||||||
olong = long;
|
olong = long;
|
||||||
ox = x;
|
ox = x;
|
||||||
|
@ -217,7 +213,7 @@ function plotTrack(info) {
|
||||||
g.setFontAlign(0,0,3);
|
g.setFontAlign(0,0,3);
|
||||||
g.drawString("Back",230,200);
|
g.drawString("Back",230,200);
|
||||||
setWatch(function() {
|
setWatch(function() {
|
||||||
viewTrack(info.fn);
|
viewTrack(info.fn, info);
|
||||||
}, BTN3);
|
}, BTN3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
// Called by the GPS app to reload settings and decide what to do
|
// Called by the GPS app to reload settings and decide what to do
|
||||||
function reload() {
|
function reload() {
|
||||||
settings = require("Storage").readJSON("gpsrec.json",1)||{};
|
settings = require("Storage").readJSON("gpsrec.json",1)||{};
|
||||||
settings.period = settings.period||1;
|
settings.period = settings.period||10;
|
||||||
settings.file |= 0;
|
settings.file |= 0;
|
||||||
|
|
||||||
Bangle.removeListener('GPS',onGPS);
|
Bangle.removeListener('GPS',onGPS);
|
||||||
|
|
Loading…
Reference in New Issue