Inverted Pendulum / Mbed 2 deprecated IP-Interface

Dependencies:   mbed QEI

Revision:
17:2dc9abb76687
Parent:
16:b5862ba97453
--- a/main.cpp	Wed Nov 16 00:54:47 2016 +0000
+++ b/main.cpp	Wed Nov 16 02:09:40 2016 +0000
@@ -87,19 +87,40 @@
             motor.anticlockwise();
         } 
 }
+void disttopulse(int distance) //find amount of pulses to distance
+{
+    
+}
+void set_speed(int speed) // wait time correspondence to speed
+{
+        
+}
 
-void test_pulsetodist()
+void test_pulsetodist() // have user input x amount of pulses to move motor a certain distance
 {
     while(1)
     {
-        int pulses;
-        printf("Enter the amount of pulses: ");
-        scanf("%i",&pulses);
-        move_pulses(pulses);
+        char str[4];
+        int steps = 0;
+        int wait = 1000;
+        time_t start = time(0);
+        double elapsed;      
+        printf("Enter the amount of steps: ");
+        fgets(str,4,stdin);
+        printf("\r\nSteps: %s", str);
+        steps = atoi(str);
+        
+        if(steps > 0)
+            motor.step_clockwise(steps, wait);
+        else
+            motor.step_anticlockwise(steps, wait);
+        elapsed = difftime( time(0), start);
+        printf("\r\nTook %i steps in time: %f \r\n",steps, elapsed);
     }
 }
 int main() {
-    test_distance();
+    while(1)
+        printf("Pulses: %i\r\n", encoder.getPulses());
     //motor.step_clockwise(100,1500);
     //motor.step_clockwise(100,1000);
     //motor.step_clockwise(100,700);