jordy morsinkhof / Mbed 2 deprecated Handmatig

Dependencies:   USBHost USBHostXpad mbed-rtos mbed

Fork of x4180_Tank by C K

Revision:
0:79485480cd7e
Child:
2:5e870c215495
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Traxster.cpp	Thu Nov 13 23:20:02 2014 +0000
@@ -0,0 +1,33 @@
+
+#include "Traxster.h"
+#include "utils.h"
+
+int getMotorSpeedInt(float f){
+    
+    int max = 100;
+    
+    if(f > 1.0)
+        f = 1.0;
+
+    if(f < -1.0)
+        f = -1.0;
+    
+    return   (int)round( (float)max * f );
+}
+
+void Traxster::SetMotors(float fm1, float fm2)
+{
+    int m1 = getMotorSpeedInt(fm1);
+    int m2 = getMotorSpeedInt(fm2);
+    
+    if (m1 == 0 && m2 == 0)
+    {
+        rob.puts("stop\r");
+    }
+    else
+    {
+        rob.printf("mogo 1:%d 2:%d\r", m1, m2);
+    }
+    while (rob.readable())
+        rob.getc();
+}