TRR2018 omar

Dependencies:   mbed

Fork of biniou by TRR 2018

Revision:
49:6a939e2ffb32
Parent:
48:df2b4b6feceb
--- a/stateMachines.cpp	Thu Sep 20 18:56:13 2018 +0000
+++ b/stateMachines.cpp	Thu Sep 20 18:58:33 2018 +0000
@@ -221,24 +221,24 @@
 #if DEBUG > 0
     pc.printf("[BTN PRESSED]\r\n");
 #endif
-switch(dumped)
-{case 0:
-    PwmMotor.period_us(DIRECTION_PERIOD_MS);          //20 ms is default
-    PwmMotor.pulsewidth_us(1000);//MIN
-    wait(3);
-    PwmMotor.pulsewidth_us(2000);//MAX
-    wait(1);
-    PwmMotor.pulsewidth_us(1500);//ZEROING
-    wait(1);
-    pulseSpeed_us = INITAL_PULSE_SPEED_US;
-    p_sectionCourante = &p_section1;
-    initSamples();
-break;
-case 1:
-    transmitData();
-    break;
-    default:
-    break;
+    switch(dumped) {
+        case 0:
+            PwmMotor.period_us(DIRECTION_PERIOD_MS);          //20 ms is default
+            PwmMotor.pulsewidth_us(1000);//MIN
+            wait(3);
+            PwmMotor.pulsewidth_us(2000);//MAX
+            wait(1);
+            PwmMotor.pulsewidth_us(1500);//ZEROING
+            wait(1);
+            pulseSpeed_us = INITAL_PULSE_SPEED_US;
+            p_sectionCourante = &p_section1;
+            initSamples();
+            break;
+        case 1:
+            transmitData();
+            break;
+        default:
+            break;
     }
     dumped ++;
 }
@@ -783,7 +783,11 @@
 #if DEBUG > 2
             pc.printf("BRAKINGGGGGGGGGGGGGGGGGG !!! \r\n");
 #endif
-            pulseSpeed_us = BRAKING_PULSE_US;
+            if(tachySpeed_cmps > 0.0) {
+                pulseSpeed_us = BRAKING_PULSE_US;
+            } else {
+                pulseSpeed_us = ZERO_PULSE_SPEED_US;
+            }
             break;
         case STOPPED:
 #if DEBUG > 2