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:
9:9734347b5756
Parent:
8:78b1ff957cba
Child:
10:e4dd36148539
--- a/test.cpp	Sat Feb 22 02:23:21 2014 +0000
+++ b/test.cpp	Sat Feb 22 03:03:37 2014 +0000
@@ -2,9 +2,38 @@
 
 #include <mbed.h>
 #include "motors.h"
+#include <Pacer.h>
+
+#include "test.h"
 #include "leds.h"
+#include "encoders.h"
 #include "pc_serial.h"
 
+void testEncoders()
+{
+    Pacer reportPacer(500000);
+    Pacer blinkPacer(200000);
+    while(1)
+    {
+        while(encoderBuffer.hasEvents())
+        {
+            PololuEncoderEvent event = encoderBuffer.readEvent();
+        }
+        
+        if(reportPacer.pace())
+        {
+            led2 = 1;
+            pc.printf("%8d %8d\n", encoderLeft.getCount(), encoderRight.getCount());
+            led2 = 0;
+        }
+        
+        if (blinkPacer.pace())
+        {
+            led1 = !led1;
+        }
+    }
+}
+
 void testMotors()
 {
     led1 = 1;
@@ -12,29 +41,29 @@
     led3 = 0;
     while(1)
     {
-        motors_speed_set(0, 0);
+        motorsSpeedSet(0, 0);
         led2 = 0;
         led3 = 0;
         wait(2);
         
-        motors_speed_set(300, 300);
+        motorsSpeedSet(300, 300);
         wait(2);
         
-        motors_speed_set(-300, 300);
+        motorsSpeedSet(-300, 300);
         wait(2);
         
-        motors_speed_set(0, 0);
+        motorsSpeedSet(0, 0);
         led2 = 1;
         wait(2);
         
-        motors_speed_set(600, 600);
+        motorsSpeedSet(600, 600);
         wait(2);
         
-        motors_speed_set(0, 0);
+        motorsSpeedSet(0, 0);
         led3 = 1;
         wait(2);
         
-        motors_speed_set(1200, 1200);
+        motorsSpeedSet(1200, 1200);
         wait(2);
     }
 }
\ No newline at end of file