capteur de mouvement
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG
main.cpp
00001 #include "mbed.h" 00002 #include "LCD_DISCO_F746NG.h" 00003 #include "TS_DISCO_F746NG.h" 00004 00005 LCD_DISCO_F746NG lcd; 00006 TS_DISCO_F746NG boutton; 00007 00008 DigitalOut led1(LED1); 00009 DigitalIn detecteur(D1); // sortie du capteur PIR 00010 00011 int x,y; 00012 00013 int main() 00014 { 00015 while(1) { 00016 int idx = 0; 00017 bool fini = true; 00018 //uint8_t init; 00019 //init = boutton.Init(lcd.GetXSize(),lcd.GetYSize());//initialisation du bouton 00020 TS_StateTypeDef TS_State;//etat du tacticle 00021 lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"ALARME", CENTER_MODE); 00022 00023 while(fini) { 00024 if (detecteur.read()== 0) { 00025 lcd.Clear(LCD_COLOR_BLACK);//effacer l'ecran 00026 lcd.SetTextColor(LCD_COLOR_RED); 00027 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Aucun Mouvement Detecte", CENTER_MODE); 00028 wait(1); 00029 lcd.SetTextColor(LCD_COLOR_GREEN); //affichage rond vert 00030 lcd.FillCircle(50, 50, 40); 00031 wait(1); 00032 lcd.Clear(LCD_COLOR_BLACK); 00033 00034 } else { 00035 lcd.Clear(LCD_COLOR_BLACK); 00036 lcd.SetTextColor(LCD_COLOR_RED); 00037 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Mouvement Detecte", CENTER_MODE); 00038 wait(1); 00039 00040 lcd.SetTextColor(LCD_COLOR_RED);//affichage rond rouge 00041 lcd.FillCircle(50, 50, 40); 00042 wait(1); 00043 00044 00045 lcd.Clear(LCD_COLOR_BLACK); 00046 lcd.SetBackColor(LCD_COLOR_BLACK); 00047 lcd.SetTextColor(LCD_COLOR_WHITE); 00048 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Arret alarme", CENTER_MODE);//demande d'arret alarme 00049 00050 lcd.SetTextColor(LCD_COLOR_WHITE); 00051 lcd.DrawRect(150,150,180,50); 00052 lcd.DisplayStringAt(3, LINE(7), (uint8_t *)"Stop", CENTER_MODE);//bouton stop 00053 wait(1); 00054 00055 boutton.GetState(&TS_State); 00056 if (TS_State.touchDetected) { 00057 x = TS_State.touchX[idx];//position du touché tactile 00058 y = TS_State.touchY[idx]; 00059 lcd.SetTextColor(LCD_COLOR_GREEN);//affichage rond vert si arret alarme 00060 lcd.FillCircle(50,50, 40); 00061 wait(1); 00062 lcd.Clear(LCD_COLOR_BLACK); 00063 fini = false; 00064 } 00065 } 00066 fini = true; 00067 00068 } 00069 00070 } 00071 00072 } 00073
Generated on Thu Aug 25 2022 13:34:27 by 1.7.2