Split firmware into separate files
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#include "logging.h"
|
||||
|
||||
void logEvent(uint8_t eventCode, const char *data, size_t num)
|
||||
{
|
||||
struct logData event;
|
||||
|
||||
noInterrupts();
|
||||
|
||||
event.unixTime = time(nullptr);
|
||||
event.eventCode = eventCode;
|
||||
|
||||
memset(event.data, 0, LOG_DATA_LENGTH);
|
||||
for (uint8_t i = 0; i < LOG_DATA_LENGTH; i++) {
|
||||
if (i >= num) break;
|
||||
event.data[i] = data[i];
|
||||
}
|
||||
|
||||
if (logPosition < LOG_SIZE) {
|
||||
eventLog[logPosition++] = event;
|
||||
}
|
||||
|
||||
interrupts();
|
||||
}
|
||||
|
||||
void removeLogRecords(uint8_t num)
|
||||
{
|
||||
// shift records down by num because they've been sent
|
||||
|
||||
if (num > logPosition) return;
|
||||
|
||||
noInterrupts();
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
eventLog[i] = eventLog[i + num];
|
||||
}
|
||||
logPosition -= num;
|
||||
|
||||
interrupts();
|
||||
}
|
||||
Reference in New Issue
Block a user