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: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: RemovedSources/WheelEncoder.cpp.txt
- 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
