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:
16:8eaa5bc2bdb1
Parent:
11:bd14d512340a
Child:
17:2df9861f53ee
--- a/buttons.cpp	Mon Feb 24 00:21:05 2014 +0000
+++ b/buttons.cpp	Mon Feb 24 01:26:00 2014 +0000
@@ -1,8 +1,13 @@
 #include <mbed.h>
 #include "buttons.h"
+#include "GeneralDebouncer.h"
+
+#define BUTTON_DEBOUNCE_TIME 20000
 
 DigitalIn button1(p13);
 
+GeneralDebouncer button1Debouncer(5000);
+
 void buttonsInit()
 {
     button1.mode(PullUp);
@@ -11,4 +16,28 @@
 bool button1IsPressed()
 {
     return button1.read() == 0;
-}
\ No newline at end of file
+}
+
+void button1Montior()
+{
+    button1Debouncer.update(button1IsPressed());
+}
+
+bool button1DefinitelyInState(bool state)
+{
+    button1Montior();
+    return button1Debouncer.getState() == state &&
+      button1Debouncer.getTimeInCurrentStateMicroseconds() > BUTTON_DEBOUNCE_TIME;   
+}
+
+bool button1DefinitelyPressed()
+{
+    return button1DefinitelyInState(true);
+}
+
+bool button1DefinitelyReleased()
+{
+    return button1DefinitelyInState(false);
+}
+
+