Soufflerie SP3 - 2 -2021
Dependencies: C12832 bouton LM75B WifiEsp8266 Acquisitionentree Affichagesp3
main.cpp@1:ecde61802f48, 2021-06-06 (annotated)
- Committer:
- schnf30
- Date:
- Sun Jun 06 12:15:12 2021 +0000
- Revision:
- 1:ecde61802f48
- Parent:
- 0:9a4606bcc07c
- Child:
- 2:66c7279cda7c
3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
schnf30 | 0:9a4606bcc07c | 1 | // acquerir la temperature avec le LM75B |
schnf30 | 0:9a4606bcc07c | 2 | // acquerir consigne avec Pot1 |
schnf30 | 0:9a4606bcc07c | 3 | #include "mbed.h" |
schnf30 | 0:9a4606bcc07c | 4 | #include "platform/mbed_thread.h" |
schnf30 | 0:9a4606bcc07c | 5 | #include "LM75B.h" |
schnf30 | 0:9a4606bcc07c | 6 | #include "acquisition.h" |
schnf30 | 0:9a4606bcc07c | 7 | #include "affichage.h" |
schnf30 | 1:ecde61802f48 | 8 | #include "wifiesp8266sp3.h" |
schnf30 | 0:9a4606bcc07c | 9 | #include "bouton.h" |
schnf30 | 0:9a4606bcc07c | 10 | #include <stdlib.h> |
schnf30 | 0:9a4606bcc07c | 11 | |
schnf30 | 1:ecde61802f48 | 12 | float VitFluxAir = 0; |
schnf30 | 1:ecde61802f48 | 13 | float ConsigneFluxAir = 0; |
schnf30 | 1:ecde61802f48 | 14 | float Freqhelice = 0; |
schnf30 | 1:ecde61802f48 | 15 | float Temperature = 0; |
schnf30 | 1:ecde61802f48 | 16 | float humidite = 0; |
schnf30 | 1:ecde61802f48 | 17 | float pression[8] = {0,0,0,0,0,0,0,0}; |
schnf30 | 1:ecde61802f48 | 18 | float Fx = 0; |
schnf30 | 1:ecde61802f48 | 19 | float Fz = 0; |
schnf30 | 1:ecde61802f48 | 20 | float Aim = 0; |
schnf30 | 1:ecde61802f48 | 21 | float Aic = 0; |
schnf30 | 0:9a4606bcc07c | 22 | |
schnf30 | 1:ecde61802f48 | 23 | RawSerial PC(USBTX, USBRX); |
schnf30 | 1:ecde61802f48 | 24 | WifiEsp8266sp3 Wifi(PA_11,PA_12); // WifiEsp8266(PinName Txd, PinName Rxd); |
schnf30 | 1:ecde61802f48 | 25 | DigitalOut En(PC_11); |
schnf30 | 0:9a4606bcc07c | 26 | |
schnf30 | 0:9a4606bcc07c | 27 | int main() |
schnf30 | 0:9a4606bcc07c | 28 | { |
schnf30 | 0:9a4606bcc07c | 29 | float mesure, mesure1; |
schnf30 | 0:9a4606bcc07c | 30 | float AngleIncCons; |
schnf30 | 1:ecde61802f48 | 31 | En.write(1); |
schnf30 | 0:9a4606bcc07c | 32 | bool ecranchange=false; |
schnf30 | 1:ecde61802f48 | 33 | char WifiPhrase[maxdata]; |
schnf30 | 0:9a4606bcc07c | 34 | PC.baud(921600); |
schnf30 | 0:9a4606bcc07c | 35 | PC.printf("Hello SP3\r\n"); |
schnf30 | 1:ecde61802f48 | 36 | AffichageEcran(); |
schnf30 | 0:9a4606bcc07c | 37 | InitBouton(); |
schnf30 | 0:9a4606bcc07c | 38 | char bouton; |
schnf30 | 0:9a4606bcc07c | 39 | while (true) { |
schnf30 | 0:9a4606bcc07c | 40 | bouton = EtatBouton(); |
schnf30 | 0:9a4606bcc07c | 41 | if (bouton!=Nochange) { |
schnf30 | 0:9a4606bcc07c | 42 | Wifi.printf("$%c\n\r",bouton); |
schnf30 | 0:9a4606bcc07c | 43 | } |
schnf30 | 0:9a4606bcc07c | 44 | if (Wifi.dataready()) { |
schnf30 | 0:9a4606bcc07c | 45 | strcpy(WifiPhrase,Wifi.read()); |
schnf30 | 1:ecde61802f48 | 46 | PC.printf("%s\r\n",WifiPhrase); |
schnf30 | 0:9a4606bcc07c | 47 | switch (WifiPhrase[1]) { |
schnf30 | 1:ecde61802f48 | 48 | case 'A': |
schnf30 | 1:ecde61802f48 | 49 | VitFluxAir = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 50 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 51 | break; |
schnf30 | 1:ecde61802f48 | 52 | case 'B': |
schnf30 | 1:ecde61802f48 | 53 | ConsigneFluxAir = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 54 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 55 | break; |
schnf30 | 1:ecde61802f48 | 56 | case 'C': |
schnf30 | 1:ecde61802f48 | 57 | Freqhelice = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 58 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 59 | break; |
schnf30 | 1:ecde61802f48 | 60 | case 'D': |
schnf30 | 1:ecde61802f48 | 61 | Temperature = atof(WifiPhrase+2); |
schnf30 | 0:9a4606bcc07c | 62 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 63 | break; |
schnf30 | 1:ecde61802f48 | 64 | case 'E': |
schnf30 | 1:ecde61802f48 | 65 | humidite = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 66 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 67 | break; |
schnf30 | 1:ecde61802f48 | 68 | case 'Z': |
schnf30 | 1:ecde61802f48 | 69 | if (sscanf(WifiPhrase,"$Z,%f,%f,%f",&VitFluxAir,&Temperature,&humidite)>=1) ecranchange=true; |
schnf30 | 1:ecde61802f48 | 70 | break; |
schnf30 | 0:9a4606bcc07c | 71 | case 'a': |
schnf30 | 1:ecde61802f48 | 72 | pression[0] = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 73 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 74 | break; |
schnf30 | 1:ecde61802f48 | 75 | case 'b': |
schnf30 | 1:ecde61802f48 | 76 | pression[1] = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 77 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 78 | break; |
schnf30 | 1:ecde61802f48 | 79 | case 'c': |
schnf30 | 1:ecde61802f48 | 80 | pression[2] = atof(WifiPhrase+2); |
schnf30 | 0:9a4606bcc07c | 81 | ecranchange=true; |
schnf30 | 0:9a4606bcc07c | 82 | break; |
schnf30 | 1:ecde61802f48 | 83 | case 'd': |
schnf30 | 1:ecde61802f48 | 84 | pression[3] = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 85 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 86 | break; |
schnf30 | 1:ecde61802f48 | 87 | case 'e': |
schnf30 | 1:ecde61802f48 | 88 | pression[4] = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 89 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 90 | break; |
schnf30 | 1:ecde61802f48 | 91 | case 'f': |
schnf30 | 1:ecde61802f48 | 92 | pression[5] = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 93 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 94 | break; |
schnf30 | 1:ecde61802f48 | 95 | case 'g': |
schnf30 | 1:ecde61802f48 | 96 | pression[6] = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 97 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 98 | break; |
schnf30 | 1:ecde61802f48 | 99 | case 'h': |
schnf30 | 1:ecde61802f48 | 100 | pression[7] = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 101 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 102 | break; |
schnf30 | 1:ecde61802f48 | 103 | case 'i': |
schnf30 | 1:ecde61802f48 | 104 | Fx = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 105 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 106 | break; |
schnf30 | 1:ecde61802f48 | 107 | case 'j': |
schnf30 | 1:ecde61802f48 | 108 | Fz = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 109 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 110 | break; |
schnf30 | 1:ecde61802f48 | 111 | case 'k': |
schnf30 | 1:ecde61802f48 | 112 | Aim = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 113 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 114 | break; |
schnf30 | 1:ecde61802f48 | 115 | case 'l': |
schnf30 | 1:ecde61802f48 | 116 | Aic = atof(WifiPhrase+2); |
schnf30 | 1:ecde61802f48 | 117 | ecranchange=true; |
schnf30 | 1:ecde61802f48 | 118 | break; |
schnf30 | 1:ecde61802f48 | 119 | case 'z': |
schnf30 | 1:ecde61802f48 | 120 | 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; |
schnf30 | 1:ecde61802f48 | 121 | break; |
schnf30 | 1:ecde61802f48 | 122 | default : ; |
schnf30 | 0:9a4606bcc07c | 123 | } |
schnf30 | 0:9a4606bcc07c | 124 | } |
schnf30 | 0:9a4606bcc07c | 125 | if (ecranchange) { |
schnf30 | 1:ecde61802f48 | 126 | AffichageEcran(); |
schnf30 | 0:9a4606bcc07c | 127 | ecranchange=false; |
schnf30 | 0:9a4606bcc07c | 128 | } |
schnf30 | 0:9a4606bcc07c | 129 | } |
schnf30 | 0:9a4606bcc07c | 130 | } |
schnf30 | 0:9a4606bcc07c | 131 |