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:
40:6fa672be85ec
Parent:
39:b19dfc5d4d4b
Child:
41:3ead1dd2cc3a
--- a/test.cpp	Thu Jul 25 02:11:25 2019 +0000
+++ b/test.cpp	Thu Jul 25 02:53:34 2019 +0000
@@ -10,6 +10,8 @@
 #include "encoders.h"
 #include "pc_serial.h"
 #include "line_sensors.h"
+#include "l3g.h"
+#include "turn_sensor.h"
 #include "reckoner.h"
 #include "buttons.h"
 
@@ -306,6 +308,55 @@
     }
 }
 
+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.getAngleDegrees());
+        }
+    }
+}
+
+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 testLineSensors()
 {
     led1 = 1;
@@ -491,7 +542,6 @@
               determinant(), dotProduct());
        }
     }
-   
 }
 
 // with should be between 0 and 63