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
00001 #pragma once 00002 00003 #include "logger.h" 00004 #include "pc_serial.h" 00005 00006 Logger::Logger() 00007 { 00008 entryIndex = 0; 00009 } 00010 00011 bool Logger::isFull() 00012 { 00013 return entryIndex >= LOGGER_SIZE; 00014 } 00015 00016 void Logger::log(struct LogEntry * newEntry) 00017 { 00018 if (isFull()) 00019 { 00020 return; 00021 } 00022 00023 LogEntry * entry = &entries[entryIndex]; 00024 entryIndex++; 00025 *entry = *newEntry; 00026 } 00027 00028 void Logger::dump() 00029 { 00030 pc.printf("Log dump start\r\n"); 00031 for(int32_t i = 0; i < entryIndex; i++) 00032 { 00033 LogEntry * entry = &entries[i]; 00034 pc.printf("%d,%d,%d\r\n", entry->turnAngle, entry->x, entry->y); 00035 } 00036 pc.printf("Log dump end\r\n"); 00037 }
Generated on Sun Jul 17 2022 15:45:15 by 1.7.2