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:
26:a2fe19341f92
Parent:
25:322ef9488e65
Child:
27:1b1fd20a2793
diff -r 322ef9488e65 -r a2fe19341f92 main.cpp
--- a/main.cpp	Mon Feb 12 07:23:24 2018 +0000
+++ b/main.cpp	Tue Feb 13 08:34:12 2018 +0000
@@ -167,7 +167,7 @@
 float Consigne_fuite = 0;
 float volet_fuite_Position = 0;
 float Volets_Speed = 0.1;
-float Volet_DeadBand = 1;
+float Volet_DeadBand = 5;
 
 #ifdef PID_MODE
 //Paramètre du PID
@@ -242,17 +242,13 @@
     //printf("  position volet fuite sauvegardée = %d pulse(s)\r\n", Pos);
     UTILS::UnMount_SD();
     Servo_Poumon.Sleep();
-    //thread_Volets.terminate();
 }
 
 //Sequence d'arrêt
 void Stop_Sequence()
 {
-    Mode_SECU();
-    //thread_Sensors.terminate();
-    //wait_ms(300);
+    Mode_SECU();  
     printf("----------------ARRET DE L'APPAREIL--------------------\r\n");
-    //wait_ms(300);
     deepsleep();
 }
 
@@ -321,7 +317,7 @@
 {
     while (true) {
         //Servo_Poumon.Go_To_Prop(Consigne_poumon);
-        //Servo_Poumon.Go_To_PID(Consigne_poumon);
+        //Servo_Poumon.Go_To_PID(Consigne_poumon, Volet_DeadBand);
         Servo_Poumon.Go_To(Consigne_poumon, Volets_Speed, Volet_DeadBand );
         
         //Servo_Fuite.Go_To_Prop(Consigne_fuite);
@@ -406,6 +402,12 @@
 
     if ((char)commande == 'S') {
         Mode_SECU();
+    }else if ((char)commande == 'D') {
+        UTILS::DIR_SD();
+    }else if ((char)commande == 'U') {
+        char filename[20];
+        sprintf(filename, "LOG_%d.txt", (int)valeur);
+        UTILS::Read_SD_File(filename);    
     } else if ((char)commande == 'r') {
         Consigne_poumon = 0;
         volet_poumon_Position = 0;
@@ -449,8 +451,6 @@
     } else if ((char)commande == 'I') {
         Consigne_poumon = (float)valeur;
         printf("  Servo Poumon    = %f\r\n", Consigne_poumon);
-    }else if ((char)commande == 'D') {
-        UTILS::DIR_SD();
     } else if ((char)commande == 'O') {
         Consigne_fuite = (float)valeur;
         printf("  Servo Fuite     =  %f\r\n", Consigne_fuite);
@@ -491,7 +491,7 @@
     newAndroidFlag = false;
 }
 
-void Create_File_Name()
+void Create_File_Name_Date()
 {
     //Du nom du fichier Date / heure
     seconds = time(NULL);
@@ -502,6 +502,13 @@
     
     }
     
+void Create_File_Name_Index()
+{
+    //Du nom du fichier par Index
+    sprintf(Log_File_Name, "LOG_%d.txt", UTILS::File_Index());
+    printf("  Nouveau fichier LOG = %s \r\n", Log_File_Name);    
+    }
+    
 int main()
 {
    button.fall(&pressed);
@@ -521,6 +528,22 @@
 
     android.attach(&callbackAndroid, Serial::RxIrq);
 
+    //Ci-dessous commande pour formater une nouvelle carte
+    //UTILS::Format_SD();
+
+    //Montage carte SD 
+    UTILS::Mount_SD();
+    
+    //Liste des fichiers sur la carte sd
+    UTILS::Dir_SD();
+    
+    bool calib_O2 = false;
+    bool calib_CO2 = false;
+    
+    if(UTILS::File_Exist("Calibration_O2") == false) {
+    calib_O2 = true;
+    }
+    
     /*
     Par défaut les valeur en cas de calibration sur true sont les suivant
 
@@ -540,15 +563,17 @@
        sensors.Sensors_INIT(true, true, true, 5, SPOOLING, DIGI_FILTER32, CALIB_AIR);
 
     */
-    sensors.Sensors_INIT(false, false);
+    Servo_Poumon.Init("Servo_Poumon");
+    //Servo_Fuite.Init();
+    
+    sensors.Sensors_INIT(calib_O2, calib_CO2);
 
     wait(1);
-
-    Servo_Poumon.Init();
-    //Servo_Fuite.Init();
     
-    Create_File_Name();
-
+    //Création du nouveau fichier LOG par index / par date.
+    Create_File_Name_Index();
+    //Create_File_Name_Date()
+    
     serialMonit.printf("  Demarrage des threads...\r\n\r\n");
 
     /*
@@ -662,7 +687,6 @@
 
         //Enregistrement de la chaine
         UTILS::Write_SD_File(to_store, Log_File_Name);
-        printf("Fichier LOG = %s \r\n", Log_File_Name);
 
         //Pour Android on ajoute < et > pour décoder l'arrivée du message
         if (NEED_ANDROID_OUTPUT == 1) {