FRC_equipe1 / Mbed 2 deprecated FRC_2019

Dependencies:   mbed

Revision:
8:94ecfe411d02
Parent:
7:753e901d441b
Child:
9:2113adf37c66
diff -r 753e901d441b -r 94ecfe411d02 main.cpp
--- a/main.cpp	Mon May 20 14:58:09 2019 +0000
+++ b/main.cpp	Thu May 23 13:54:45 2019 +0000
@@ -1,15 +1,24 @@
 #include "mbed.h"
 #include "CAN_asser.h"
 
+
+CAN can(PB_8, PB_9,1000000); 
+
+bool flagFinDpl = true;
+
+void automate_test();
+
 int main(void)
 {
     bool quit = false;
     
     can_init();
+    can.attach(&isr_can);
         
     while(!quit)
     {
-        trait_can();  
+        trait_can();
+        automate_test();
     }
     
     return 0;
@@ -17,23 +26,29 @@
 
 void automate_test()
 {
-    static typedef enum{AVANCE,TOURNE} type_etat;
-    type_etat etat = AVANCE;
+    typedef enum{AVANCE,TOURNE} type_etat;
+    static type_etat etat = AVANCE;
     
     switch(etat)
-    {
-    case AVANCE:
-        Gostraight(500,0,0,0);
-        
-        if(FlagFinDpl)
-            etat = TOURNE;        
-        break;
-        
-    case TOURNE:
-        Rotate(900);
-        
-        if(FlagFinDpl)
-            etat = AVANCE;
-        break;
+    {            
+        case AVANCE:
+            
+            if(flagFinDpl)
+            {
+                Rotate(900);
+                etat = TOURNE;
+                flagFinDpl = false;
+            }
+            break;
+            
+        case TOURNE:
+            
+            if(flagFinDpl)
+            {
+                GoStraight(500,0,0,0);
+                etat = AVANCE;
+                flagFinDpl = false;
+            }
+            break;
     }
 }
\ No newline at end of file