David Pasztor / Mbed 2 deprecated Motor_control

Dependencies:   mbed-rtos mbed

Revision:
49:731c95cd5852
Child:
51:bab6e5eb864a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands.h	Fri Mar 24 16:57:35 2017 +0000
@@ -0,0 +1,39 @@
+#include <vector>
+
+#include "mbed.h"
+#include "controlLoops.h"
+
+Ticker lifeTicker;
+
+volatile bool commandFinished = false;
+void stopCommand() {
+    commandFinished = true;
+    lifeTicker.detach();
+    controlTicker.detach();
+}
+
+void rotateWith(float r, float v) {
+
+}
+
+void setVelocity(float v) {
+//    targetV = v;
+//    goalRevs = 900.0f;
+//    print("Spinning with V=%.2f\n\r", targetV);
+
+    lifeTicker.attach(&stopCommand, 10);
+}
+
+void playTune(float freq) {
+    motorPWMPeriod = 1.0f / freq;
+//    motorOut(0, 0.5);
+    Thread::wait(1000);
+}
+
+void playTunes(const vector<float>& tunes) {
+    for (int i=0; i<tunes.size(); ++i) {
+        playTune(tunes[i]);
+    }
+//    motorPWMPeriod = defaultMotorPWMPeriod;
+    stopMotor();
+}
\ No newline at end of file