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-15
Revision:
46:f11cb4f93aac
Parent:
37:23000a47ed2b
Child:
47:cb5c1504c24d

File content as of revision 46:f11cb4f93aac:

#pragma once

#include "logger.h"
#include "main.h"
#include "pc_serial.h"

Logger::Logger()
{
    entryIndex = 0;   
}

bool Logger::isFull()
{
    return entryIndex >= LOGGER_SIZE;
}

void Logger::log()
{
    if (isFull())
    {
        return;   
    }
    
    LogEntry * entry = &entries[entryIndex];
    entryIndex++;
    
    entry->turnAngle = 0;
    entry->x = reckoner.x >> 16;
    entry->y = reckoner.y >> 16;
}

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\r\n", entry->turnAngle, entry->x, entry->y);
    }
    pc.printf("Log dump end\r\n");
}