Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PololuEncoder Pacer mbed GeneralDebouncer
Diff: test.cpp
- 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