mbed-os github

Dependencies:   ADS1015 Faulhaber HTU21D_mod MS5837_potless Sensor_Head_RevB_3 USBDevice_dfu Utilsdfu beep

Fork of ARNSRS_testDFU by POTLESS

Revision:
21:b8900130ca05
Parent:
20:5f79fb4565a7
Child:
22:555c2930e8e0
diff -r 5f79fb4565a7 -r b8900130ca05 main.cpp
--- a/main.cpp	Wed Feb 07 14:52:47 2018 +0000
+++ b/main.cpp	Wed Feb 07 19:24:11 2018 +0000
@@ -174,6 +174,16 @@
 AnalogIn V_USB(PC_4);
 float Vusb = 1;
 
+//Interruption user button
+InterruptIn button(USER_BUTTON);
+volatile bool  GO = false;
+
+void pressed() {
+ 
+  if (GO == false) GO = true;
+    
+}
+
 //Passage en mode SECU
 void Mode_SECU()
 {
@@ -197,6 +207,7 @@
     //Pos = Servo_Fuite.getPulses();
     //UTILS::Store_A_Val((float)Pos, "Servo_Fuite");
     //printf("  position volet fuite sauvegardée = %d pulse(s)\r\n", Pos);
+    Servo_Poumon.Sleep();
     thread_Volets.terminate();
 }
 
@@ -204,10 +215,11 @@
 void Stop_Sequence()
 {
     Mode_SECU();
-    thread_Sensors.terminate();
+    wait(1);
+    //thread_Secu.terminate();
+    //thread_Sensors.terminate();
     printf("----------------ARRET DE L'APPAREIL--------------------\r\n");
-    Servo_Poumon.Sleep();
-    wait(2);
+    //wait(2);
     deepsleep();
 }
 
@@ -444,6 +456,19 @@
 
 int main()
 {
+   button.fall(&pressed);
+   int count = 0;
+   
+   while (1) { 
+   
+   if (count == 0) serialMonit.printf("Appuyez sur le User Button pour commencer...\r\n");
+   
+   count = 1;
+   
+    if (GO == true) {
+    
+    wait(1);
+        
     serialMonit.attach(&callbackParam, Serial::RxIrq);
 
     android.attach(&callbackAndroid, Serial::RxIrq);
@@ -493,14 +518,20 @@
     thread_Sensors.start(Get_Info_thread);
 
     thread_Sensors.set_priority(osPriorityNormal);
+    
+    wait_ms(300);
 
     thread_Volets.start(GO_TO_thread);
 
     thread_Volets.set_priority(osPriorityNormal);
     
+    wait_ms(300);
+    
     thread_Secu.start(SECU_thread);
 
     thread_Secu.set_priority(osPriorityNormal);
+    
+    wait_ms(300);
 
 #ifdef PID_MODE
     //Init PID
@@ -619,5 +650,7 @@
         }
 
         wait_ms(RATE_TRUE);
-    }
+    }    
+  }
+  }
 }