SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Branch:
Drift
Revision:
87:15fcf7891bf9
Parent:
65:295c222fdf88
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemovedSources/WheelEncoder.cpp.txt	Wed Apr 19 04:06:01 2017 +0000
@@ -0,0 +1,56 @@
+#if 0
+
+#include "WheelEncoder.h"
+#include "Core.h"
+#include "SWUSBServer.h"
+
+#include "PinAssignment.h"
+#include "SWUSBServer.h"
+
+#include "mbed.h"
+
+
+WheelEncoder::WheelEncoder(SW::Core& core) :
+    m_core(core),
+    m_intRL(InterruptIn(PIN_WE_RL)),
+    m_intRR(InterruptIn(PIN_WE_RR)),
+    m_rrDuration(1.0f),
+    m_rlDuration(1.0f)
+{
+    m_rrightTimer.start();
+    m_rleftTimer.start();
+    m_intRL.rise(callback(this, &WheelEncoder::pulseInRLeft));
+    m_intRR.rise(callback(this, &WheelEncoder::pulseInRRight));
+     
+}
+
+
+void WheelEncoder::Update(float deltaTime)
+{
+    //int rrHz = 1 / m_rrDuration;
+    //int rlHz = 1 / m_rlDuration;
+    
+    ///char buf[5];
+    //sprintf(buf, "RR: %d", rrHz);
+    ///m_core.GetUSBServer().PushUnreliableMsg('D', buf);
+    //sprintf(buf, "RL: %d", rlHz);
+    //m_core.GetUSBServer().PushUnreliableMsg('D', buf);
+}
+
+void WheelEncoder::pulseInRRight()
+{
+    m_rrDuration = m_rrightTimer.read();
+    m_rrightTimer.stop();
+    m_rrightTimer.reset();
+    m_rrightTimer.start();
+}
+    
+void WheelEncoder::pulseInRLeft()
+{
+    m_rlDuration = m_rleftTimer.read();
+    m_rleftTimer.stop();
+    m_rleftTimer.reset();
+    m_rleftTimer.start();
+}
+    
+#endif  //if 0
\ No newline at end of file