complete motor

Dependencies:   BufferedSerial motor_sn7544

Revision:
3:0c6258635590
Parent:
2:a04440f0d001
Child:
4:a72f75611198
--- a/main.cpp	Thu May 23 23:04:30 2019 +0000
+++ b/main.cpp	Tue Jun 25 11:01:49 2019 +0000
@@ -26,15 +26,16 @@
     }
 }
 
-int set_speed(void)
+void set_speed(void)
 {
     int speed;
     speed = atoi((const char*)rx_buffer);
     if(speed>78){speed=78;}
     if(speed<-78){speed=-78;}
     motor1.setTarget(speed);
+  //  motor1.setTarget(60);
     pc.printf(" Set speed = %d\r\n", speed);
-    return speed;
+    
 }
 
 int main()
@@ -45,15 +46,19 @@
     tachoINT2.rise(&update_current);
     pc.attach(callback(rx_cb));
     int rpm;
+    float distance;
 
     while(1) {
         flag=0;
+        
         pc.printf("Enter the value for speed [-78,78]\r\n");
         while(flag!=1) {
             rpm=motor1.getRPM();
-            pc.printf("rpm = %d\r\n",rpm);
+            distance=motor1.CalculateCumDis();
+            printf("distance: %f\r\n",distance);
             wait(1);
         }
+//        motor1.setTarget(60);
         set_speed();
     }