MDC3.0 rs-485 コントロールプログラム can も追加予定.... 詳細はwiki バグレポートは中田くんに,やさしく教えてください(煽り禁止)

Dependents:   quadOmni_yanagi NHK2017_octopus ikarashiMDCmaster NHK2017_octopus2 ... more

Revision:
4:d6f0b74affd7
Parent:
2:75153205d6e8
Child:
6:342e3a4f4a8d
--- a/ikarashiMDC.cpp	Tue Aug 22 01:55:17 2017 +0000
+++ b/ikarashiMDC.cpp	Mon Aug 28 12:56:38 2017 +0000
@@ -13,22 +13,23 @@
 
 int ikarashiMDC::setSpeed(const double& speed)
 {
-    uint8_t data[4],dataSpeed;
+    uint8_t data[3],dataSpeed;
+    double cropped_speed;
     //Limiter
-    const double cropped_speed = -1 < speed ?
-                                  1 > speed ?
-                                  speed:1
-                                  :-1;
-
+    if(speed > 1.0)
+        cropped_speed = 1.0;
+    if(speed < -1.0)
+        cropped_speed = -1.0;
+    cropped_speed =speed;
     //dataspeed 0~253 neutaral 126
     dataSpeed = ((cropped_speed+1.0)/2.0)*253;
-    //printf("%d\n",dataSpeed);
+    printf("%d\n",dataSpeed);
     //set sending data
     data[0] = 255; //header
     data[1] = (addr<<5) + motorNum + (mode<<4); //address
     data[2] = dataSpeed;
     //send data
-    for(int i=0; i<4; i++) {
+    for(int i=0; i<3; i++) {
         serial->putc(data[i]);
     }
     return 0;