for Bertl2014 HTL-Graz-Göoesting

Revision:
1:18c4a2bc1228
Parent:
0:50c6cfc49ead
--- a/Steuerung.cpp	Tue Dec 29 11:16:51 2015 +0000
+++ b/Steuerung.cpp	Mon Jan 11 12:16:19 2016 +0000
@@ -10,13 +10,19 @@
 DigitalOut MotorR_FORWARD(P1_3); 
 DigitalOut MotorR_REVERSE(P1_4);
 
-void bertl_engine (int left, int right)
-{    
-    MotorL_EN = MotorR_EN = 1;      
+void period_ms(int ms) 
+{
+    MotorL_EN.period_ms(ms);
+    MotorR_EN.period_ms(ms);
+}
+
+void bertl_engine(int left, int right, int seconds)
+{          
     
-    int index_Engine = 0;
-    
-         if (left > 0 && right > 0)  // decleration for left and right engine
+   /* int index_Engine = 0;
+                
+    // decleration for left and right engine
+         if (left > 0 && right > 0)  
             index_Engine = 1;
         
         else if (left < 0 && right > 0)
@@ -45,16 +51,20 @@
 switch (index_Engine)  //begin Switch
    { 
         case 1:
-            MotorR_EN = 1;
-            MotorL_EN = 1;
+            MotorR_EN.pulsewidth_ms(seconds); 
+            MotorL_EN.pulsewidth_ms(seconds);
+            MotorL_REVERSE = 0;
+            MotorR_REVERSE = 0;
             MotorL_FORWARD = 1;
-            MotorR_FORWARD = 1;           
+            MotorR_FORWARD = 1;    
        
         break;
             
         case 2:
             MotorR_EN = 1;
             MotorL_EN = 1;
+            MotorL_FORWARD = 0;
+            MotorR_REVERSE = 0;
             MotorL_REVERSE = 1;
             MotorR_FORWARD = 1;           
         break;
@@ -62,6 +72,8 @@
         case 3:
             MotorR_EN = 1;
             MotorL_EN = 1;
+            MotorL_REVERSE = 0;
+            MotorR_FORWARD = 0;
             MotorL_FORWARD = 1;
             MotorR_REVERSE = 1;            
         break;
@@ -69,6 +81,8 @@
         case 4:
             MotorR_EN = 1;
             MotorL_EN = 1;
+            MotorL_FORWARD = 0;
+            MotorR_FORWARD = 0;
             MotorL_REVERSE = 1;
             MotorR_REVERSE = 1;       
         break;  
@@ -76,24 +90,28 @@
         case 5:
             MotorL_EN = 0;
             MotorR_EN = 1;
+            MotorR_FORWARD = 0;
             MotorR_REVERSE = 1;
         break;  
         
         case 6:
             MotorL_EN = 0;
             MotorR_EN = 1;
+            MotorR_REVERSE = 0;
             MotorR_FORWARD = 1;
         break; 
     
          case 7:
             MotorR_EN = 0;
-            MotorR_EN = 1;
+            MotorL_EN = 1;
+            MotorL_FORWARD = 0;
             MotorL_REVERSE = 1;          
         break;    
  
          case 8:
             MotorR_EN = 0;
             MotorL_EN = 1;
+            MotorL_REVERSE = 0;
             MotorL_FORWARD = 1;                    
          break;    
          
@@ -101,5 +119,5 @@
             MotorR_EN = 0;
             MotorL_EN = 0;
          break;
-    }//end Switch 
-}//end bertl_engine
\ No newline at end of file
+    }//end Switch */
+}//end bertl_engine 
\ No newline at end of file