Time is good

Dependencies:   RoboClaw mbed

Fork of Robot2016_2-0 by ARES

Revision:
92:f09f55aa992b
Parent:
91:65fb6b9f3932
Child:
93:c0b040954eac
--- a/main.cpp	Fri May 06 13:36:06 2016 +0000
+++ b/main.cpp	Fri May 06 15:25:21 2016 +0000
@@ -1,4 +1,5 @@
 #include "entete.h"
+
 #include "AX12/AX12.h"
 
 DigitalIn CAMP(PA_15);
@@ -24,34 +25,7 @@
 /* Debut du programme */
 int main(void)
 {
-    roboclaw.ForwardM1(0);
-    roboclaw.ForwardM2(0);
-    Ticker ticker;
-    Timeout end;
-    ticker.attach(&Sharps, 0.01);
 
-    umbrella.setMode(0);
-    umbrella.setMaxTorque(200);
-    umbrella.setGoal(150);
-    wait(1);
-    umbrella.setGoal(160);
-    wait(1);
-    umbrella.setGoal(150);
-    wait(1);
-    umbrella.setMaxTorque(0);
-    
-    while(START == 1)
-    {
-        LEDR = 1;
-        LEDV = 1;
-        wait(0.5);
-        LEDR = 0;
-        LEDV = 0;
-        wait(0.5);
-    }
-   
-    wait(1);
-    depart();
     
     if (SCouleur == VERT) {
         end.attach(&endFonc, 90);
@@ -70,7 +44,7 @@
         GotoDist(3.5);
         GotoThet(-3.04);
         R_SEUIL_SHARP = 1; 
-        GotoDist(4.1);
+        GotoDist(4.5);
     }
     else if (SCouleur == VIOLET) {  
         end.attach(&endFonc, 90);
@@ -89,7 +63,7 @@
         GotoDist(3.5);
         GotoThet(3.04);
         R_SEUIL_SHARP = 1; 
-        GotoDist(4.1);
+        GotoDist(4.5);
     }
     else if (SCouleur == NOIR) {
         TestDist3(2,2);
@@ -135,3 +109,34 @@
     umbrella.setGoal(300);
     while(1);
 }
+
+void init() {
+    roboclaw.ForwardM1(0);
+    roboclaw.ForwardM2(0);
+    Ticker ticker;
+    Timeout end;
+    ticker.attach(&Sharps, 0.01);
+
+    umbrella.setMode(0);
+    umbrella.setMaxTorque(200);
+    umbrella.setGoal(150);
+    wait(1);
+    umbrella.setGoal(160);
+    wait(1);
+    umbrella.setGoal(150);
+    wait(1);
+    umbrella.setMaxTorque(0);
+    
+    while(START == 1)
+    {
+        LEDR = 1;
+        LEDV = 1;
+        wait(0.5);
+        LEDR = 0;
+        LEDV = 0;
+        wait(0.5);
+    }
+   
+    wait(1);
+    depart();
+}