mbed-os github

Dependencies:   ADS1015 Faulhaber HTU21D_mod MS5837_potless Sensor_Head_RevB_3 USBDevice_dfu Utilsdfu beep

Fork of ARNSRS_testDFU by POTLESS

Committer:
POTLESS_2
Date:
Wed May 30 13:02:01 2018 +0000
Revision:
51:16a055fd287c
Parent:
49:a7432da60647
Child:
52:4e36a88711d6
dfu qui marche ???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
potless 1:bef7856b5c0a 1 #include "mbed.h"
potless 2:4a8bf1d53439 2 #include <string>
POTLESS_2 7:ad15c386e960 3 #include "Sensor_head_revB.h"
POTLESS_2 8:a750d531b381 4 #include "HTU21D.h"
POTLESS_2 12:7f3aadd79f89 5 #include "PID.h"
POTLESS_2 19:cac3761a5d0b 6 #include "Faulhaber.h"
POTLESS_2 29:5b822d18bce6 7 #include "Utils.h"
POTLESS_2 47:89a088bc8866 8 #include "beep.h"
POTLESS_2 47:89a088bc8866 9 #include "USBSerial.h"
POTLESS_2 4:d84250f67dec 10
potless 48:9ceb095f397a 11
POTLESS_2 17:bef8abc445f2 12 //Commandes des servos
potless 45:61ba3cc4fc55 13
potless 45:61ba3cc4fc55 14 DigitalOut E5V (PA_4);
POTLESS_2 19:cac3761a5d0b 15 #define PWM_SERVO_POUMON PB_15
POTLESS_2 19:cac3761a5d0b 16 #define nSleep_SERVO_POUMON PC_6
POTLESS_2 19:cac3761a5d0b 17 #define FWD_SERVO_POUMON PB_14
POTLESS_2 19:cac3761a5d0b 18 #define REV_SERVO_POUMON PB_13
POTLESS_2 43:5ae8baf28e32 19 #define Channel_A_SERVO_POUMON PB_2
POTLESS_2 43:5ae8baf28e32 20 #define Channel_B_SERVO_POUMON PB_1
POTLESS_2 19:cac3761a5d0b 21 #define HOME_SERVO_POUMON 0
POTLESS_2 17:bef8abc445f2 22
POTLESS_2 19:cac3761a5d0b 23 #define PWM_SERVO_FUITE PB_10
POTLESS_2 43:5ae8baf28e32 24 #define nSleep_SERVO_FUITE PB_0
POTLESS_2 19:cac3761a5d0b 25 #define FWD_SERVO_FUITE PB_4
POTLESS_2 19:cac3761a5d0b 26 #define REV_SERVO_FUITE PB_5
POTLESS_2 43:5ae8baf28e32 27 #define Channel_A_SERVO_FUITE PC_9
POTLESS_2 43:5ae8baf28e32 28 #define Channel_B_SERVO_FUITE PA_8
POTLESS_2 19:cac3761a5d0b 29 #define HOME_SERVO_FUITE 90
POTLESS_2 17:bef8abc445f2 30
POTLESS_2 43:5ae8baf28e32 31 //Pin de test des alims
POTLESS_2 43:5ae8baf28e32 32 #define PIN_V_PILES_ANALOG PA_1
POTLESS_2 43:5ae8baf28e32 33 #define PIN_V_PILES_DIGI PC_3
POTLESS_2 43:5ae8baf28e32 34 #define PIN_V_USB_DIGI PA_0
POTLESS_2 11:b2feed92584a 35
POTLESS_2 51:16a055fd287c 36 USBSerial serialMonit;
POTLESS_2 51:16a055fd287c 37
potless 44:5cd6f84a62ec 38 //#define OUTPUT(...) { NVIC_DisableIRQ(USART3_IRQn); serialMonit.printf(__VA_ARGS__); fflush(stdout);NVIC_EnableIRQ(USART3_IRQn);}
potless 44:5cd6f84a62ec 39 #define OUTPUT(...) { NVIC_DisableIRQ(USART2_IRQn); serialMonit.printf(__VA_ARGS__); fflush(stdout);NVIC_EnableIRQ(USART2_IRQn);}
POTLESS_2 46:28298df0ac55 40 #define IHM(...) { NVIC_DisableIRQ(USART3_IRQn); display.printf(__VA_ARGS__); fflush(stdout);NVIC_EnableIRQ(USART3_IRQn);}
POTLESS_2 34:26f6e3dbefb9 41
POTLESS_2 25:322ef9488e65 42 //PinName pwm, PinName nSleep, PinName fwd, PinName rev, PinName channelA, PinName channelB, int pulsesPerRev, int Rapport, Encoding encoding = X2_ENCODING
POTLESS_2 25:322ef9488e65 43 Faulhaber Servo_Poumon("Servo_Poumon", PWM_SERVO_POUMON, nSleep_SERVO_POUMON, FWD_SERVO_POUMON, REV_SERVO_POUMON, Channel_A_SERVO_POUMON, Channel_B_SERVO_POUMON, 16, 207, Faulhaber::X2_ENCODING);
POTLESS_2 43:5ae8baf28e32 44 Faulhaber Servo_Fuite("Servo_Fuite", PWM_SERVO_FUITE, nSleep_SERVO_FUITE, FWD_SERVO_FUITE, REV_SERVO_FUITE, Channel_A_SERVO_FUITE, Channel_B_SERVO_FUITE, 16, 207, Faulhaber::X2_ENCODING);
POTLESS_2 17:bef8abc445f2 45
POTLESS_2 17:bef8abc445f2 46 //Moniteur série, Serial 2
potless 45:61ba3cc4fc55 47 //Serial serialMonit(PC_10, PC_11, 115200); // UART 3 pour windev nucleo - version définitive sur uart3 pour carte ARNSRS
POTLESS_2 47:89a088bc8866 48 //Serial serialMonit(PA_2, PA_3,115200); // UART2 à décommenter pour carte ARNSRS
POTLESS_2 47:89a088bc8866 49
potless 49:a7432da60647 50
POTLESS_2 10:aca745a66d51 51
POTLESS_2 43:5ae8baf28e32 52 //Communication avec l'IHM
POTLESS_2 46:28298df0ac55 53 Serial display(PC_4, PC_5, 115200);
POTLESS_2 43:5ae8baf28e32 54
POTLESS_2 43:5ae8baf28e32 55 //Moniteur pour le debug avec une nucleo, a commenter avec la carte definitive
potless 44:5cd6f84a62ec 56 //Serial serial(USBTX, USBRX, 115200);
POTLESS_2 4:d84250f67dec 57
POTLESS_2 7:ad15c386e960 58 //Init de la lib ARNSRS;
POTLESS_2 7:ad15c386e960 59 SENSOR_HEAD_REV_B sensors;
potless 2:4a8bf1d53439 60
POTLESS_2 34:26f6e3dbefb9 61 //pour Param Venant du PV
POTLESS_2 42:3591ec9903b4 62 const int sizeParam = 50;
POTLESS_2 11:b2feed92584a 63 char param[sizeParam];
POTLESS_2 11:b2feed92584a 64 volatile int indexParam = 0;
POTLESS_2 6:ebed9093d661 65 bool newParamFlag = false;
potless 2:4a8bf1d53439 66
POTLESS_2 43:5ae8baf28e32 67 //Flag PID ON / OFF
POTLESS_2 43:5ae8baf28e32 68 int FLAG_PID = 0;
POTLESS_2 42:3591ec9903b4 69
POTLESS_2 42:3591ec9903b4 70 //Flag pour interrompre l'affichage si on veut...
POTLESS_2 42:3591ec9903b4 71 bool FLAG_AFF = false;
POTLESS_2 25:322ef9488e65 72
POTLESS_2 40:32d89e04ead1 73 //Flag pour envoyer à l'app windev...
POTLESS_2 40:32d89e04ead1 74 bool FLAG_WINDEV = false;
POTLESS_2 40:32d89e04ead1 75
POTLESS_2 43:5ae8baf28e32 76 //Flag pour envoyer à l'IHM...
POTLESS_2 46:28298df0ac55 77 bool FLAG_DISPLAY = true;
POTLESS_2 43:5ae8baf28e32 78
POTLESS_2 29:5b822d18bce6 79 //Flag pour interrompre l'enregistrement si on veut...
POTLESS_2 29:5b822d18bce6 80 bool FLAG_REC = true;
POTLESS_2 29:5b822d18bce6 81
POTLESS_2 33:f5d4bae05f16 82 //Flag pour interrompre les demandes O2 en cours ed calibration...
POTLESS_2 33:f5d4bae05f16 83 bool FLAG_O2 = true;
POTLESS_2 33:f5d4bae05f16 84
POTLESS_2 7:ad15c386e960 85 //Variables de stockage des infos capteurs
POTLESS_2 7:ad15c386e960 86 int co2 = 0;
POTLESS_2 7:ad15c386e960 87 float pression = 0;
POTLESS_2 9:04bfdfc029cb 88 float Temp1 = 0;
POTLESS_2 7:ad15c386e960 89 int ppO2 = 0;
POTLESS_2 7:ad15c386e960 90 int CellO2_1 = 0;
POTLESS_2 7:ad15c386e960 91 int CellO2_2 = 0;
POTLESS_2 36:1f5e2247b073 92
POTLESS_2 18:bfd78c05b589 93 //Variables et constantes OTU
POTLESS_2 18:bfd78c05b589 94 float OTU = 0;
POTLESS_2 18:bfd78c05b589 95 float COEF_OTU = 0.83;
POTLESS_2 18:bfd78c05b589 96
POTLESS_2 17:bef8abc445f2 97 //Mesure du temps d'éxecution du loop
POTLESS_2 7:ad15c386e960 98 Timer REAL_RATE;
POTLESS_2 7:ad15c386e960 99 float RATE = 0;
POTLESS_2 11:b2feed92584a 100 float RATE_TRUE = 0;
POTLESS_2 29:5b822d18bce6 101 float Ref_Time = 2.0; //La durée de la boucle désirée...
POTLESS_2 7:ad15c386e960 102
POTLESS_2 17:bef8abc445f2 103 //HTU21D sur l'I2C
POTLESS_2 8:a750d531b381 104 HTU21D temphumid(PB_9, PB_8); //Temp humid sensor || SDA, SCL
POTLESS_2 9:04bfdfc029cb 105 float Temp2;
POTLESS_2 9:04bfdfc029cb 106 int Humid;
POTLESS_2 9:04bfdfc029cb 107
POTLESS_2 9:04bfdfc029cb 108 //Data LOG
POTLESS_2 9:04bfdfc029cb 109 char to_store[50];
POTLESS_2 9:04bfdfc029cb 110 time_t seconds;
POTLESS_2 25:322ef9488e65 111 char Log_File_Name[] = " ";
POTLESS_2 42:3591ec9903b4 112 int count = 0;
POTLESS_2 42:3591ec9903b4 113 int Max_Log_Size = 1800;//1 heure, 1800 lignes donc à multiplier par la fréquence d'enregistrement, Ref_Time, pour voir combien de temps représente un Log...
POTLESS_2 8:a750d531b381 114
POTLESS_2 10:aca745a66d51 115 //Contrôle des servos
POTLESS_2 19:cac3761a5d0b 116 float Consigne_poumon = 0;
POTLESS_2 19:cac3761a5d0b 117 float volet_poumon_Position = 0;
POTLESS_2 19:cac3761a5d0b 118 float Consigne_fuite = 0;
POTLESS_2 19:cac3761a5d0b 119 float volet_fuite_Position = 0;
potless 45:61ba3cc4fc55 120 float Volets_Speed = 1;
POTLESS_2 26:a2fe19341f92 121 float Volet_DeadBand = 5;
POTLESS_2 10:aca745a66d51 122
POTLESS_2 12:7f3aadd79f89 123 //Paramètre du PID
POTLESS_2 12:7f3aadd79f89 124 float Kc = 40;
POTLESS_2 12:7f3aadd79f89 125 float Ti = 0;
POTLESS_2 12:7f3aadd79f89 126 float Td = 0;
POTLESS_2 12:7f3aadd79f89 127 float RATE_PID = Ref_Time;
POTLESS_2 12:7f3aadd79f89 128 float Commande_PID;
POTLESS_2 43:5ae8baf28e32 129 int consigne = 210;
POTLESS_2 15:efd3b3bf3f37 130 float Max_Input = 1000;
POTLESS_2 15:efd3b3bf3f37 131 float Min_Input = 80;
POTLESS_2 19:cac3761a5d0b 132 float Max_Output = 85;//Vérifier la valeur pour angle à laisser ouvert...
POTLESS_2 19:cac3761a5d0b 133 float Min_Output = 5;
POTLESS_2 10:aca745a66d51 134
POTLESS_2 12:7f3aadd79f89 135 //Init PID
POTLESS_2 17:bef8abc445f2 136 PID control_Servo(Kc, Ti, Td, RATE_PID);
POTLESS_2 10:aca745a66d51 137
POTLESS_2 19:cac3761a5d0b 138 //Boolean du status de l'appareil, en mode SECU ou nominal
POTLESS_2 19:cac3761a5d0b 139 bool EN_MODE_SECU = false;
POTLESS_2 31:231a96d1d1c8 140
POTLESS_2 31:231a96d1d1c8 141 //Test des alim
POTLESS_2 46:28298df0ac55 142 //DigitalIn V_PILES_DIGI(PIN_V_PILES_DIGI);
POTLESS_2 39:65ff3c4f9675 143
POTLESS_2 43:5ae8baf28e32 144 //Test voltage piles
POTLESS_2 43:5ae8baf28e32 145 AnalogIn V_PILES_ANALOG(PIN_V_PILES_ANALOG);
POTLESS_2 31:231a96d1d1c8 146
POTLESS_2 31:231a96d1d1c8 147 int Vusb = 1;
POTLESS_2 31:231a96d1d1c8 148 int VPiles = 1;
POTLESS_2 43:5ae8baf28e32 149 float VPiles_val = 1;
POTLESS_2 18:bfd78c05b589 150
potless 48:9ceb095f397a 151
POTLESS_2 43:5ae8baf28e32 152 //Interruption pin
POTLESS_2 43:5ae8baf28e32 153 InterruptIn vpile_off_on(PIN_V_PILES_DIGI);
POTLESS_2 43:5ae8baf28e32 154 InterruptIn vusb_off_on(PIN_V_USB_DIGI);
POTLESS_2 21:b8900130ca05 155
POTLESS_2 47:89a088bc8866 156 //Buzzer
POTLESS_2 47:89a088bc8866 157 Beep buzzer(PC_8);
POTLESS_2 47:89a088bc8866 158
POTLESS_2 47:89a088bc8866 159
POTLESS_2 29:5b822d18bce6 160 void Affichage()
potless 49:a7432da60647 161 {
POTLESS_2 42:3591ec9903b4 162 //serialMonit.printf("\r\n");
POTLESS_2 29:5b822d18bce6 163 serialMonit.printf(" CO2 = %d ppm\r\n" , co2);
POTLESS_2 29:5b822d18bce6 164 serialMonit.printf(" PPO2 = %d mb\r\n", ppO2);
POTLESS_2 31:231a96d1d1c8 165 serialMonit.printf(" OTU = %d \r\n", (int)OTU);
POTLESS_2 29:5b822d18bce6 166 serialMonit.printf(" Pression = %f msw\r\n", pression);
POTLESS_2 29:5b822d18bce6 167 serialMonit.printf(" Temp MS5837 = %f C\r\n", Temp1);
POTLESS_2 29:5b822d18bce6 168 serialMonit.printf(" Temp HTU21D = %f C\n\r", Temp2);
POTLESS_2 29:5b822d18bce6 169 serialMonit.printf(" Humidity = %d %%\n\r", Humid);
POTLESS_2 42:3591ec9903b4 170 //serialMonit.printf("\n\r");
POTLESS_2 29:5b822d18bce6 171 serialMonit.printf(" Cell O2 n 1 = %d\r\n" , CellO2_1);
POTLESS_2 29:5b822d18bce6 172 serialMonit.printf(" Cell O2 n 2 = %d\r\n" , CellO2_2);
POTLESS_2 42:3591ec9903b4 173 //serialMonit.printf("\r\n");
POTLESS_2 29:5b822d18bce6 174 serialMonit.printf(" Volet Poumon = %f\r\n" , volet_poumon_Position);
POTLESS_2 29:5b822d18bce6 175 serialMonit.printf(" Volet Fuite = %f\r\n" , volet_fuite_Position);
POTLESS_2 42:3591ec9903b4 176 //serialMonit.printf("\r\n");
POTLESS_2 42:3591ec9903b4 177 serialMonit.printf(" Temps d execution de la boucle = %f seconde(s)\r\n", (RATE + RATE_TRUE / 1000));
POTLESS_2 42:3591ec9903b4 178 //serialMonit.printf("\r\n");
POTLESS_2 42:3591ec9903b4 179 if (FLAG_REC) serialMonit.printf(" Chaine enregistrée = %s\r\n", to_store);
POTLESS_2 30:7a16a66d76f3 180 else serialMonit.printf(" Pas d'enregistrement en cours.");
POTLESS_2 42:3591ec9903b4 181 //serialMonit.printf("\r\n");
POTLESS_2 42:3591ec9903b4 182 serialMonit.printf(" V_USB = %f\r\n", Vusb);
POTLESS_2 42:3591ec9903b4 183 //serialMonit.printf("\r\n\r\n");
POTLESS_2 29:5b822d18bce6 184 fflush(stdout);
POTLESS_2 29:5b822d18bce6 185 }
POTLESS_2 29:5b822d18bce6 186
potless 38:fe77b68eec37 187
POTLESS_2 19:cac3761a5d0b 188 //Passage en mode SECU
POTLESS_2 19:cac3761a5d0b 189 void Mode_SECU()
POTLESS_2 18:bfd78c05b589 190 {
POTLESS_2 43:5ae8baf28e32 191
POTLESS_2 18:bfd78c05b589 192 //Mise du PID en mode manuel (desactivation...)
POTLESS_2 18:bfd78c05b589 193 control_Servo.setMode(MANUAL_MODE);
POTLESS_2 43:5ae8baf28e32 194
POTLESS_2 19:cac3761a5d0b 195 Consigne_poumon = HOME_SERVO_POUMON;
POTLESS_2 19:cac3761a5d0b 196 Consigne_fuite = HOME_SERVO_FUITE;
POTLESS_2 34:26f6e3dbefb9 197
POTLESS_2 25:322ef9488e65 198 Volets_Speed = 0.1;
POTLESS_2 25:322ef9488e65 199 Volet_DeadBand = 10;
POTLESS_2 25:322ef9488e65 200
POTLESS_2 47:89a088bc8866 201 /*
POTLESS_2 19:cac3761a5d0b 202 while(1) {
POTLESS_2 25:322ef9488e65 203 wait_ms(100);
POTLESS_2 19:cac3761a5d0b 204 if (Servo_Poumon.Pos_OK() == true) break;
POTLESS_2 43:5ae8baf28e32 205 if (Servo_Fuite.Pos_OK() == true) break;
POTLESS_2 19:cac3761a5d0b 206 }
POTLESS_2 47:89a088bc8866 207 */
POTLESS_2 43:5ae8baf28e32 208
POTLESS_2 43:5ae8baf28e32 209 OUTPUT(" Appareil en mode SECU\r\n");
POTLESS_2 34:26f6e3dbefb9 210
POTLESS_2 25:322ef9488e65 211 wait_ms(100);
POTLESS_2 34:26f6e3dbefb9 212
POTLESS_2 19:cac3761a5d0b 213 EN_MODE_SECU = true;
POTLESS_2 43:5ae8baf28e32 214
POTLESS_2 25:322ef9488e65 215 wait_ms(100);
POTLESS_2 43:5ae8baf28e32 216 int Pos_P = Servo_Poumon.getPulses();
POTLESS_2 43:5ae8baf28e32 217 UTILS::Store_A_Val((float)Pos_P, "Servo_Poumon.sys");
POTLESS_2 43:5ae8baf28e32 218 DEBUG(" position volet poumon sauvegardée = %d pulse(s)\r\n", Pos_P);
POTLESS_2 47:89a088bc8866 219 OUTPUT(" Volet poumon en sécu\r\n");
POTLESS_2 47:89a088bc8866 220
POTLESS_2 43:5ae8baf28e32 221 int Pos_F = Servo_Fuite.getPulses();
POTLESS_2 43:5ae8baf28e32 222 UTILS::Store_A_Val((float)Pos_F, "Servo_Fuite.sys");
POTLESS_2 43:5ae8baf28e32 223 DEBUG(" position volet fuite sauvegardée = %d pulse(s)\r\n", Pos_F);
POTLESS_2 47:89a088bc8866 224 OUTPUT(" Volet fuite en sécu\r\n");
POTLESS_2 47:89a088bc8866 225
POTLESS_2 23:7477dc855fad 226 Servo_Poumon.Sleep();
POTLESS_2 43:5ae8baf28e32 227 Servo_Fuite.Sleep();
POTLESS_2 19:cac3761a5d0b 228 }
POTLESS_2 19:cac3761a5d0b 229
POTLESS_2 19:cac3761a5d0b 230 //Sequence d'arrêt
POTLESS_2 19:cac3761a5d0b 231 void Stop_Sequence()
POTLESS_2 34:26f6e3dbefb9 232 {
POTLESS_2 43:5ae8baf28e32 233 OUTPUT(" Mise en veille de l'appareil.\r\n");
POTLESS_2 43:5ae8baf28e32 234
POTLESS_2 43:5ae8baf28e32 235 wait(1);
POTLESS_2 43:5ae8baf28e32 236
POTLESS_2 34:26f6e3dbefb9 237 Mode_SECU();
POTLESS_2 47:89a088bc8866 238
POTLESS_2 47:89a088bc8866 239 wait(1);
POTLESS_2 39:65ff3c4f9675 240 //ejection de la flash pour pas crasher le system de fichiers
POTLESS_2 39:65ff3c4f9675 241 UTILS::UnMount_Flash();
POTLESS_2 47:89a088bc8866 242
POTLESS_2 47:89a088bc8866 243 OUTPUT(" Ejection de la Flash\r\n");
POTLESS_2 47:89a088bc8866 244 wait(1);
POTLESS_2 47:89a088bc8866 245 buzzer.beep(1000,0.5);
POTLESS_2 47:89a088bc8866 246 wait(1);
potless 37:f9461c6592f2 247 // préparation deepsleep
POTLESS_2 40:32d89e04ead1 248
potless 37:f9461c6592f2 249 /*
potless 37:f9461c6592f2 250 //première méthode mais je ne sais pas ce que ça consomme et il faut normalement reduire le frequence d'horloge avant
potless 37:f9461c6592f2 251 //il est possible que ça génère un plantage et la rtc ne fonctionnera pas?
potless 37:f9461c6592f2 252 HAL_PWREx_EnableLowPowerRunMode();
potless 37:f9461c6592f2 253 DEBUG("----------------LOW POWER RUN MODE--------------------\r\n");
POTLESS_2 40:32d89e04ead1 254
potless 37:f9461c6592f2 255 bool isDSallowed;
potless 37:f9461c6592f2 256 isDSallowed = sleep_manager_can_deep_sleep();
potless 37:f9461c6592f2 257 DEBUG(" Deep sleep autorisé ? %i\r\n", isDSallowed);
potless 37:f9461c6592f2 258 wait(1.0);
POTLESS_2 34:26f6e3dbefb9 259
potless 37:f9461c6592f2 260 DEBUG("\n\r Deepsleep tentative normale !(bouton bleu pour ressortir)\n");
potless 37:f9461c6592f2 261 wait(0.1);
POTLESS_2 40:32d89e04ead1 262
potless 37:f9461c6592f2 263 sleep_manager_sleep_auto(); // ne marche pas, je ne sais pas pk
potless 37:f9461c6592f2 264 */
POTLESS_2 47:89a088bc8866 265
POTLESS_2 39:65ff3c4f9675 266 /*
potless 38:fe77b68eec37 267 HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2); // pour PC_13
POTLESS_2 40:32d89e04ead1 268 // Clear wake up Flag
POTLESS_2 40:32d89e04ead1 269 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2);
POTLESS_2 40:32d89e04ead1 270 // Enable wakeup pin WKUP2
potless 38:fe77b68eec37 271 HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_LOW); // low parce qu'on veut que ça redémarre avec le user button TODO à passer sur High pour que ça redémarrage avec l'arrivée du hus sur l'USB
POTLESS_2 39:65ff3c4f9675 272 */
POTLESS_2 47:89a088bc8866 273
POTLESS_2 43:5ae8baf28e32 274 HAL_PWREx_EnablePullUpPullDownConfig() ;
POTLESS_2 46:28298df0ac55 275 HAL_PWREx_EnableGPIOPullDown(PWR_GPIO_A, PWR_GPIO_BIT_0);
POTLESS_2 40:32d89e04ead1 276
potless 38:fe77b68eec37 277 HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); // pour PA_0
POTLESS_2 40:32d89e04ead1 278 // Clear wake up Flag
POTLESS_2 40:32d89e04ead1 279 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);
POTLESS_2 40:32d89e04ead1 280 // Enable wakeup pin WKUP2
POTLESS_2 39:65ff3c4f9675 281 HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); // high est la valeur par défaut
POTLESS_2 40:32d89e04ead1 282
POTLESS_2 40:32d89e04ead1 283 // Set RTC back-up register RTC_BKP31R to indicate
POTLESS_2 40:32d89e04ead1 284 //later on that system has entered shutdown mode
potless 37:f9461c6592f2 285 WRITE_REG( RTC->BKP31R, 0x1 );
POTLESS_2 40:32d89e04ead1 286 //Enter shutdown mode
potless 37:f9461c6592f2 287 DEBUG("\n\r Attention c'est du brutal ! bouton bleu pour ressort.... ZZZZZZZ ZZZZZ !!!\n");
POTLESS_2 40:32d89e04ead1 288
potless 37:f9461c6592f2 289 HAL_PWREx_EnterSHUTDOWNMode();
POTLESS_2 18:bfd78c05b589 290 }
POTLESS_2 18:bfd78c05b589 291
POTLESS_2 31:231a96d1d1c8 292 //Fonction test de valeur d'entrée digitale
POTLESS_2 29:5b822d18bce6 293 int Power_Test(DigitalIn& pin)
POTLESS_2 20:5f79fb4565a7 294 {
POTLESS_2 29:5b822d18bce6 295 pin.mode(PullDown);
POTLESS_2 34:26f6e3dbefb9 296
POTLESS_2 34:26f6e3dbefb9 297 if(!pin) {
POTLESS_2 34:26f6e3dbefb9 298 Stop_Sequence();
POTLESS_2 34:26f6e3dbefb9 299 return 0;
POTLESS_2 34:26f6e3dbefb9 300 } else {
POTLESS_2 34:26f6e3dbefb9 301 return 1;
POTLESS_2 34:26f6e3dbefb9 302 }
POTLESS_2 20:5f79fb4565a7 303 }
POTLESS_2 20:5f79fb4565a7 304
POTLESS_2 31:231a96d1d1c8 305 //Fonction test de valeur d'entrée analogique
POTLESS_2 31:231a96d1d1c8 306 float Power_Test(AnalogIn& pin)
POTLESS_2 31:231a96d1d1c8 307 {
POTLESS_2 31:231a96d1d1c8 308 float Val = pin.read();
POTLESS_2 31:231a96d1d1c8 309 return Val;
POTLESS_2 31:231a96d1d1c8 310 }
POTLESS_2 31:231a96d1d1c8 311
POTLESS_2 18:bfd78c05b589 312 //Contrôle du status de l'appareil / des constantes
POTLESS_2 18:bfd78c05b589 313 bool Check()
POTLESS_2 18:bfd78c05b589 314 {
POTLESS_2 18:bfd78c05b589 315 if (ppO2 > 100)
POTLESS_2 19:cac3761a5d0b 316 return true;//Situation OK
POTLESS_2 18:bfd78c05b589 317 else
POTLESS_2 19:cac3761a5d0b 318 return false;//Situation dégradée
POTLESS_2 18:bfd78c05b589 319 }
POTLESS_2 18:bfd78c05b589 320
POTLESS_2 18:bfd78c05b589 321 //Calcul des OTU
POTLESS_2 18:bfd78c05b589 322 float Calcul_OTU()
POTLESS_2 18:bfd78c05b589 323 {
POTLESS_2 18:bfd78c05b589 324 /*
POTLESS_2 18:bfd78c05b589 325 La formule suivante permet de calculer la quantité d' OTU accumulée
POTLESS_2 18:bfd78c05b589 326 OTU = T * (2* PpO2 -1)0,83
POTLESS_2 18:bfd78c05b589 327 avec :
POTLESS_2 18:bfd78c05b589 328 T = temps de plongée en minutes
POTLESS_2 18:bfd78c05b589 329 PpO2 = pression partielle d’ oxygène en bars
POTLESS_2 18:bfd78c05b589 330 */
POTLESS_2 18:bfd78c05b589 331
POTLESS_2 19:cac3761a5d0b 332 if (ppO2 > 500) {
POTLESS_2 18:bfd78c05b589 333 float val = (2 * (float)ppO2/1000 - 1);//je divise par 1000 car la PP est en mb...
POTLESS_2 18:bfd78c05b589 334 OTU += Ref_Time * pow(val, COEF_OTU);
POTLESS_2 19:cac3761a5d0b 335 }
POTLESS_2 18:bfd78c05b589 336 }
POTLESS_2 10:aca745a66d51 337
POTLESS_2 17:bef8abc445f2 338 //Thread d'intérogation des capteurs, positions servo
POTLESS_2 34:26f6e3dbefb9 339 void SENSORS_thread()
POTLESS_2 6:ebed9093d661 340 {
POTLESS_2 7:ad15c386e960 341 while (true) {
POTLESS_2 36:1f5e2247b073 342 //DEEP_DEBUG(" SENSORS_thread\r\n");
POTLESS_2 7:ad15c386e960 343
POTLESS_2 7:ad15c386e960 344 //CO2 sur Cozir
POTLESS_2 7:ad15c386e960 345 co2 = sensors.requestCO2();
POTLESS_2 7:ad15c386e960 346 //P / T sur MS5837
POTLESS_2 7:ad15c386e960 347 pression = sensors.requestPress();
POTLESS_2 9:04bfdfc029cb 348 Temp1 = sensors.requestTemp();
POTLESS_2 7:ad15c386e960 349 //PPO2 sur ADS1015
POTLESS_2 33:f5d4bae05f16 350 if (FLAG_O2) ppO2 = sensors.requestPpO2();
POTLESS_2 7:ad15c386e960 351 //Cell O2 en mV
POTLESS_2 33:f5d4bae05f16 352 if (FLAG_O2) CellO2_1 = sensors.requestCellO2_1();
POTLESS_2 33:f5d4bae05f16 353 if (FLAG_O2) CellO2_2 = sensors.requestCellO2_2();
POTLESS_2 9:04bfdfc029cb 354
POTLESS_2 8:a750d531b381 355 //HTU21D
POTLESS_2 9:04bfdfc029cb 356 Temp2 = temphumid.sample_ctemp();
POTLESS_2 9:04bfdfc029cb 357 Humid = temphumid.sample_humid();
POTLESS_2 9:04bfdfc029cb 358
POTLESS_2 10:aca745a66d51 359 //Retour position des servos
POTLESS_2 17:bef8abc445f2 360 volet_poumon_Position = Servo_Poumon.Get_Position();
POTLESS_2 43:5ae8baf28e32 361 volet_fuite_Position = Servo_Fuite.Get_Position();
POTLESS_2 43:5ae8baf28e32 362
POTLESS_2 43:5ae8baf28e32 363 //Calcul des OTU
POTLESS_2 43:5ae8baf28e32 364 Calcul_OTU();
POTLESS_2 34:26f6e3dbefb9 365
POTLESS_2 19:cac3761a5d0b 366 }
POTLESS_2 19:cac3761a5d0b 367 }
POTLESS_2 12:7f3aadd79f89 368
POTLESS_2 19:cac3761a5d0b 369 void GO_TO_thread()
POTLESS_2 19:cac3761a5d0b 370 {
POTLESS_2 19:cac3761a5d0b 371 while (true) {
POTLESS_2 36:1f5e2247b073 372 //DEEP_DEBUG(" GO_TO_Thread\r\n");
POTLESS_2 34:26f6e3dbefb9 373
POTLESS_2 19:cac3761a5d0b 374 //Servo_Poumon.Go_To_Prop(Consigne_poumon);
POTLESS_2 26:a2fe19341f92 375 //Servo_Poumon.Go_To_PID(Consigne_poumon, Volet_DeadBand);
POTLESS_2 34:26f6e3dbefb9 376 Servo_Poumon.Go_To(Consigne_poumon, Volets_Speed, Volet_DeadBand);
POTLESS_2 34:26f6e3dbefb9 377
POTLESS_2 19:cac3761a5d0b 378 //Servo_Fuite.Go_To_Prop(Consigne_fuite);
POTLESS_2 43:5ae8baf28e32 379 //Servo_Fuite.Go_To_PID(Consigne_fuite, Volet_DeadBand);
POTLESS_2 43:5ae8baf28e32 380 Servo_Fuite.Go_To(Consigne_fuite, Volets_Speed, Volet_DeadBand );
POTLESS_2 15:efd3b3bf3f37 381 }
potless 2:4a8bf1d53439 382 }
POTLESS_2 4:d84250f67dec 383
POTLESS_2 20:5f79fb4565a7 384 void SECU_thread()
POTLESS_2 20:5f79fb4565a7 385 {
POTLESS_2 34:26f6e3dbefb9 386 while (true) {
POTLESS_2 34:26f6e3dbefb9 387
POTLESS_2 20:5f79fb4565a7 388 }
POTLESS_2 20:5f79fb4565a7 389 }
POTLESS_2 20:5f79fb4565a7 390
POTLESS_2 11:b2feed92584a 391 //Callback de l'intérruption des envois de commandes depuis le terminal
POTLESS_2 6:ebed9093d661 392 void callbackParam()
POTLESS_2 34:26f6e3dbefb9 393 {
POTLESS_2 40:32d89e04ead1 394
POTLESS_2 40:32d89e04ead1 395
POTLESS_2 34:26f6e3dbefb9 396 while(serialMonit.readable()) {
POTLESS_2 40:32d89e04ead1 397 if ((indexParam == sizeParam) || newParamFlag == true) { //éviter la saturation du buffer
potless 44:5cd6f84a62ec 398 NVIC_DisableIRQ(USART2_IRQn); // USART 2 pour carte ARNSRS
POTLESS_2 29:5b822d18bce6 399 char char_flush = serialMonit.getc();
potless 44:5cd6f84a62ec 400 NVIC_EnableIRQ(USART2_IRQn); // USART 2 pour carte ARNSRS
POTLESS_2 40:32d89e04ead1 401 } else {
potless 44:5cd6f84a62ec 402 NVIC_DisableIRQ(USART2_IRQn); // USART 2 pour carte ARNSRS
POTLESS_2 29:5b822d18bce6 403 param [indexParam ++] = serialMonit.getc();//chargement du buffer dans le message
POTLESS_2 40:32d89e04ead1 404 if ((indexParam == sizeParam) || (param[indexParam - 1] == '\n')) {//le message est complet ou nouvelle ligne ou autre si on veut...
POTLESS_2 40:32d89e04ead1 405 param[indexParam] = 0;
POTLESS_2 40:32d89e04ead1 406 newParamFlag = true;
POTLESS_2 40:32d89e04ead1 407 }
potless 44:5cd6f84a62ec 408 NVIC_EnableIRQ(USART2_IRQn); // USART 2 pour carte ARNSRS
POTLESS_2 34:26f6e3dbefb9 409 }
POTLESS_2 34:26f6e3dbefb9 410 }
POTLESS_2 6:ebed9093d661 411 }
POTLESS_2 4:d84250f67dec 412
POTLESS_2 9:04bfdfc029cb 413 void Decoding_Message(char message [])
POTLESS_2 9:04bfdfc029cb 414 {
POTLESS_2 9:04bfdfc029cb 415
POTLESS_2 42:3591ec9903b4 416 char com[20] = "";
POTLESS_2 42:3591ec9903b4 417 char numb[30] = "";
POTLESS_2 36:1f5e2247b073 418
POTLESS_2 34:26f6e3dbefb9 419 sscanf(message,"%s %s",&com , &numb);
POTLESS_2 36:1f5e2247b073 420
POTLESS_2 35:a209a192f431 421 DEEP_DEBUG("\r\n Commande = %s Valeur = %s \r\n\r\n", com, numb);
POTLESS_2 42:3591ec9903b4 422 //serialMonit.printf("\r\n Commande = %s Valeur = %s \r\n\r\n", com, numb);
POTLESS_2 36:1f5e2247b073 423
POTLESS_2 43:5ae8baf28e32 424 OUTPUT("?\r\n");
POTLESS_2 43:5ae8baf28e32 425
POTLESS_2 30:7a16a66d76f3 426 if (0 == strcmp(com, "secu")) {
POTLESS_2 19:cac3761a5d0b 427 Mode_SECU();
POTLESS_2 42:3591ec9903b4 428 } else if (0 == strcmp(com, "PING")) {
POTLESS_2 43:5ae8baf28e32 429 FLAG_PID = 0;
POTLESS_2 43:5ae8baf28e32 430 FLAG_AFF = false;
POTLESS_2 43:5ae8baf28e32 431 FLAG_WINDEV = false;
POTLESS_2 43:5ae8baf28e32 432 control_Servo.setMode(MANUAL_MODE);
POTLESS_2 34:26f6e3dbefb9 433 } else if (0 == strcmp(com, "ARNSRS_ID")) {
POTLESS_2 43:5ae8baf28e32 434 OUTPUT("Changement de l'ID de l'appareil pour le N°: %s?\r\n", numb);
POTLESS_2 34:26f6e3dbefb9 435 UTILS::Store_A_Val(atoi(numb), "ARNSRS_ID");
POTLESS_2 43:5ae8baf28e32 436 } else if (0 == strcmp(com, "monit")) {
POTLESS_2 43:5ae8baf28e32 437 FLAG_AFF = false;
POTLESS_2 43:5ae8baf28e32 438 FLAG_WINDEV = true;
POTLESS_2 43:5ae8baf28e32 439 } else if (0 == strcmp(com, "debug")) {
POTLESS_2 43:5ae8baf28e32 440 FLAG_AFF = false;
POTLESS_2 43:5ae8baf28e32 441 FLAG_WINDEV = false;
POTLESS_2 34:26f6e3dbefb9 442 } else if (0 == strcmp(com, "Head_ID")) {
POTLESS_2 34:26f6e3dbefb9 443 //On l'enregistre dans l'eeprom
POTLESS_2 43:5ae8baf28e32 444 OUTPUT("Changement de l'ID de la tête capteur pour le N°: %s\r\n", numb);
POTLESS_2 34:26f6e3dbefb9 445 UTILS::write_EEPROM(numb, HEAD_ID);
POTLESS_2 34:26f6e3dbefb9 446 } else if (0 == strcmp(com, "O2_1_ID")) {
POTLESS_2 34:26f6e3dbefb9 447 //On l'enregistre dans l'eeprom
POTLESS_2 34:26f6e3dbefb9 448 UTILS::write_EEPROM(numb, CELL_O2_1_ID);
POTLESS_2 34:26f6e3dbefb9 449 } else if (0 == strcmp(com, "O2_2_ID")) {
POTLESS_2 34:26f6e3dbefb9 450 //On l'enregistre dans l'eeprom
POTLESS_2 34:26f6e3dbefb9 451 UTILS::write_EEPROM(numb, CELL_O2_2_ID);
POTLESS_2 34:26f6e3dbefb9 452 } else if (0 == strcmp(com, "CO2_ID")) {
POTLESS_2 34:26f6e3dbefb9 453 //On l'enregistre dans l'eeprom
POTLESS_2 34:26f6e3dbefb9 454 UTILS::write_EEPROM(numb, CO2_ID);
POTLESS_2 34:26f6e3dbefb9 455 } else if (0 == strcmp(com, "calib_O2")) {
POTLESS_2 33:f5d4bae05f16 456 FLAG_O2 = false;
POTLESS_2 33:f5d4bae05f16 457 wait_ms(100);
POTLESS_2 42:3591ec9903b4 458 float Val = sensors.Calibrate_O2(atoi(numb));
POTLESS_2 43:5ae8baf28e32 459 OUTPUT(" Calibration O2 dans l'air = %f\r\n", Val);
POTLESS_2 33:f5d4bae05f16 460 wait_ms(100);
POTLESS_2 33:f5d4bae05f16 461 FLAG_O2 = true;
POTLESS_2 41:51ba69648f9d 462 } else if (0 == strcmp(com, "calib_CO2_A")) {
POTLESS_2 43:5ae8baf28e32 463 int Val = sensors.Calibrate_CO2();
POTLESS_2 43:5ae8baf28e32 464 OUTPUT(" Calibration CO2 dans l'air = %d\r\n", Val);
POTLESS_2 34:26f6e3dbefb9 465 } else if (0 == strcmp(com, "flash_i")) {
POTLESS_2 42:3591ec9903b4 466 UTILS::Flash_Infos(&serialMonit);
POTLESS_2 36:1f5e2247b073 467 } else if (0 == strcmp(com, "flash_u")) {
POTLESS_2 43:5ae8baf28e32 468 OUTPUT(" Démontage de la Flash.\r\n");
POTLESS_2 36:1f5e2247b073 469 FLAG_REC = false;
POTLESS_2 36:1f5e2247b073 470 UTILS::UnMount_Flash();
POTLESS_2 36:1f5e2247b073 471 } else if (0 == strcmp(com, "flash_m")) {
POTLESS_2 43:5ae8baf28e32 472 OUTPUT(" Montage de la Flash.\r\n");
POTLESS_2 40:32d89e04ead1 473 UTILS::Mount_Flash();
POTLESS_2 35:a209a192f431 474 } else if (0 == strcmp(com, "check_F")) {
POTLESS_2 43:5ae8baf28e32 475 OUTPUT(" ARNSRS_ID.sys = %d\r\n", (int)UTILS::Read_A_Val("ARNSRS_ID.sys"));
POTLESS_2 43:5ae8baf28e32 476 OUTPUT(" Servo_Poumon.sys = %d\r\n", (int)UTILS::Read_A_Val("Servo_Poumon.sys"));
POTLESS_2 43:5ae8baf28e32 477 OUTPUT(" Servo_Fuite.sys = %d\r\n", (int)UTILS::Read_A_Val("Servo_Fuite.sys"));
POTLESS_2 35:a209a192f431 478 } else if (0 == strcmp(com, "check_E")) {
POTLESS_2 42:3591ec9903b4 479 sensors.Sensor_head_check(&serialMonit);
POTLESS_2 34:26f6e3dbefb9 480 } else if (0 == strcmp(com, "rec")) {
POTLESS_2 34:26f6e3dbefb9 481 if (FLAG_REC) {
POTLESS_2 34:26f6e3dbefb9 482 FLAG_REC = false;
POTLESS_2 43:5ae8baf28e32 483 OUTPUT(" Arrêt du Data Logging.\r\n");
POTLESS_2 34:26f6e3dbefb9 484 } else {
POTLESS_2 34:26f6e3dbefb9 485 FLAG_REC = true;
POTLESS_2 43:5ae8baf28e32 486 OUTPUT(" Démarrage Data Logging dans %s\r\n", Log_File_Name);
POTLESS_2 34:26f6e3dbefb9 487 }
POTLESS_2 34:26f6e3dbefb9 488 } else if (0 == strcmp(com, "help")) {
POTLESS_2 29:5b822d18bce6 489 FLAG_AFF = false;
POTLESS_2 42:3591ec9903b4 490 UTILS::Help(&serialMonit);
POTLESS_2 34:26f6e3dbefb9 491 } else if (0 == strcmp(com, "start")) {
POTLESS_2 29:5b822d18bce6 492 FLAG_AFF = true;
POTLESS_2 34:26f6e3dbefb9 493 } else if (0 == strcmp(com, "stop")) {
POTLESS_2 29:5b822d18bce6 494 FLAG_AFF = false;
POTLESS_2 40:32d89e04ead1 495 //UTILS::Help();
POTLESS_2 36:1f5e2247b073 496 } else if (0 == strcmp(com, "flash_c")) {
POTLESS_2 29:5b822d18bce6 497 FLAG_REC = false;
POTLESS_2 29:5b822d18bce6 498 UTILS::Clean_Flash();
POTLESS_2 42:3591ec9903b4 499 } else if (0 == strcmp(com, "flash_f")) {
POTLESS_2 34:26f6e3dbefb9 500 FLAG_REC = false;
POTLESS_2 43:5ae8baf28e32 501 UTILS::Clean_Flash_All();
POTLESS_2 42:3591ec9903b4 502 } else if (0 == strcmp(com, "dir")) {
POTLESS_2 43:5ae8baf28e32 503 FLAG_WINDEV = false;
POTLESS_2 43:5ae8baf28e32 504 OUTPUT("$\r\n");
POTLESS_2 43:5ae8baf28e32 505 wait(0.5);
POTLESS_2 42:3591ec9903b4 506 UTILS::Dir_Flash(&serialMonit);
POTLESS_2 42:3591ec9903b4 507 } else if (0 == strcmp(com, "get")) {
POTLESS_2 29:5b822d18bce6 508 wait_ms(100);
POTLESS_2 43:5ae8baf28e32 509 char filename[20];
POTLESS_2 43:5ae8baf28e32 510 UTILS::Read_Flash_File(&serialMonit, numb);
POTLESS_2 43:5ae8baf28e32 511 wait_ms(100);
POTLESS_2 34:26f6e3dbefb9 512 } else if (0 == strcmp(com, "del")) {
POTLESS_2 29:5b822d18bce6 513 FLAG_REC = false;
POTLESS_2 29:5b822d18bce6 514 char filename[20];
POTLESS_2 42:3591ec9903b4 515 UTILS::Delete_Flash_File(numb);
POTLESS_2 43:5ae8baf28e32 516 OUTPUT("$\r\n");
POTLESS_2 43:5ae8baf28e32 517 wait(0.5);
POTLESS_2 43:5ae8baf28e32 518 UTILS::Dir_Flash(&serialMonit);
POTLESS_2 31:231a96d1d1c8 519 FLAG_REC = true;
POTLESS_2 34:26f6e3dbefb9 520 } else if (0 == strcmp(com, "file_s")) {
POTLESS_2 31:231a96d1d1c8 521 char filename[20];
POTLESS_2 42:3591ec9903b4 522 UTILS::Get_File_Size(&serialMonit, numb);
POTLESS_2 29:5b822d18bce6 523 } else if (0 == strcmp(com, "calib_p")) {
POTLESS_2 20:5f79fb4565a7 524 Consigne_poumon = 0;
POTLESS_2 20:5f79fb4565a7 525 volet_poumon_Position = 0;
POTLESS_2 19:cac3761a5d0b 526 Servo_Poumon.reset();
POTLESS_2 43:5ae8baf28e32 527 OUTPUT(" Volet poumon Calibré.\r\n");
POTLESS_2 29:5b822d18bce6 528 } else if (0 == strcmp(com, "calib_f")) {
POTLESS_2 29:5b822d18bce6 529 Consigne_fuite = 0;
POTLESS_2 29:5b822d18bce6 530 volet_fuite_Position = 0;
POTLESS_2 43:5ae8baf28e32 531 Servo_Fuite.reset();
POTLESS_2 43:5ae8baf28e32 532 OUTPUT(" Volet fuite Calibré.\r\n");
POTLESS_2 29:5b822d18bce6 533 } else if (0 == strcmp(com, "sleep")) {
POTLESS_2 19:cac3761a5d0b 534 Stop_Sequence();
POTLESS_2 29:5b822d18bce6 535 } else if (0 == strcmp(com, "time")) {//Depuis terminal MAC taper : " date +%s "
POTLESS_2 34:26f6e3dbefb9 536 set_time(atoi(numb));
POTLESS_2 43:5ae8baf28e32 537 OUTPUT(" La RTC a été mise à l'heure.\r\n");
POTLESS_2 29:5b822d18bce6 538 } else if (0 == strcmp(com, "c_pou")) {
POTLESS_2 43:5ae8baf28e32 539 Consigne_poumon = atof(numb);
POTLESS_2 43:5ae8baf28e32 540 DEBUG(" Servo Poumon = %f\r\n", Consigne_poumon);
POTLESS_2 43:5ae8baf28e32 541 } else if (0 == strcmp(com, "c_fui")) {
POTLESS_2 43:5ae8baf28e32 542 Consigne_fuite = atof(numb);
POTLESS_2 43:5ae8baf28e32 543 DEBUG(" Servo Fuite = %f\r\n", Consigne_fuite);
POTLESS_2 43:5ae8baf28e32 544 } else if (0 == strcmp(com, "mp_pou")) {
POTLESS_2 41:51ba69648f9d 545 Consigne_poumon += atof(numb);
POTLESS_2 33:f5d4bae05f16 546 DEBUG(" Servo Poumon = %f\r\n", Consigne_poumon);
POTLESS_2 43:5ae8baf28e32 547 } else if (0 == strcmp(com, "mp_fui")) {
POTLESS_2 41:51ba69648f9d 548 Consigne_fuite += atof(numb);
POTLESS_2 33:f5d4bae05f16 549 DEBUG(" Servo Fuite = %f\r\n", Consigne_fuite);
POTLESS_2 29:5b822d18bce6 550 } else if (0 == strcmp(com, "reset")) {
POTLESS_2 43:5ae8baf28e32 551 FLAG_REC = false;
POTLESS_2 36:1f5e2247b073 552 UTILS::UnMount_Flash();
POTLESS_2 43:5ae8baf28e32 553 OUTPUT(" Reset de l'appareil.\r\n");
POTLESS_2 43:5ae8baf28e32 554 wait(1);
POTLESS_2 10:aca745a66d51 555 NVIC_SystemReset();
POTLESS_2 43:5ae8baf28e32 556 } else if (0 == strcmp(com, "Kc")) {
POTLESS_2 43:5ae8baf28e32 557 Kc = atof(numb);
POTLESS_2 43:5ae8baf28e32 558 control_Servo.reset();
POTLESS_2 43:5ae8baf28e32 559 control_Servo.setTunings(Kc, Ti, Td);
POTLESS_2 43:5ae8baf28e32 560 OUTPUT(" MAJ PID --> Kc = %f Ti = %f Td = %f?\r\n", Kc, Ti, Td);
POTLESS_2 43:5ae8baf28e32 561 } else if (0 == strcmp(com, "Ti")) {
POTLESS_2 43:5ae8baf28e32 562 Ti = atof(numb);
POTLESS_2 43:5ae8baf28e32 563 control_Servo.reset();
POTLESS_2 43:5ae8baf28e32 564 control_Servo.setTunings(Kc, Ti, Td);
POTLESS_2 43:5ae8baf28e32 565 OUTPUT(" MAJ PID --> Kc = %f Ti = %f Td = %f?\r\n", Kc, Ti, Td);
POTLESS_2 43:5ae8baf28e32 566 } else if (0 == strcmp(com, "Td")) {
POTLESS_2 43:5ae8baf28e32 567 Td = atof(numb);
POTLESS_2 43:5ae8baf28e32 568 control_Servo.reset();
POTLESS_2 43:5ae8baf28e32 569 control_Servo.setTunings(Kc, Ti, Td);
POTLESS_2 43:5ae8baf28e32 570 OUTPUT(" MAJ PID --> Kc = %f Ti = %f Td = %f?\r\n", Kc, Ti, Td);
POTLESS_2 43:5ae8baf28e32 571 } else if (0 == strcmp(com, "Cons")) {
POTLESS_2 43:5ae8baf28e32 572 consigne = atoi(numb);
POTLESS_2 43:5ae8baf28e32 573 control_Servo.setSetPoint(consigne);
POTLESS_2 43:5ae8baf28e32 574 OUTPUT(" MAJ CONSIGNE PID --> Consigne = %d?\r\n", consigne);
potless 49:a7432da60647 575
potless 49:a7432da60647 576 } else if (0 == strcmp(com, "dfu")) {
potless 49:a7432da60647 577 OUTPUT(" Mode DFU main \r\n");
potless 49:a7432da60647 578 *((unsigned long *) 0x10007FF0) = 0xDEADBEEF;
potless 49:a7432da60647 579 wait(1);
potless 49:a7432da60647 580 NVIC_SystemReset();
potless 49:a7432da60647 581
potless 49:a7432da60647 582
POTLESS_2 43:5ae8baf28e32 583 } else if (0 == strcmp(com, "PID")) {
POTLESS_2 43:5ae8baf28e32 584 if (FLAG_PID == 1) {
POTLESS_2 43:5ae8baf28e32 585 control_Servo.setMode(MANUAL_MODE);
POTLESS_2 43:5ae8baf28e32 586 OUTPUT(" PID OFF?\r\n");
POTLESS_2 43:5ae8baf28e32 587 FLAG_PID = 0;
POTLESS_2 43:5ae8baf28e32 588 } else if (FLAG_PID == 0) {
POTLESS_2 43:5ae8baf28e32 589 control_Servo.setMode(AUTO_MODE);
POTLESS_2 43:5ae8baf28e32 590 OUTPUT(" PID ON?\r\n");
POTLESS_2 43:5ae8baf28e32 591 FLAG_PID = 1;
POTLESS_2 43:5ae8baf28e32 592 }
POTLESS_2 12:7f3aadd79f89 593 } else {
POTLESS_2 43:5ae8baf28e32 594
POTLESS_2 9:04bfdfc029cb 595 sensors.cozirSend(message);
POTLESS_2 9:04bfdfc029cb 596 }
POTLESS_2 34:26f6e3dbefb9 597
POTLESS_2 9:04bfdfc029cb 598 strcpy(param," ");
POTLESS_2 9:04bfdfc029cb 599 indexParam = 0;
POTLESS_2 9:04bfdfc029cb 600 newParamFlag = false;
POTLESS_2 9:04bfdfc029cb 601 }
POTLESS_2 9:04bfdfc029cb 602
POTLESS_2 26:a2fe19341f92 603 void Create_File_Name_Date()
POTLESS_2 25:322ef9488e65 604 {
POTLESS_2 25:322ef9488e65 605 //Du nom du fichier Date / heure
POTLESS_2 25:322ef9488e65 606 seconds = time(NULL);
POTLESS_2 25:322ef9488e65 607 char Time[40];
POTLESS_2 25:322ef9488e65 608 strftime(Time, 40, "%a_%d_%m_%Y_%H%M", localtime(&seconds));
POTLESS_2 42:3591ec9903b4 609 sprintf(Log_File_Name, "%s_LOG.csv", Time);
POTLESS_2 42:3591ec9903b4 610 DEBUG(" Nouveau fichier LOG = %s \r\n", Log_File_Name);
POTLESS_2 34:26f6e3dbefb9 611 }
POTLESS_2 34:26f6e3dbefb9 612
POTLESS_2 26:a2fe19341f92 613 void Create_File_Name_Index()
POTLESS_2 26:a2fe19341f92 614 {
POTLESS_2 26:a2fe19341f92 615 //Du nom du fichier par Index
POTLESS_2 42:3591ec9903b4 616 sprintf(Log_File_Name, "LOG_%d.csv", UTILS::File_Index());
POTLESS_2 34:26f6e3dbefb9 617 DEBUG(" Nouveau fichier LOG = %s \r\n", Log_File_Name);
POTLESS_2 34:26f6e3dbefb9 618 }
POTLESS_2 34:26f6e3dbefb9 619
potless 48:9ceb095f397a 620
potless 48:9ceb095f397a 621
potless 48:9ceb095f397a 622
potless 48:9ceb095f397a 623
potless 48:9ceb095f397a 624
potless 48:9ceb095f397a 625
POTLESS_2 4:d84250f67dec 626 int main()
POTLESS_2 12:7f3aadd79f89 627 {
POTLESS_2 47:89a088bc8866 628
POTLESS_2 40:32d89e04ead1 629 HAL_Init();
potless 48:9ceb095f397a 630
POTLESS_2 40:32d89e04ead1 631
POTLESS_2 40:32d89e04ead1 632 __HAL_RCC_PWR_CLK_ENABLE();
potless 37:f9461c6592f2 633 HAL_PWR_EnableBkUpAccess();
potless 48:9ceb095f397a 634
potless 48:9ceb095f397a 635
potless 48:9ceb095f397a 636
POTLESS_2 40:32d89e04ead1 637
POTLESS_2 43:5ae8baf28e32 638 //Ci-dessous commande pour formater une nouvelle carte
POTLESS_2 43:5ae8baf28e32 639 //UTILS::Format_Flash();
POTLESS_2 43:5ae8baf28e32 640
POTLESS_2 43:5ae8baf28e32 641 //Montage Flash
POTLESS_2 43:5ae8baf28e32 642 UTILS::Mount_Flash();
POTLESS_2 12:7f3aadd79f89 643
POTLESS_2 43:5ae8baf28e32 644 //Liste des fichiers sur la Flash
POTLESS_2 43:5ae8baf28e32 645 //UTILS::Dir_Flash(&serialMonit);
POTLESS_2 26:a2fe19341f92 646
POTLESS_2 43:5ae8baf28e32 647 if (UTILS::File_Exist("ARNSRS_ID.sys") == false) {
POTLESS_2 43:5ae8baf28e32 648 UTILS::Store_A_Val(000, "ARNSRS_ID.sys");
POTLESS_2 43:5ae8baf28e32 649 DEBUG("ARNSRS ID forcée à 000\r\n");
POTLESS_2 43:5ae8baf28e32 650 }
potless 45:61ba3cc4fc55 651 /*
potless 45:61ba3cc4fc55 652 while(1){
potless 45:61ba3cc4fc55 653 OUTPUT("\r\n\r\n Démarrage de l'appareil, veuillez patienter...\r\n\r\n");}
potless 45:61ba3cc4fc55 654 */
POTLESS_2 34:26f6e3dbefb9 655
POTLESS_2 43:5ae8baf28e32 656 //Vérification RTC, si on est le 01/01/70, c'est qu'il y a un problème...
POTLESS_2 43:5ae8baf28e32 657 seconds = time(NULL);
POTLESS_2 43:5ae8baf28e32 658 char YEAR[10];
POTLESS_2 43:5ae8baf28e32 659 strftime(YEAR, 10, "%D", localtime(&seconds));
POTLESS_2 43:5ae8baf28e32 660 if (0 == strcmp(YEAR, "01/01/70")); //OUTPUT(" Vous devez régler la RTC...\r\n\r\n");
POTLESS_2 18:bfd78c05b589 661
POTLESS_2 43:5ae8baf28e32 662 bool calib_O2 = false;
POTLESS_2 43:5ae8baf28e32 663 bool calib_CO2 = false;
POTLESS_2 18:bfd78c05b589 664
POTLESS_2 43:5ae8baf28e32 665 /*
POTLESS_2 43:5ae8baf28e32 666 Par défaut les valeur en cas de calibration sur true sont les suivant
POTLESS_2 18:bfd78c05b589 667
POTLESS_2 43:5ae8baf28e32 668 nbCalibO2 = 5
POTLESS_2 43:5ae8baf28e32 669 Mode = SPOOLING
POTLESS_2 43:5ae8baf28e32 670 Filtre = DIGI_FILTER32
POTLESS_2 43:5ae8baf28e32 671 CalibrationCO2 = "CALIB_AIR"
POTLESS_2 18:bfd78c05b589 672
POTLESS_2 43:5ae8baf28e32 673 Parfois la calibration du Cozir coince...faire reset et relancer...
POTLESS_2 43:5ae8baf28e32 674
POTLESS_2 43:5ae8baf28e32 675 Pour calibrer avec ces paramètres :
POTLESS_2 18:bfd78c05b589 676
POTLESS_2 43:5ae8baf28e32 677 sensors.Sensors_INIT(true, true);
POTLESS_2 43:5ae8baf28e32 678
POTLESS_2 43:5ae8baf28e32 679 Pour changer utiliser la syntaxe suivante :
POTLESS_2 43:5ae8baf28e32 680
POTLESS_2 43:5ae8baf28e32 681 sensors.Sensors_INIT(true, true, true, 5, SPOOLING, DIGI_FILTER32, CALIB_AIR);
POTLESS_2 43:5ae8baf28e32 682
POTLESS_2 43:5ae8baf28e32 683 */
POTLESS_2 43:5ae8baf28e32 684
POTLESS_2 43:5ae8baf28e32 685 sensors.Sensors_INIT(calib_O2, calib_CO2);
POTLESS_2 43:5ae8baf28e32 686
POTLESS_2 43:5ae8baf28e32 687 wait(1);
POTLESS_2 43:5ae8baf28e32 688
POTLESS_2 43:5ae8baf28e32 689 //Création du nouveau fichier LOG par index / par date.
POTLESS_2 43:5ae8baf28e32 690 //Create_File_Name_Index();
POTLESS_2 43:5ae8baf28e32 691 Create_File_Name_Date();
POTLESS_2 43:5ae8baf28e32 692
POTLESS_2 43:5ae8baf28e32 693 //Création et écriture du header du fichier LOG
POTLESS_2 43:5ae8baf28e32 694 sensors.Create_Header(Log_File_Name);
POTLESS_2 42:3591ec9903b4 695
POTLESS_2 43:5ae8baf28e32 696 Servo_Poumon.Init("Servo_Poumon.sys");
POTLESS_2 43:5ae8baf28e32 697 Servo_Fuite.Init("Servo_Fuite.sys");
POTLESS_2 15:efd3b3bf3f37 698
POTLESS_2 43:5ae8baf28e32 699 //OUTPUT(" Demarrage des threads...\r\n\r\n");
POTLESS_2 43:5ae8baf28e32 700
POTLESS_2 43:5ae8baf28e32 701 /*
POTLESS_2 43:5ae8baf28e32 702
POTLESS_2 43:5ae8baf28e32 703 Pour mémoire, les réglage de priorité des thread
POTLESS_2 15:efd3b3bf3f37 704
POTLESS_2 43:5ae8baf28e32 705 osPriorityIdle = -3, ///< priority: idle (lowest)
POTLESS_2 43:5ae8baf28e32 706 osPriorityLow = -2, ///< priority: low
POTLESS_2 43:5ae8baf28e32 707 osPriorityBelowNormal = -1, ///< priority: below normal
POTLESS_2 43:5ae8baf28e32 708 osPriorityNormal = 0, ///< priority: normal (default)
POTLESS_2 43:5ae8baf28e32 709 osPriorityAboveNormal = +1, ///< priority: above normal
POTLESS_2 43:5ae8baf28e32 710 osPriorityHigh = +2, ///< priority: high
POTLESS_2 43:5ae8baf28e32 711 osPriorityRealtime = +3, ///< priority: realtime (highest)
POTLESS_2 43:5ae8baf28e32 712 osPriorityError = 0x84 ///< system cannot determine priority or thread has illegal priority
POTLESS_2 43:5ae8baf28e32 713 */
POTLESS_2 18:bfd78c05b589 714
POTLESS_2 43:5ae8baf28e32 715 wait(1);
POTLESS_2 20:5f79fb4565a7 716
POTLESS_2 43:5ae8baf28e32 717 Thread thread_Volets(osPriorityNormal);
POTLESS_2 43:5ae8baf28e32 718
POTLESS_2 43:5ae8baf28e32 719 thread_Volets.start(callback(GO_TO_thread));
POTLESS_2 12:7f3aadd79f89 720
POTLESS_2 43:5ae8baf28e32 721 //OUTPUT(" Contrôle des volets démarré\r\n\r\n");
POTLESS_2 43:5ae8baf28e32 722
POTLESS_2 43:5ae8baf28e32 723 wait(1);
POTLESS_2 34:26f6e3dbefb9 724
POTLESS_2 43:5ae8baf28e32 725 Thread thread_Secu(osPriorityNormal);
POTLESS_2 43:5ae8baf28e32 726
POTLESS_2 43:5ae8baf28e32 727 thread_Secu.start(callback(SECU_thread));
POTLESS_2 34:26f6e3dbefb9 728
POTLESS_2 43:5ae8baf28e32 729 //OUTPUT(" Contrôle des paramètres de sécu démarré\r\n\r\n");
POTLESS_2 43:5ae8baf28e32 730
POTLESS_2 43:5ae8baf28e32 731 wait(1);
POTLESS_2 43:5ae8baf28e32 732
POTLESS_2 43:5ae8baf28e32 733 Thread thread_Head(osPriorityNormal);
POTLESS_2 36:1f5e2247b073 734
POTLESS_2 43:5ae8baf28e32 735 thread_Head.start(callback(SENSORS_thread));
POTLESS_2 36:1f5e2247b073 736
POTLESS_2 43:5ae8baf28e32 737 //OUTPUT(" Tête capteurs démarrée\r\n\r\n");
POTLESS_2 43:5ae8baf28e32 738
POTLESS_2 43:5ae8baf28e32 739 wait(1);
POTLESS_2 9:04bfdfc029cb 740
POTLESS_2 43:5ae8baf28e32 741 //Init PID
POTLESS_2 43:5ae8baf28e32 742 //Entrée PPO2 entre 100 et 1000 mb
POTLESS_2 43:5ae8baf28e32 743 control_Servo.setInputLimits(Min_Input, Max_Input);
POTLESS_2 43:5ae8baf28e32 744 //Sortie servo entre 0 et 100 %
POTLESS_2 43:5ae8baf28e32 745 control_Servo.setOutputLimits(Min_Output, Max_Output);
POTLESS_2 43:5ae8baf28e32 746 //Mode auto au démarrage
POTLESS_2 43:5ae8baf28e32 747 control_Servo.setMode(MANUAL_MODE);
POTLESS_2 43:5ae8baf28e32 748 //Consigne à x mb
POTLESS_2 43:5ae8baf28e32 749 control_Servo.setSetPoint(consigne);
POTLESS_2 34:26f6e3dbefb9 750
POTLESS_2 43:5ae8baf28e32 751 //OUTPUT(" Cliquez sur le bouton help pour voir la liste des \r\n commandes administrateur disponibles.\r\n");
POTLESS_2 7:ad15c386e960 752
POTLESS_2 43:5ae8baf28e32 753
POTLESS_2 46:28298df0ac55 754 OUTPUT("$\r\n");
POTLESS_2 43:5ae8baf28e32 755 wait(0.5);
POTLESS_2 43:5ae8baf28e32 756 UTILS::Dir_Flash(&serialMonit);
POTLESS_2 43:5ae8baf28e32 757
POTLESS_2 47:89a088bc8866 758 serialMonit.attach(&callbackParam);
potless 45:61ba3cc4fc55 759
POTLESS_2 46:28298df0ac55 760 vusb_off_on.fall(&Stop_Sequence);
POTLESS_2 46:28298df0ac55 761
POTLESS_2 46:28298df0ac55 762 E5V = 1;
POTLESS_2 36:1f5e2247b073 763
POTLESS_2 47:89a088bc8866 764 buzzer.beep(1000,0.5);
POTLESS_2 47:89a088bc8866 765
POTLESS_2 43:5ae8baf28e32 766 while (true) {
POTLESS_2 36:1f5e2247b073 767
POTLESS_2 43:5ae8baf28e32 768 //Démarrage du Timer mesurant le temps d'éxecution du code
POTLESS_2 43:5ae8baf28e32 769 REAL_RATE.start();
POTLESS_2 36:1f5e2247b073 770
POTLESS_2 43:5ae8baf28e32 771 if (newParamFlag) {
POTLESS_2 43:5ae8baf28e32 772 DEEP_DEBUG(" From PC = %s\r\n", param);
POTLESS_2 43:5ae8baf28e32 773 Decoding_Message(param);
POTLESS_2 43:5ae8baf28e32 774 }
POTLESS_2 34:26f6e3dbefb9 775
POTLESS_2 43:5ae8baf28e32 776 //Fabrication de la chaine Date / heure
POTLESS_2 43:5ae8baf28e32 777 seconds = time(NULL);
POTLESS_2 43:5ae8baf28e32 778 char Time_buf[32];
POTLESS_2 43:5ae8baf28e32 779 strftime(Time_buf, 32, "%D %I-%M-%S ", localtime(&seconds));
POTLESS_2 19:cac3761a5d0b 780
POTLESS_2 43:5ae8baf28e32 781 //Fabrication de la chaine à enregistrer
POTLESS_2 43:5ae8baf28e32 782 sprintf(to_store,"<%s;%d;%d;%.2f;%d;%.2f;%.2f;%d;%d;%d;%.2f;%.2f;%d;%.3f;%.3f;%.3f;%d>",
POTLESS_2 43:5ae8baf28e32 783 Time_buf,
POTLESS_2 43:5ae8baf28e32 784 co2,
POTLESS_2 43:5ae8baf28e32 785 ppO2,
POTLESS_2 43:5ae8baf28e32 786 pression,
POTLESS_2 43:5ae8baf28e32 787 (int)OTU,
POTLESS_2 43:5ae8baf28e32 788 Temp1,
POTLESS_2 43:5ae8baf28e32 789 Temp2,
POTLESS_2 43:5ae8baf28e32 790 Humid,
POTLESS_2 43:5ae8baf28e32 791 CellO2_1,
POTLESS_2 43:5ae8baf28e32 792 CellO2_2,
POTLESS_2 43:5ae8baf28e32 793 volet_poumon_Position,
POTLESS_2 43:5ae8baf28e32 794 volet_fuite_Position,
POTLESS_2 43:5ae8baf28e32 795 FLAG_PID,
POTLESS_2 43:5ae8baf28e32 796 Kc,
POTLESS_2 43:5ae8baf28e32 797 Ti,
POTLESS_2 43:5ae8baf28e32 798 Td,
POTLESS_2 43:5ae8baf28e32 799 consigne
POTLESS_2 43:5ae8baf28e32 800 );
POTLESS_2 15:efd3b3bf3f37 801
POTLESS_2 15:efd3b3bf3f37 802
POTLESS_2 43:5ae8baf28e32 803 //Pour windev
POTLESS_2 43:5ae8baf28e32 804 if (FLAG_WINDEV) {
POTLESS_2 43:5ae8baf28e32 805 OUTPUT("%s\r\n", to_store);
POTLESS_2 43:5ae8baf28e32 806 }
POTLESS_2 43:5ae8baf28e32 807
POTLESS_2 43:5ae8baf28e32 808 //Pour l'IHM
POTLESS_2 46:28298df0ac55 809 if (FLAG_DISPLAY) {
POTLESS_2 46:28298df0ac55 810 IHM("%s\r\n", to_store);
POTLESS_2 46:28298df0ac55 811 }
POTLESS_2 43:5ae8baf28e32 812
POTLESS_2 43:5ae8baf28e32 813 //Vers le moniteur série
POTLESS_2 43:5ae8baf28e32 814 if (FLAG_AFF) {
potless 44:5cd6f84a62ec 815 NVIC_DisableIRQ(USART3_IRQn); // USART 2 si ARNSRS mais plus utilisé
POTLESS_2 43:5ae8baf28e32 816 Affichage();
potless 44:5cd6f84a62ec 817 NVIC_EnableIRQ(USART3_IRQn); // USART 2 si ARNSRS mais plus utilisé
POTLESS_2 43:5ae8baf28e32 818 }
POTLESS_2 12:7f3aadd79f89 819
POTLESS_2 43:5ae8baf28e32 820 //Enregistrement de la chaine
POTLESS_2 43:5ae8baf28e32 821 if (FLAG_REC) {
POTLESS_2 43:5ae8baf28e32 822 UTILS::Write_Flash_File(to_store, Log_File_Name);
POTLESS_2 43:5ae8baf28e32 823 count ++;
POTLESS_2 43:5ae8baf28e32 824 if (count > Max_Log_Size) {
POTLESS_2 43:5ae8baf28e32 825 Create_File_Name_Date();
POTLESS_2 43:5ae8baf28e32 826 sensors.Create_Header(Log_File_Name);
POTLESS_2 43:5ae8baf28e32 827 count = 0;
POTLESS_2 43:5ae8baf28e32 828 OUTPUT("$\r\n");
POTLESS_2 43:5ae8baf28e32 829 wait(0.5);
POTLESS_2 43:5ae8baf28e32 830 UTILS::Dir_Flash(&serialMonit);
POTLESS_2 34:26f6e3dbefb9 831 }
POTLESS_2 34:26f6e3dbefb9 832 }
POTLESS_2 43:5ae8baf28e32 833
POTLESS_2 43:5ae8baf28e32 834 //Update du PID
POTLESS_2 43:5ae8baf28e32 835 control_Servo.setProcessValue(ppO2);
POTLESS_2 43:5ae8baf28e32 836 //Nouvelle sortie servo fuite si on est pas en mode SECU
potless 45:61ba3cc4fc55 837 //if(!EN_MODE_SECU) Consigne_fuite = control_Servo.compute();
POTLESS_2 43:5ae8baf28e32 838
POTLESS_2 43:5ae8baf28e32 839 //Arrêt du Timer mesurant le temps d'éxecution du code
POTLESS_2 43:5ae8baf28e32 840 REAL_RATE.stop();
POTLESS_2 43:5ae8baf28e32 841 //Définition de la nouvelle valeur du temps d'échantillonage du PID.
POTLESS_2 43:5ae8baf28e32 842 RATE = REAL_RATE.read();
POTLESS_2 43:5ae8baf28e32 843 //Reset du Timer
POTLESS_2 43:5ae8baf28e32 844 REAL_RATE.reset();
POTLESS_2 43:5ae8baf28e32 845
POTLESS_2 43:5ae8baf28e32 846 //Pour ralentir le code à Ref_Time seconde fixe quelque soit les intéruptions du loop....
POTLESS_2 43:5ae8baf28e32 847 if (Ref_Time > RATE) {
POTLESS_2 43:5ae8baf28e32 848 RATE_TRUE = (Ref_Time - RATE) * 1000;
POTLESS_2 43:5ae8baf28e32 849 } else {
POTLESS_2 43:5ae8baf28e32 850 RATE_TRUE = 0;
POTLESS_2 43:5ae8baf28e32 851
POTLESS_2 43:5ae8baf28e32 852 //control_Servo.setInterval(RATE);
POTLESS_2 43:5ae8baf28e32 853
POTLESS_2 43:5ae8baf28e32 854 DEEP_DEBUG("Pour ralentir le code, Ref_Time doit être supérieur à %f seconde(s)\r\n\n", RATE);
POTLESS_2 43:5ae8baf28e32 855 }
POTLESS_2 43:5ae8baf28e32 856
POTLESS_2 43:5ae8baf28e32 857 wait_ms(RATE_TRUE);
POTLESS_2 34:26f6e3dbefb9 858 }
POTLESS_2 4:d84250f67dec 859 }
POTLESS_2 43:5ae8baf28e32 860
POTLESS_2 43:5ae8baf28e32 861