vers 2

Dependencies:   Affichagesp2 C12832 LM75B WifiEsp8266 Acquisitionentreesp2

main.cpp

Committer:
schnf30
Date:
18 months ago
Revision:
0:7b66b529c674
Child:
1:c7890e7c361e

File content as of revision 0:7b66b529c674:

// acquerir la temperature avec le LM75B
#include "mbed.h"
#include "platform/mbed_thread.h"
#include "LM75B.h"
#include "acquisition.h"
#include "affichage.h"
#include "wifiesp8266.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 test1;
bool Drticker1 = false;
void event1()
{
    Drticker1 = true;
}

int main()
{
    char WifiPhrase[22];
    float mesure=0;
    float AngleIncCons = 25;
    bool ecranchange=false;
    AffichageEcran(mesure,AngleIncCons);
    PC.baud(921600);
    PC.printf("Hello je suis SP2\r\n");
    test1.attach(&event1,1);
    while (true) {
        if (Wifi.dataready()) {
            strcpy(WifiPhrase,Wifi.read());
            switch (WifiPhrase[1]) {
                case 'm':
                    AngleIncCons=AngleIncCons+1;
                    Wifi.printf("$l%f\r\n",AngleIncCons);         
                    ecranchange=true;
                    break;
                case 'n' :
                    AngleIncCons=AngleIncCons-1;
                    Wifi.printf("$l%f\r\n",AngleIncCons);             
                    ecranchange=true;
                    break;
                default :
                    PC.printf("%s\r\n",WifiPhrase);
            }

        }
        if (Drticker1) {
            Drticker1 = false;
            mesure = sensor.read();
            Wifi.printf("$a%f\r\n",mesure);
            ecranchange=true;
        } 
        if (ecranchange) {
            AffichageEcran(mesure,AngleIncCons);
            ecranchange=false;
        }
    }
}