David's line following code from the LVBots competition, 2015.

Dependencies:   GeneralDebouncer Pacer PololuEncoder mbed

Fork of DeadReckoning by David Grayson

logger.cpp

Committer:
DavidEGrayson
Date:
2015-04-16
Revision:
57:99bec7fab454
Parent:
49:eaa6fd514f4f

File content as of revision 57:99bec7fab454:

#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");
}