programme final projet s4
Dependencies: BSP_DISCO_F746NG SDFileSystem TS_DISCO_F746NG affichage_des_ecrans mbed rtc_lib
main_glb.cpp
- Committer:
- Asoumy
- Date:
- 2016-10-14
- Revision:
- 3:53f3194a919e
- Parent:
- 2:a6c2f346bca5
- Child:
- 4:c6e9b4449a5f
File content as of revision 3:53f3194a919e:
#include "mbed.h" #include "TS_DISCO_F746NG.h" #include "LCD_DISCO_F746NG.h" #include "ds1338.h" #include "horloge.h" #include "Ecran.h" //définition de la zone tactile dans l'ecran principal #define TOUCHADMINISTRATEUR ((TS_State.touchDetected) && ( TS_State.touchX[0]>0) &&( TS_State.touchX[0]< 240)&& ( TS_State.touchY[0]>0) && (TS_State.touchY[0] < 272)) #define TOUCHUTILISATEUR ((TS_State.touchDetected) && ( TS_State.touchX[0]> 240) &&( TS_State.touchX[0]< 480)&& ( TS_State.touchY[0]> 0) && (TS_State.touchY[0] < 272)) // définitions des touches tactiles qui interviennent dans l'écran 1 #define TOUCHTIMEDATE ((TS_State.touchDetected) && ( TS_State.touchX[0]>10) && (TS_State.touchX[0]< 165)&& (TS_State.touchY[0]>50) && (TS_State.touchY[0] < 180)) #define TOUCHFREQ ((TS_State.touchDetected) && ( TS_State.touchX[0]>170) && (TS_State.touchX[0]< 328)&& (TS_State.touchY[0]>60) && (TS_State.touchY[0] < 180)) #define TOUCHAFFICHAGE ((TS_State.touchDetected) && ( TS_State.touchX[0]>333) &&( TS_State.touchX[0]< 475)&& ( TS_State.touchY[0]> 60) && (TS_State.touchY[0] < 180)) //définitions des touches tactiles qui intervient dans les écrans paramettrable #define TOUCHRETOUR ((TS_State.touchDetected) && ( TS_State.touchX[0]>30) &&( TS_State.touchX[0]< 110)&& ( TS_State.touchY[0]> 210) && (TS_State.touchY[0] < 240)) #define TOUCHMoins ((TS_State.touchDetected) && ( TS_State.touchX[0]>145) &&( TS_State.touchX[0]< 225)&& ( TS_State.touchY[0]> 210) && (TS_State.touchY[0] < 240)) #define TOUCHPlus ((TS_State.touchDetected) && ( TS_State.touchX[0]> 245) &&( TS_State.touchX[0]< 325)&& ( TS_State.touchY[0]> 210) && (TS_State.touchY[0] < 240)) #define TOUCHOK ((TS_State.touchDetected) && ( TS_State.touchX[0]> 360) &&( TS_State.touchX[0]< 440)&& ( TS_State.touchY[0]> 210) && (TS_State.touchY[0] < 240)) //définitions des touches tactiles pour régler l'heure et la date #define TOUCHDAY ((TS_State.touchDetected) && ( TS_State.touchX[0]> 30) &&( TS_State.touchX[0]< 85)&& ( TS_State.touchY[0]> 82) && (TS_State.touchY[0] < 110)) #define TOUCHMonth ((TS_State.touchDetected) && ( TS_State.touchX[0]> 100) &&( TS_State.touchX[0]< 160)&& ( TS_State.touchY[0]> 82) && (TS_State.touchY[0] < 110)) #define TOUCHYear ((TS_State.touchDetected) && ( TS_State.touchX[0]> 170) &&( TS_State.touchX[0]< 240)&& ( TS_State.touchY[0]> 82) && (TS_State.touchY[0] < 110)) #define TOUCHHour ((TS_State.touchDetected) && ( TS_State.touchX[0]> 30) &&( TS_State.touchX[0]< 60)&& ( TS_State.touchY[0]> 164) && (TS_State.touchY[0] < 204)) #define TOUCHMinute ((TS_State.touchDetected) && ( TS_State.touchX[0]> 100) &&( TS_State.touchX[0]< 159)&& ( TS_State.touchY[0]> 164) && (TS_State.touchY[0] < 204)) #define TOUCHSeconde ((TS_State.touchDetected) && ( TS_State.touchX[0]> 172) &&( TS_State.touchX[0]< 240)&& ( TS_State.touchY[0]> 164) && (TS_State.touchY[0] < 204)) //définition des touches tactiles pour le réglage de la fréquence d'envoi des données sur la carte SD #define TOUCHPerHour ((TS_State.touchDetected) && ( TS_State.touchX[0]> 25) &&( TS_State.touchX[0]< 175)&& ( TS_State.touchY[0]> 115) && (TS_State.touchY[0] < 145)) #define TOUCHPerDay ((TS_State.touchDetected) && ( TS_State.touchX[0]> 245) &&( TS_State.touchX[0]< 405)&& ( TS_State.touchY[0]> 115) && (TS_State.touchY[0] < 145)) #define TOUCHPerWeek ((TS_State.touchDetected) && ( TS_State.touchX[0]> 25) &&( TS_State.touchX[0]< 175)&& ( TS_State.touchY[0]> 155) && (TS_State.touchY[0] < 185)) #define TOUCHPermonth ((TS_State.touchDetected) && ( TS_State.touchX[0]> 245) &&( TS_State.touchX[0]< 405)&& ( TS_State.touchY[0]> 155) && (TS_State.touchY[0] < 185)) //définition de l'attente avant l'affichage d'un nouvel écran #define ATTENTE wait(0.2); int affiche=0; /*void horloge(); char jour[6]; char mois[6]; char annee[6]; char heure[6]; char minute[6]; char seconde[6]; */ TS_DISCO_F746NG ts; DigitalOut led1(LED1); int main() { DS1338 ds1338(D14,D15); wait(0.5); void principal(); struct tm time; wait(1); affiche=1; TS_StateTypeDef TS_State; ts.Init(480, 272); ds1338.writeTime(&time); while(1) { ts.GetState(&TS_State); ds1338.readTime(&time); typedef enum {etat0, etat1, etat1_1,etat_reg_minute, etat3, etat4 ,etat2, etat_reg_day, etat_reg_month,etat_reg_year, etat_reg_hour} type_etat; static type_etat etat= etat0; switch (etat) { case etat0: if (affiche==1) { Ecranprincipal (); affiche=0; } if (TOUCHUTILISATEUR) { etat= etat1_1; affiche=1; ATTENTE } if (TOUCHADMINISTRATEUR) { etat= etat1; affiche=1; ATTENTE } break; case etat1_1: if(affiche==1) { ATTENTE EcranUtilis (); affiche=0; } /*if (TOUCHAFF) { etat=etat4; affiche=1; }*/ if (TOUCHRETOUR) { etat= etat0; affiche=1; ATTENTE } break; case etat1: if (affiche==1) { ATTENTE EcranAdminis (); ; affiche=0; } if (TOUCHTIMEDATE) { etat = etat2; affiche=1; } if (TOUCHFREQ) { etat= etat3; affiche=1; } if (TOUCHAFFICHAGE) { etat=etat4; affiche=1; } if (TOUCHRETOUR) { etat= etat0; affiche=1; ATTENTE; } break; case etat2: if (affiche==1) { Ecran2(); affiche=0; } if (TOUCHRETOUR) { etat= etat1; affiche=1; ATTENTE } if (TOUCHDAY) { etat= etat_reg_day; affiche=1; } if (TOUCHMonth) { etat=etat_reg_month; affiche=1; } if (TOUCHYear) { etat=etat_reg_year; affiche=1; } if (TOUCHHour) { etat=etat_reg_hour; affiche=1; } if (TOUCHMinute) { etat=etat_reg_minute; affiche=1; } if (TOUCHRETOUR) { etat= etat1; affiche=1; ATTENTE } if (TOUCHSeconde) { time.tm_sec=0; affiche=1; } break; case etat_reg_day: if (affiche==1) { Ecran2_Day(); affiche=0; } if(TOUCHPlus){ time.tm_mday=time.tm_mday+1; ATTENTE Ecran2_Day(); //if(day>30) day=0; } if(TOUCHMoins) { time.tm_mday=time.tm_mday-1; wait (0.3); Ecran2_Day(); //if(day<2) day=32; } if ( (TOUCHOK)||(TOUCHRETOUR) ) { etat= etat2; affiche=1; ATTENTE } break; case etat_reg_month: if (affiche==1){ Ecran2_Month(); affiche=0; } if(TOUCHPlus) { time.tm_mon=time.tm_mon+1; ATTENTE Ecran2_Month(); //if(month>11) month=0; } if(TOUCHMoins) { time.tm_mon=time.tm_mon-1; ATTENTE Ecran2_Month(); //if(month<2) month=13; } if ( (TOUCHOK)|| (TOUCHRETOUR)) { etat= etat2; affiche=1; ATTENTE } break; case etat_reg_year: if (affiche==1){ Ecran2_Year (); affiche=0; } if(TOUCHPlus) { time.tm_year=time.tm_year+1; ATTENTE Ecran2_Year(); //if(year>3000) year=2000; } if(TOUCHMoins) { time.tm_year=time.tm_year-1; ATTENTE Ecran2_Year(); //if(year<2000) year=3000; } if ((TOUCHOK) ||(TOUCHRETOUR)) { etat= etat2; affiche=1; ATTENTE } break; case etat_reg_hour: if (affiche==1){ affiche=0; Ecran2_Hour(); } if(TOUCHPlus){ time.tm_hour=time.tm_hour+1; ATTENTE Ecran2_Hour(); //if(hour>22) hour=0; } if(TOUCHMoins){ time.tm_hour=time.tm_hour-1; ATTENTE Ecran2_Hour(); //if(hour<1) hour=24; } if ((TOUCHOK)||(TOUCHRETOUR)){ etat= etat2; affiche=1; ATTENTE } break; case etat_reg_minute: if (affiche==1) { Ecran2_Minutes(); affiche=0; } if(TOUCHPlus) { time.tm_min=time.tm_min+1; ATTENTE Ecran2_Minutes(); //if(min>58) min=0; } if(TOUCHMoins) { time.tm_min=time.tm_min-1; wait (0.3); Ecran2_Minutes(); //if(min>2) min=59; } if ((TOUCHOK) || (TOUCHRETOUR)){ etat= etat2; affiche=1; ATTENTE } break; case etat3: if (affiche==1) { Ecran3(); affiche=0; } if (TOUCHRETOUR) { etat= etat1; affiche=1; ATTENTE } break; case etat4: if (affiche==1) { Ecran4(); affiche=0; } if (TOUCHRETOUR) { etat= etat1; affiche=1; ATTENTE } break; } } }