Soufflerie SP3 - 2 -2021
Dependencies: C12832 bouton LM75B WifiEsp8266 Acquisitionentree Affichagesp3
Diff: main.cpp
- Revision:
- 1:ecde61802f48
- Parent:
- 0:9a4606bcc07c
- Child:
- 2:66c7279cda7c
diff -r 9a4606bcc07c -r ecde61802f48 main.cpp --- a/main.cpp Sun May 23 13:20:55 2021 +0000 +++ b/main.cpp Sun Jun 06 12:15:12 2021 +0000 @@ -5,32 +5,35 @@ #include "LM75B.h" #include "acquisition.h" #include "affichage.h" -#include "wifiesp8266.h" +#include "wifiesp8266sp3.h" #include "bouton.h" #include <stdlib.h> -RawSerial PC(USBTX, USBRX); -WifiEsp8266 Wifi(PA_11,PA_12,PC_11); // WifiEsp8266(PinName Txd, PinName Rxd, PinName En); - -LM75B sensor(D14,D15); +float VitFluxAir = 0; +float ConsigneFluxAir = 0; +float Freqhelice = 0; +float Temperature = 0; +float humidite = 0; +float pression[8] = {0,0,0,0,0,0,0,0}; +float Fx = 0; +float Fz = 0; +float Aim = 0; +float Aic = 0; -Ticker test; -bool Drticker = false; -void event() -{ - Drticker = true; -} +RawSerial PC(USBTX, USBRX); +WifiEsp8266sp3 Wifi(PA_11,PA_12); // WifiEsp8266(PinName Txd, PinName Rxd); +DigitalOut En(PC_11); int main() { float mesure, mesure1; float AngleIncCons; + En.write(1); bool ecranchange=false; - char WifiPhrase[22]; + char WifiPhrase[maxdata]; PC.baud(921600); PC.printf("Hello SP3\r\n"); - AffichageEcran(mesure,AngleIncCons); - test.attach(&event,1); + AffichageEcran(); InitBouton(); char bouton; while (true) { @@ -40,28 +43,87 @@ } if (Wifi.dataready()) { strcpy(WifiPhrase,Wifi.read()); + PC.printf("%s\r\n",WifiPhrase); switch (WifiPhrase[1]) { - case 'l': - AngleIncCons = atof(WifiPhrase+2); + case 'A': + VitFluxAir = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'B': + ConsigneFluxAir = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'C': + Freqhelice = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'D': + Temperature = atof(WifiPhrase+2); ecranchange=true; - break; + break; + case 'E': + humidite = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'Z': + if (sscanf(WifiPhrase,"$Z,%f,%f,%f",&VitFluxAir,&Temperature,&humidite)>=1) ecranchange=true; + break; case 'a': - mesure = atof(WifiPhrase+2); + pression[0] = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'b': + pression[1] = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'c': + pression[2] = atof(WifiPhrase+2); ecranchange=true; break; - default : - PC.printf("%s\r\n",WifiPhrase); + case 'd': + pression[3] = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'e': + pression[4] = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'f': + pression[5] = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'g': + pression[6] = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'h': + pression[7] = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'i': + Fx = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'j': + Fz = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'k': + Aim = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'l': + Aic = atof(WifiPhrase+2); + ecranchange=true; + break; + case 'z': + if (sscanf(WifiPhrase,"$z,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",pression,pression+1,pression+2,pression+3,pression+4,pression+5,pression+6,pression+7,&Fx,&Fz,&Aim)>=1) ecranchange=true; + break; + default : ; } } - if (Drticker) { - Drticker = false; - mesure1 = sensor.read(); - ecranchange=true; - Wifi.printf("$B%f\r\n",mesure1); - Wifi.printf("$b%f\r\n",mesure1); - } if (ecranchange) { - AffichageEcran(mesure,AngleIncCons); + AffichageEcran(); ecranchange=false; } }