Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/board/data-logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
MICROBIT_HAL_LOG_TIMESTAMP_NONE,
MICROBIT_HAL_LOG_TIMESTAMP_SECONDS,
} from "./constants";
import { State } from "./state";
import { DataLoggingState, State } from "./state";

// Determined via a CODAL program dumping logEnd - dataStart in MicroBitLog.cpp.
// This is only approximate as we don't serialize our state in the same way but
Expand All @@ -24,7 +24,7 @@ export class DataLogging {
private headingsChanged: boolean = false;
private headings: string[] = [];
private row: string[] | undefined;
private logFull: boolean = false;
state: DataLoggingState = { type: "dataLogging", logFull: false };

constructor(
private currentTimeMillis: () => number,
Expand Down Expand Up @@ -84,13 +84,13 @@ export class DataLogging {
if (entry.data || entry.headings) {
const entrySize = calculateEntrySize(entry);
if (this.size + entrySize > maxSizeBytes) {
if (!this.logFull) {
this.logFull = true;
if (!this.state.logFull) {
this.state = {
...this.state,
logFull: true,
};
this.onChange({
dataLogging: {
type: "dataLogging",
logFull: true,
},
dataLogging: this.state,
});
}
return MICROBIT_HAL_DEVICE_NO_RESOURCES;
Expand Down Expand Up @@ -148,13 +148,13 @@ export class DataLogging {
this.timestampOnLastEndRow = undefined;

this.size = 0;
if (this.logFull) {
this.logFull = false;
if (this.state.logFull) {
this.state = {
...this.state,
logFull: false,
};
this.onChange({
dataLogging: {
type: "dataLogging",
logFull: false,
},
dataLogging: this.state,
});
}

Expand Down
6 changes: 1 addition & 5 deletions src/board/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,7 @@ export class Board {
compassHeading: this.compass.state.compassHeading,

lightLevel: this.display.lightLevel,
dataLogging: {
// Placeholder.
type: "dataLogging",
logFull: false,
},
dataLogging: this.dataLogging.state,
soundLevel: this.microphone.soundLevel,
temperature: this.temperature,
};
Expand Down