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

Revision:
37:23000a47ed2b
Parent:
34:6c84680d823a
Child:
38:5e93a479c244
--- a/main.cpp	Thu Mar 06 02:39:07 2014 +0000
+++ b/main.cpp	Thu Mar 06 05:11:46 2014 +0000
@@ -15,6 +15,8 @@
 
 Reckoner reckoner;
 LineTracker lineTracker;
+Logger logger;
+Pacer loggerPacer(50000);
 
 const int16_t drivingSpeed = 400;
 
@@ -49,6 +51,8 @@
     //testSensorGlitches();
     //testTurnInPlace();
     //testCloseness();
+    //testLogger();
+    
 
     // Real routines for the contest.
     loadCalibration();
@@ -72,9 +76,29 @@
     //finalSettleIn();
     
     setLeds(1, 1, 1, 1);
-    while(1){}
+    loggerReportLoop();
+}
+
+void loggerService()
+{
+    if (loggerPacer.pace())
+    {
+        logger.log();   
+    }
 }
 
+void loggerReportLoop()
+{
+    while(1)
+    {
+        if(button1DefinitelyPressed())
+        {
+            logger.dump();
+        }
+    }   
+}
+
+
 void loadCalibration()
 {
     /** QTR-3RC **/
@@ -209,7 +233,8 @@
         lineTracker.read();
         lineTracker.updateCalibration();       
         updateReckonerFromEncoders();
-        updateMotorsToDriveStraight();        
+        loggerService();
+        updateMotorsToDriveStraight();
         lineStatus.update(lineTracker.getLineVisible());       
 
         if(lineStatus.getState() == true && lineStatus.getTimeInCurrentStateMicroseconds() > 20000)
@@ -249,6 +274,7 @@
     {
         lineTracker.read();
         updateReckonerFromEncoders();
+        loggerService();
 
         lineStatus.update(lineTracker.getLineVisible());
         
@@ -271,7 +297,8 @@
     while(1)
     {
         updateReckonerFromEncoders();
-        
+        loggerService();
+
         float magn = magnitude();
         
         if (magn < (1<<(14+7)))  
@@ -329,7 +356,8 @@
         led1 = (state == 1);
         
         updateReckonerFromEncoders();
-        
+        loggerService();
+
         float dot = dotProduct();
         int16_t speedModification = -dot * settleModificationStrength;
         if (speedModification > settleModificationStrength)