From bf3809970ca18ed0085a80de41b7c865f9fed486 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.comā©> Date: Sat, 18 Nov 2023 22:09:50 +0100 Subject: [PATCH] recorder: test using GPS fix time --- apps/recorder/widget.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/recorder/widget.js b/apps/recorder/widget.js index 7fc46bc6ad..dfb505cd3f 100644 --- a/apps/recorder/widget.js +++ b/apps/recorder/widget.js @@ -176,13 +176,16 @@ }; let getCSVHeaders = activeRecorders => ["Time"].concat(activeRecorders.map(r=>r.fields)); - let writeLog = function(period) { + let writeLog = function(period, fix) { entriesWritten++; WIDGETS["recorder"].draw(); try { - var fields = [period===1?getTime().toFixed(1):Math.round(getTime())]; + console.log("\nfix lat: " + fix.lat + "\nfix time (ms): " + fix.time + "\ncpu time (s): " + getTime()); + var time = (fix.time&&fix.lat)?fix.time/1000:getTime(); + var fields = [period===1?time.toFixed(1):Math.round(time)]; activeRecorders.forEach(recorder => fields.push.apply(fields,recorder.getValues())); if (storageFile) storageFile.write(fields.join(",")+"\n"); + console.log("logged time (s): " + fields[0]); } catch(e) { // If storage.write caused an error, disable // GPS recording so we don't keep getting errors! @@ -194,7 +197,8 @@ } } - function writeOnGPS() {writeLog(settings.period)} + let writeOnGPS = function(fix) {writeLog(loadSettings().period, fix); } + // Called by the GPS app to reload settings and decide what to do let reload = function() { var settings = loadSettings();