David's dead reckoning code for the LVBots competition on March 6th. Uses the mbed LPC1768, DRV8835, QTR-3RC, and two DC motors with encoders.
Dependencies: PololuEncoder Pacer mbed GeneralDebouncer
logger.cpp
- Committer:
- DavidEGrayson
- Date:
- 2019-08-13
- Revision:
- 48:597738b77f77
- Parent:
- 40:6fa672be85ec
File content as of revision 48:597738b77f77:
#pragma once
#include "logger.h"
#include "pc_serial.h"
Logger::Logger()
{
entryIndex = 0;
}
bool Logger::isFull()
{
return entryIndex >= LOGGER_SIZE;
}
void Logger::log(struct LogEntry * newEntry)
{
if (isFull())
{
return;
}
LogEntry * entry = &entries[entryIndex];
entryIndex++;
*entry = *newEntry;
}
void Logger::dump()
{
pc.printf("Log dump start\r\n");
for(int32_t i = 0; i < entryIndex; i++)
{
LogEntry * entry = &entries[i];
pc.printf("%d,%d,%d\r\n", entry->turnAngle, entry->x, entry->y);
}
pc.printf("Log dump end\r\n");
}
David Grayson