V1

Dependencies:   BufferedSerial sn7544

Fork of GPG_motor by Kang mingyo

Files at this revision

API Documentation at this revision

Comitter:
kangmingyo
Date:
Thu Jun 27 04:05:20 2019 +0000
Parent:
4:a72f75611198
Child:
6:2478c5817b47
Commit message:
v2

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Jun 25 11:07:15 2019 +0000
+++ b/main.cpp	Thu Jun 27 04:05:20 2019 +0000
@@ -13,12 +13,13 @@
     motor1.UpdateCurrentPosition();
     //  pc.printf("Update Position\r\n");
 }
-void rx_cb(void){
+void rx_cb(void)
+{
     char ch;
     ch = pc.getc();
     pc.putc(ch);
     rx_buffer[index++]=ch;
-    if(ch==0x0D){
+    if(ch==0x0D) {
         pc.putc(0x0A);
         rx_buffer[--index]='\0';
         index=0;
@@ -30,12 +31,16 @@
 {
     int speed;
     speed = atoi((const char*)rx_buffer);
-    if(speed>78){speed=78;}
-    if(speed<-78){speed=-78;}
+    if(speed>78) {
+        speed=78;
+    }
+    if(speed<-78) {
+        speed=-78;
+    }
     motor1.setTarget(speed);
-  //  motor1.setTarget(60);
+    //  motor1.setTarget(60);
     pc.printf(" Set speed = %d\r\n", speed);
-    
+
 }
 
 int main()
@@ -51,14 +56,14 @@
 
     while(1) {
         flag=0;
-        
+
         pc.printf("Enter the value for speed [-78,78]\r\n");
         while(flag!=1) {
             rpm = motor1.getRPM();
             cumdistance = motor1.CalculateCumDis(); //  누적거리
             reladistance = motor1.CalculateRelaDis(); // 상대거리
-            
-            
+
+
             printf("Rpm: %f\r\n",distance);
             printf("cumdistance: %f\r\n",cumdistance);
             printf("reladistance: %f\r\n",reladistance);