Skip to content

Commit

Permalink
recorder: test using GPS fix time
Browse files Browse the repository at this point in the history
  • Loading branch information
thyttan committed Nov 18, 2023
1 parent 31d1f48 commit bf38099
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/recorder/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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();
Expand Down

0 comments on commit bf38099

Please sign in to comment.