test de premier push

Dependencies:   WakeUp mbed EPD_GDE021A1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002     main.cpp comportant la machine d'état.
00003     Les fonctions appelées par ce main doivent être déclarées dans des headers.
00004  */
00005 
00006 #include <stdio.h>
00007 #include "mbed.h"
00008 #include "WakeUp.h"
00009 #include "../Headers/period.h"
00010 #include "../Headers/states.h"
00011 #include "../Headers/constants.h"
00012 #include "../Headers/ecran.h"
00013 #include "../Headers/poids.h"
00014 #include "../Headers/send.h"
00015 #include "../Headers/refreshScreen.h"
00016 #include "../Headers/standby.h"
00017 
00018 
00019 Serial pc(USBTX, USBRX);    // serie USB (ne pas oublier de souder sur la carte)
00020 InterruptIn bouton(PA_0);   // bouton bleu en interuption     
00021 
00022 State state = Start;        // état de base : start
00023 int poidsRuche;
00024 
00025 int poids = 17;
00026 int temp = 21;
00027 int hum = 92;
00028 
00029 int main ()
00030 {
00031     //Ecran::print;
00032     refreshScreen();
00033     poidsRuche = Poids::get();
00034     while(true)
00035     {
00036         bouton.rise(&refreshScreen);
00037         switch(state)
00038         {
00039             case Start:
00040                 pc.printf("State Start\n");
00041                 //TODO Test jour ou nuit
00042 
00043                 //TODO SI jour, Etat suivant = DeepSleepShort
00044                 //TODO SI nuit, Etat suivant = DeepSleepLong
00045                 state = Send;
00046                 break;
00047             case DeepSleepShort:
00048                 pc.printf("State DeepSleepShort\n");
00049                 standby(DEEPSLEEP_SHORT_DURATION);
00050                 state = Start;
00051                 break;
00052             case DeepSleepLong:
00053                 pc.printf("State DeepSleepLong\n");
00054                 standby(DEEPSLEEP_LONG_DURATION);
00055                 state = Start;
00056                 break;
00057             case MesPHT:
00058                 pc.printf("State MesPHT\n");
00059                 //TODO Ajouter appel à mesPHT(...)
00060 
00061                 //TODO Test poids
00062 
00063                 //TODO SI poids < 5 Kg, Etat suivant = MesGPS
00064                 //TODO SINON Etat suivant = Send
00065                 break;
00066             case MesGPS:
00067                 pc.printf("State MesGPS\n");
00068                 //TODO Ajouter appel à mesGPS(...)
00069                 break;
00070             case Send:
00071                 pc.printf("State Send\n");
00072                 //TODO Ajouter appel à send(...)
00073                 send(poids,temp,hum);
00074                 //TODO Test jour ou nuit
00075 
00076                 //TODO SI jour, Etat suivant = DeepSleepShort
00077                 //TODO SI nuit, Etat suivant = DeepSleepLong
00078                 state = Start;
00079                 break;
00080             default:
00081                 pc.printf("State Error\n");
00082                 state = Start;
00083         }//end switch
00084     }//end while
00085 }//end main