forked from FOSS/BangleApps
recorder 0.18: Improve widget load speed, allow currently recording track to be plotted in openstmap
parent
e5894c36af
commit
902db2a19a
|
@ -21,3 +21,4 @@
|
|||
0.15: Show distance more accurately in conjunction with new locale app (fix #1523)
|
||||
0.16: Ability to append to existing track (fix #1712)
|
||||
0.17: Use default Bangle formatter for booleans
|
||||
0.18: Improve widget load speed, allow currently recording track to be plotted in openstmap
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "recorder",
|
||||
"name": "Recorder",
|
||||
"shortName": "Recorder",
|
||||
"version": "0.17",
|
||||
"version": "0.18",
|
||||
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
|
||||
"icon": "app.png",
|
||||
"tags": "tool,outdoors,gps,widget",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
(() => {
|
||||
var storageFile; // file for GPS track
|
||||
var entriesWritten = 0;
|
||||
var activeRecorders = [];
|
||||
var writeInterval;
|
||||
{
|
||||
let storageFile; // file for GPS track
|
||||
let entriesWritten = 0;
|
||||
let activeRecorders = [];
|
||||
let writeInterval;
|
||||
|
||||
function loadSettings() {
|
||||
let loadSettings = function() {
|
||||
var settings = require("Storage").readJSON("recorder.json",1)||{};
|
||||
settings.period = settings.period||10;
|
||||
if (!settings.file || !settings.file.startsWith("recorder.log"))
|
||||
|
@ -12,12 +12,12 @@
|
|||
return settings;
|
||||
}
|
||||
|
||||
function updateSettings(settings) {
|
||||
let updateSettings = function(settings) {
|
||||
require("Storage").writeJSON("recorder.json", settings);
|
||||
if (WIDGETS["recorder"]) WIDGETS["recorder"].reload();
|
||||
}
|
||||
|
||||
function getRecorders() {
|
||||
let getRecorders = function() {
|
||||
var recorders = {
|
||||
gps:function() {
|
||||
var lat = 0;
|
||||
|
@ -159,7 +159,7 @@
|
|||
return recorders;
|
||||
}
|
||||
|
||||
function writeLog() {
|
||||
let writeLog = function() {
|
||||
entriesWritten++;
|
||||
WIDGETS["recorder"].draw();
|
||||
try {
|
||||
|
@ -178,7 +178,7 @@
|
|||
}
|
||||
|
||||
// Called by the GPS app to reload settings and decide what to do
|
||||
function reload() {
|
||||
let reload = function() {
|
||||
var settings = loadSettings();
|
||||
if (writeInterval) clearInterval(writeInterval);
|
||||
writeInterval = undefined;
|
||||
|
@ -224,7 +224,7 @@
|
|||
// add the widget
|
||||
WIDGETS["recorder"]={area:"tl",width:0,draw:function() {
|
||||
if (!writeInterval) return;
|
||||
g.reset(); g.drawImage(atob("DRSBAAGAHgDwAwAAA8B/D/hvx38zzh4w8A+AbgMwGYDMDGBjAA=="),this.x+1,this.y+2);
|
||||
g.reset().drawImage(atob("DRSBAAGAHgDwAwAAA8B/D/hvx38zzh4w8A+AbgMwGYDMDGBjAA=="),this.x+1,this.y+2);
|
||||
activeRecorders.forEach((recorder,i)=>{
|
||||
recorder.draw(this.x+15+(i>>1)*12, this.y+(i&1)*12);
|
||||
});
|
||||
|
@ -265,24 +265,38 @@
|
|||
updateSettings(settings);
|
||||
WIDGETS["recorder"].reload();
|
||||
return Promise.resolve(settings.recording);
|
||||
}/*,plotTrack:function(m) { // m=instance of openstmap module
|
||||
// FIXME - add track plotting
|
||||
// if we're here, settings was already loaded
|
||||
var f = require("Storage").open(settings.file,"r");
|
||||
var l = f.readLine(f);
|
||||
if (l===undefined) return;
|
||||
var c = l.split(",");
|
||||
var mp = m.latLonToXY(+c[1], +c[2]);
|
||||
g.moveTo(mp.x,mp.y);
|
||||
l = f.readLine(f);
|
||||
while(l!==undefined) {
|
||||
c = l.split(",");
|
||||
mp = m.latLonToXY(+c[1], +c[2]);
|
||||
g.lineTo(mp.x,mp.y);
|
||||
g.fillCircle(mp.x,mp.y,2); // make the track more visible
|
||||
},plotTrack:function(m) { // m=instance of openstmap module
|
||||
// Plots the current track in the currently set color
|
||||
if (!activeRecorders) return; // not recording & not recording GPS
|
||||
var settings = loadSettings();
|
||||
// keep function to draw track in RAM
|
||||
function plot(g) { "ram";
|
||||
var f = require("Storage").open(settings.file,"r");
|
||||
var l = f.readLine();
|
||||
if (l===undefined) return; // empty file?
|
||||
var mp, c = l.split(",");
|
||||
var la=c.indexOf("Latitude"),lo=c.indexOf("Longitude");
|
||||
l = f.readLine();
|
||||
while (l && !c[la]) {
|
||||
c = l.split(",");
|
||||
l = f.readLine(f);
|
||||
}
|
||||
if (l===undefined) return; // empty file?
|
||||
mp = m.latLonToXY(+c[la], +c[lo]);
|
||||
g.moveTo(mp.x,mp.y);
|
||||
l = f.readLine(f);
|
||||
var n = 200; // only plot first 200 points to keep things fast(ish)
|
||||
while(l && n--) {
|
||||
c = l.split(",");
|
||||
if (c[la]) {
|
||||
mp = m.latLonToXY(+c[la], +c[lo]);
|
||||
g.lineTo(mp.x,mp.y);
|
||||
}
|
||||
l = f.readLine(f);
|
||||
}
|
||||
}
|
||||
}*/};
|
||||
plot(g);
|
||||
}};
|
||||
// load settings, set correct widget width
|
||||
reload();
|
||||
})()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue