Soufflerie SP3 - 2 -2021

Dependencies:   C12832 bouton LM75B WifiEsp8266 Acquisitionentree Affichagesp3

Revision:
0:9a4606bcc07c
Child:
1:ecde61802f48
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun May 23 13:20:55 2021 +0000
@@ -0,0 +1,69 @@
+// acquerir la temperature avec le LM75B
+// acquerir consigne avec Pot1
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+#include "LM75B.h"
+#include "acquisition.h"
+#include "affichage.h"
+#include "wifiesp8266.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);
+
+Ticker test;
+bool Drticker = false;
+void event()
+{
+    Drticker = true;
+}
+
+int main()
+{
+    float mesure, mesure1;
+    float AngleIncCons;
+    bool ecranchange=false;
+    char WifiPhrase[22];
+    PC.baud(921600);
+    PC.printf("Hello SP3\r\n");
+    AffichageEcran(mesure,AngleIncCons);
+    test.attach(&event,1);
+    InitBouton();
+    char bouton;
+    while (true) {
+        bouton = EtatBouton();
+        if (bouton!=Nochange) {
+            Wifi.printf("$%c\n\r",bouton);        
+        }
+        if (Wifi.dataready()) {
+            strcpy(WifiPhrase,Wifi.read());
+            switch (WifiPhrase[1]) {
+                case 'l':
+                    AngleIncCons = atof(WifiPhrase+2);
+                    ecranchange=true;
+                    break;
+                case 'a':
+                    mesure = atof(WifiPhrase+2);
+                    ecranchange=true;
+                    break;                    
+                default :
+                    PC.printf("%s\r\n",WifiPhrase);
+            }
+        }
+        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);
+            ecranchange=false;
+        }
+    }
+}
+