Skip to content

Commit

Permalink
recorder: 1 decimal place for 1 second period logs
Browse files Browse the repository at this point in the history
  • Loading branch information
thyttan committed Nov 17, 2023
1 parent 9ea23e3 commit 44c597b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/recorder/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,17 @@
};
let getCSVHeaders = activeRecorders => ["Time"].concat(activeRecorders.map(r=>r.fields));

let writeLog = function() {
let writeLog = function(period) {
entriesWritten++;
WIDGETS["recorder"].draw();
try {
var fields = [Math.round(getTime())];
var time = getTime();
if (period===1) {
time = Math.round(time)+"."+(Math.round(time*10))%10;
} else {
time = Math.round(time);
}
var fields = [time];
activeRecorders.forEach(recorder => fields.push.apply(fields,recorder.getValues()));
if (storageFile) storageFile.write(fields.join(",")+"\n");
} catch(e) {
Expand Down Expand Up @@ -222,7 +228,7 @@
}
// start recording...
WIDGETS["recorder"].draw();
writeInterval = setInterval(writeLog, settings.period*1000);
writeInterval = setInterval(writeLog, settings.period*1000, settings.period);
} else {
WIDGETS["recorder"].width = 0;
storageFile = undefined;
Expand Down

0 comments on commit 44c597b

Please sign in to comment.