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

Dependencies:   GeneralDebouncer Pacer PololuEncoder mbed

Fork of DeadReckoning by David Grayson

Revision:
44:edcacba44760
Parent:
39:a5e25fd52ff8
Child:
45:e16e74bbbf8c
--- a/test.cpp	Tue Apr 14 01:56:59 2015 +0000
+++ b/test.cpp	Wed Apr 15 19:14:39 2015 +0000
@@ -12,6 +12,8 @@
 #include "line_sensors.h"
 #include "reckoner.h"
 #include "buttons.h"
+#include "l3g.h"
+#include "turn_sensor.h"
 
 void __attribute__((noreturn)) infiniteReckonerReportLoop();
 void printBar(const char * name, uint16_t adcResult);
@@ -456,4 +458,53 @@
     pc.putc('|');
     pc.putc('\r');
     pc.putc('\n');
+}
+
+void testL3g()
+{
+    Pacer reportPacer(750000);
+    Timer timer;
+    timer.start();
+    int32_t gz = 0;
+    bool reportedReading = false;
+    while(1)
+    {
+        int32_t result = l3gZAvailable();
+        if (result == 1)
+        {
+            gz = l3gZRead();
+            reportedReading = false;
+            if (gz > 100 || gz < -100)
+            {
+                pc.printf("%d, %d\r\n", timer.read_us(), gz); 
+                reportedReading = true;
+            }
+        }
+        else if (result != 0)
+        {
+            pc.printf("l3gZAvailable error: %d\n", result);
+        }
+
+        if (reportPacer.pace() && !reportedReading)
+        {
+            pc.printf("%d, %d\r\n", timer.read_us(), gz);
+            reportedReading = true;
+        }
+    }
+}
+
+void testTurnSensor()
+{
+    pc.printf("Test turn sensor\r\n");
+    Pacer reportPacer(200000);
+    TurnSensor turnSensor;
+    turnSensor.start();
+    while(1)
+    {
+        turnSensor.update();
+        if (reportPacer.pace())
+        {
+            pc.printf("%d\r\n", turnSensor.getAngle());
+        }
+    }
 }
\ No newline at end of file