projet interfaçage

Dependencies:   Servo BSP_DISCO_F746NG

Committer:
maxenceadnot
Date:
Mon Jun 21 09:08:58 2021 +0000
Revision:
4:e629702e7738
Parent:
3:9f66aabe7b3b
projet adnot

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:9933f7db9a9b 1 #include "mbed.h"
maxenceadnot 4:e629702e7738 2 #include "Servo.h"
Jerome Coutant 3:9f66aabe7b3b 3 #include "stm32746g_discovery_lcd.h"
Jerome Coutant 3:9f66aabe7b3b 4 #include "stm32746g_discovery_ts.h"
maxenceadnot 4:e629702e7738 5
maxenceadnot 4:e629702e7738 6 TS_StateTypeDef TS_State;
maxenceadnot 4:e629702e7738 7 uint16_t x, y;
bcostm 0:9933f7db9a9b 8 uint8_t text[30];
bcostm 0:9933f7db9a9b 9 uint8_t status;
bcostm 0:9933f7db9a9b 10 uint8_t idx;
bcostm 0:9933f7db9a9b 11 uint8_t cleared = 0;
bcostm 0:9933f7db9a9b 12 uint8_t prev_nb_touches = 0;
maxenceadnot 4:e629702e7738 13
maxenceadnot 4:e629702e7738 14 PwmOut servo_mot(D6);
bcostm 0:9933f7db9a9b 15
maxenceadnot 4:e629702e7738 16 InterruptIn motion(D7); // ir
maxenceadnot 4:e629702e7738 17 DigitalOut buzzer(D5); //buzzer
maxenceadnot 4:e629702e7738 18 int on = 1, off = 0; //buzzer
maxenceadnot 4:e629702e7738 19 int motion_detected = 0;//ir
maxenceadnot 4:e629702e7738 20 int code=0;
maxenceadnot 4:e629702e7738 21 int positionCode=0;
maxenceadnot 4:e629702e7738 22 int touchh=0;
maxenceadnot 4:e629702e7738 23 int activer=0;
maxenceadnot 4:e629702e7738 24 int cnt = 0;//ir
maxenceadnot 4:e629702e7738 25
maxenceadnot 4:e629702e7738 26 void irq_handler(void)// void ir
maxenceadnot 4:e629702e7738 27 {
maxenceadnot 4:e629702e7738 28 motion_detected = 1;
maxenceadnot 4:e629702e7738 29 }
maxenceadnot 4:e629702e7738 30
maxenceadnot 4:e629702e7738 31 void alarme(){
maxenceadnot 4:e629702e7738 32 if(motion_detected) { //if ir
maxenceadnot 4:e629702e7738 33 cnt++;
maxenceadnot 4:e629702e7738 34 buzzer = on;
maxenceadnot 4:e629702e7738 35
maxenceadnot 4:e629702e7738 36 BSP_LCD_FillRect (20, 255, 15, 15);
maxenceadnot 4:e629702e7738 37
maxenceadnot 4:e629702e7738 38 }
maxenceadnot 4:e629702e7738 39
maxenceadnot 4:e629702e7738 40 }
maxenceadnot 4:e629702e7738 41
maxenceadnot 4:e629702e7738 42 void drawEtoile()
maxenceadnot 4:e629702e7738 43 {
maxenceadnot 4:e629702e7738 44
maxenceadnot 4:e629702e7738 45 if(positionCode==0){
maxenceadnot 4:e629702e7738 46 BSP_LCD_DisplayStringAt(32,42,(uint8_t*)" ",LEFT_MODE); //1
maxenceadnot 4:e629702e7738 47 BSP_LCD_DisplayStringAt(32,96,(uint8_t*)" ",LEFT_MODE); //2
maxenceadnot 4:e629702e7738 48 BSP_LCD_DisplayStringAt(32,150,(uint8_t*)" ",LEFT_MODE); //3
maxenceadnot 4:e629702e7738 49 BSP_LCD_DisplayStringAt(32,205,(uint8_t*)" ",LEFT_MODE);} //4
maxenceadnot 4:e629702e7738 50
maxenceadnot 4:e629702e7738 51 if(positionCode==1){
maxenceadnot 4:e629702e7738 52 BSP_LCD_DisplayStringAt(32,42,(uint8_t*)"*",LEFT_MODE); }//1
maxenceadnot 4:e629702e7738 53
maxenceadnot 4:e629702e7738 54 if(positionCode==2){
maxenceadnot 4:e629702e7738 55 BSP_LCD_DisplayStringAt(32,42,(uint8_t*)"*",LEFT_MODE); //1
maxenceadnot 4:e629702e7738 56 BSP_LCD_DisplayStringAt(32,96,(uint8_t*)"*",LEFT_MODE); }//2
maxenceadnot 4:e629702e7738 57
maxenceadnot 4:e629702e7738 58 if(positionCode==3){
maxenceadnot 4:e629702e7738 59 BSP_LCD_DisplayStringAt(32,42,(uint8_t*)"*",LEFT_MODE); //1
maxenceadnot 4:e629702e7738 60 BSP_LCD_DisplayStringAt(32,96,(uint8_t*)"*",LEFT_MODE); //2
maxenceadnot 4:e629702e7738 61 BSP_LCD_DisplayStringAt(32,150,(uint8_t*)"*",LEFT_MODE);} //3
maxenceadnot 4:e629702e7738 62
maxenceadnot 4:e629702e7738 63 if(positionCode==4){
maxenceadnot 4:e629702e7738 64 BSP_LCD_DisplayStringAt(32,42,(uint8_t*)"*",LEFT_MODE); //1
maxenceadnot 4:e629702e7738 65 BSP_LCD_DisplayStringAt(32,96,(uint8_t*)"*",LEFT_MODE); //2
maxenceadnot 4:e629702e7738 66 BSP_LCD_DisplayStringAt(32,150,(uint8_t*)"*",LEFT_MODE); //3
maxenceadnot 4:e629702e7738 67 BSP_LCD_DisplayStringAt(32,205,(uint8_t*)"*",LEFT_MODE);} //4
maxenceadnot 4:e629702e7738 68 }
maxenceadnot 4:e629702e7738 69
maxenceadnot 4:e629702e7738 70 void draw(){
maxenceadnot 4:e629702e7738 71
maxenceadnot 4:e629702e7738 72 drawEtoile();
maxenceadnot 4:e629702e7738 73
maxenceadnot 4:e629702e7738 74 BSP_LCD_DrawRect (20, 33, 40, 30); //code 1
maxenceadnot 4:e629702e7738 75 BSP_LCD_DrawRect (20, 88, 40, 30); //code 2
maxenceadnot 4:e629702e7738 76 BSP_LCD_DrawRect (20, 143, 40, 30); //code 3
maxenceadnot 4:e629702e7738 77 BSP_LCD_DrawRect (20, 198, 40, 30); //code 4
maxenceadnot 4:e629702e7738 78
maxenceadnot 4:e629702e7738 79 BSP_LCD_DrawRect (75, 10, 91, 77); //dessiner rectange 1
maxenceadnot 4:e629702e7738 80 BSP_LCD_DisplayStringAt(115,39,(uint8_t*)"1",LEFT_MODE);
maxenceadnot 4:e629702e7738 81
maxenceadnot 4:e629702e7738 82 BSP_LCD_DrawRect (75, 97, 91, 77); //dessiner rectange 2
maxenceadnot 4:e629702e7738 83 BSP_LCD_DisplayStringAt(215,39,(uint8_t*)"2",LEFT_MODE);
maxenceadnot 4:e629702e7738 84
maxenceadnot 4:e629702e7738 85 BSP_LCD_DrawRect (75, 184, 91, 77); //dessiner rectange 3
maxenceadnot 4:e629702e7738 86 BSP_LCD_DisplayStringAt(317,39,(uint8_t*)"3",LEFT_MODE);
maxenceadnot 4:e629702e7738 87
maxenceadnot 4:e629702e7738 88 BSP_LCD_DrawRect (176, 10, 91, 77); //dessiner rectange 4
maxenceadnot 4:e629702e7738 89 BSP_LCD_DisplayStringAt(115,130,(uint8_t*)"4",LEFT_MODE);
maxenceadnot 4:e629702e7738 90
maxenceadnot 4:e629702e7738 91 BSP_LCD_DrawRect (176, 97, 91, 77); //dessiner rectange 5
maxenceadnot 4:e629702e7738 92 BSP_LCD_DisplayStringAt(215,130,(uint8_t*)"5",LEFT_MODE);
maxenceadnot 4:e629702e7738 93
maxenceadnot 4:e629702e7738 94 BSP_LCD_DrawRect (176, 184, 91, 77); //dessiner rectange 6
maxenceadnot 4:e629702e7738 95 BSP_LCD_DisplayStringAt(317,130,(uint8_t*)"6",LEFT_MODE);
maxenceadnot 4:e629702e7738 96
maxenceadnot 4:e629702e7738 97 BSP_LCD_DrawRect (277, 10, 91, 77); //dessiner rectange 7
maxenceadnot 4:e629702e7738 98 BSP_LCD_DisplayStringAt(115,218,(uint8_t*)"7",LEFT_MODE);
maxenceadnot 4:e629702e7738 99
maxenceadnot 4:e629702e7738 100 BSP_LCD_DrawRect (277, 97, 91, 77); //dessiner rectange 8
maxenceadnot 4:e629702e7738 101 BSP_LCD_DisplayStringAt(215,218,(uint8_t*)"8",LEFT_MODE);
maxenceadnot 4:e629702e7738 102
maxenceadnot 4:e629702e7738 103 BSP_LCD_DrawRect (277, 184, 91, 77); //dessiner rectange 9
maxenceadnot 4:e629702e7738 104 BSP_LCD_DisplayStringAt(317,218,(uint8_t*)"9",LEFT_MODE);
maxenceadnot 4:e629702e7738 105
maxenceadnot 4:e629702e7738 106 BSP_LCD_DrawRect (378, 97, 91, 77); //dessiner rectange 0
maxenceadnot 4:e629702e7738 107 BSP_LCD_DisplayStringAt(419,130,(uint8_t*)"0",LEFT_MODE);
maxenceadnot 4:e629702e7738 108
maxenceadnot 4:e629702e7738 109 BSP_LCD_DrawRect (378, 184, 91, 77); //dessiner rectange valider V
maxenceadnot 4:e629702e7738 110 BSP_LCD_DisplayStringAt(419,218,(uint8_t*)"V",LEFT_MODE);
maxenceadnot 4:e629702e7738 111
maxenceadnot 4:e629702e7738 112 BSP_LCD_DrawRect (378, 10, 91, 77); //dessiner rectange effacer X
maxenceadnot 4:e629702e7738 113 BSP_LCD_DisplayStringAt(419,39,(uint8_t*)"X",LEFT_MODE);
maxenceadnot 4:e629702e7738 114
maxenceadnot 4:e629702e7738 115
maxenceadnot 4:e629702e7738 116
maxenceadnot 4:e629702e7738 117 if(TS_State.touchDetected){
maxenceadnot 4:e629702e7738 118 touchh=touchh+1;
maxenceadnot 4:e629702e7738 119
maxenceadnot 4:e629702e7738 120 if(y<87&&y>10&&x>75&&x<166)// definir zone de touch //1
maxenceadnot 4:e629702e7738 121 {
maxenceadnot 4:e629702e7738 122 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 123 sprintf((char*)text, "numero 1");
maxenceadnot 4:e629702e7738 124 BSP_LCD_DrawRect (75, 10, 91, 77); //dessiner rectange 1
maxenceadnot 4:e629702e7738 125 if( positionCode==0&&touchh==1){int code11=339;code=code+code11;positionCode=1;sprintf((char*)text, "p1");}
maxenceadnot 4:e629702e7738 126 if( positionCode==1&&touchh==2){int code12=762;code=code+code12;positionCode=2;sprintf((char*)text, "p2");}
maxenceadnot 4:e629702e7738 127 if( positionCode==2&&touchh==3){int code13=131;code=code+code13;positionCode=3;sprintf((char*)text, "p3");}
maxenceadnot 4:e629702e7738 128 if(positionCode==3&&touchh==4){int code14=201;code=code+code14;positionCode=4;sprintf((char*)text, "p4");}
maxenceadnot 4:e629702e7738 129 }
maxenceadnot 4:e629702e7738 130
maxenceadnot 4:e629702e7738 131 if(y<87&&y>10&&x>176&&x<267)// definir zone de touch //2
maxenceadnot 4:e629702e7738 132 {
maxenceadnot 4:e629702e7738 133 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 134 sprintf((char*)text, "numero 2");
maxenceadnot 4:e629702e7738 135 if(positionCode==0&&touchh==1){int code21=751;code=code+code21;positionCode=1;}
maxenceadnot 4:e629702e7738 136 if(positionCode==1&&touchh==2){int code22=309;code=code+code22;positionCode=2;}
maxenceadnot 4:e629702e7738 137 if(positionCode==2&&touchh==3){int code23=540;code=code+code23;positionCode=3;}
maxenceadnot 4:e629702e7738 138 if(positionCode==3&&touchh==4){int code24=603;code=code+code24;positionCode=4;}
maxenceadnot 4:e629702e7738 139 }
maxenceadnot 4:e629702e7738 140
maxenceadnot 4:e629702e7738 141 if(y<87&&y>10&&x>277&&x<368)// definir zone de touch //3
maxenceadnot 4:e629702e7738 142 {
maxenceadnot 4:e629702e7738 143 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 144 sprintf((char*)text, "numero 3");
maxenceadnot 4:e629702e7738 145 if(positionCode==0&&touchh==1){int code31=905;code=code+code31;positionCode=1;}
maxenceadnot 4:e629702e7738 146 if(positionCode==1&&touchh==2){int code32=805;code=code+code32;positionCode=2;}
maxenceadnot 4:e629702e7738 147 if(positionCode==2&&touchh==3){int code33=50;code=code+code33;positionCode=3;}
maxenceadnot 4:e629702e7738 148 if(positionCode==3&&touchh==4){int code34=10;code=code+code34;positionCode=4;}
maxenceadnot 4:e629702e7738 149 }
maxenceadnot 4:e629702e7738 150
maxenceadnot 4:e629702e7738 151 if(y<174&&y>97&&x>75&&x<166)// definir zone de touch //4
maxenceadnot 4:e629702e7738 152 {
maxenceadnot 4:e629702e7738 153 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 154 sprintf((char*)text, "numero 4");
maxenceadnot 4:e629702e7738 155 if(positionCode==0&&touchh==1){int code41=110;code=code+code41;positionCode=1;}
maxenceadnot 4:e629702e7738 156 if(positionCode==1&&touchh==2){int code42=322;code=code+code42;positionCode=2;}
maxenceadnot 4:e629702e7738 157 if(positionCode==2&&touchh==3){int code43=555;code=code+code43;positionCode=3;}
maxenceadnot 4:e629702e7738 158 if(positionCode==3&&touchh==4){int code44=672;code=code+code44;positionCode=4;}
maxenceadnot 4:e629702e7738 159 }
maxenceadnot 4:e629702e7738 160
maxenceadnot 4:e629702e7738 161 if(y<174&&y>97&&x>176&&x<267)// definir zone de touch //5
maxenceadnot 4:e629702e7738 162 {
maxenceadnot 4:e629702e7738 163 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 164 sprintf((char*)text, "numero 5");
maxenceadnot 4:e629702e7738 165 if(positionCode==0&&touchh==1){int code51=631;code=code+code51;positionCode=1;}
maxenceadnot 4:e629702e7738 166 if(positionCode==1&&touchh==2){int code52=782;code=code+code52;positionCode=2;}
maxenceadnot 4:e629702e7738 167 if(positionCode==2&&touchh==3){int code53=823;code=code+code53;positionCode=3;}
maxenceadnot 4:e629702e7738 168 if(positionCode==3&&touchh==4){int code54=951;code=code+code54;positionCode=4;}
maxenceadnot 4:e629702e7738 169 }
maxenceadnot 4:e629702e7738 170
maxenceadnot 4:e629702e7738 171 if(y<174&&y>97&&x>277&&x<368)// definir zone de touch //6
maxenceadnot 4:e629702e7738 172 {
maxenceadnot 4:e629702e7738 173 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 174 sprintf((char*)text, "numero 6");
maxenceadnot 4:e629702e7738 175 if(positionCode==0&&touchh==1){int code61=729;code=code+code61;positionCode=1;}
maxenceadnot 4:e629702e7738 176 if(positionCode==1&&touchh==2){int code62=819;code=code+code62;positionCode=2;}
maxenceadnot 4:e629702e7738 177 if(positionCode==2&&touchh==3){int code63=157;code=code+code63;positionCode=3;}
maxenceadnot 4:e629702e7738 178 if(positionCode==3&&touchh==4){int code64=43;code=code+code64;positionCode=4;}
maxenceadnot 4:e629702e7738 179 }
maxenceadnot 4:e629702e7738 180
maxenceadnot 4:e629702e7738 181 if(y<261&&y>184&&x>75&&x<166)// definir zone de touch //7
maxenceadnot 4:e629702e7738 182 {
maxenceadnot 4:e629702e7738 183 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 184 sprintf((char*)text, "numero 7");
maxenceadnot 4:e629702e7738 185 if(positionCode==0&&touchh==1){int code71=537;code=code+code71;positionCode=1;}
maxenceadnot 4:e629702e7738 186 if(positionCode==1&&touchh==2){int code72=486;code=code+code72;positionCode=2;}
maxenceadnot 4:e629702e7738 187 if(positionCode==2&&touchh==3){int code73=352;code=code+code73;positionCode=3;}
maxenceadnot 4:e629702e7738 188 if(positionCode==3&&touchh==4){int code74=13;code=code+code74;positionCode=4;}
maxenceadnot 4:e629702e7738 189 }
maxenceadnot 4:e629702e7738 190
maxenceadnot 4:e629702e7738 191 if(y<261&&y>184&&x>176&&x<267)// definir zone de touch //8
maxenceadnot 4:e629702e7738 192 {
maxenceadnot 4:e629702e7738 193 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 194 sprintf((char*)text, "numero 8");
maxenceadnot 4:e629702e7738 195 if(positionCode==0&&touchh==1){int code81=789;code=code+code81;positionCode=1;}
maxenceadnot 4:e629702e7738 196 if(positionCode==1&&touchh==2){int code82=18;code=code+code82;positionCode=2;}
maxenceadnot 4:e629702e7738 197 if(positionCode==2&&touchh==3){int code83=803;code=code+code83;positionCode=3;}
maxenceadnot 4:e629702e7738 198 if(positionCode==3&&touchh==4){int code84=935;code=code+code84;positionCode=4;}
maxenceadnot 4:e629702e7738 199 }
maxenceadnot 4:e629702e7738 200
maxenceadnot 4:e629702e7738 201 if(y<261&&y>184&&x>277&&x<368)// definir zone de touch //9
maxenceadnot 4:e629702e7738 202 {
maxenceadnot 4:e629702e7738 203 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 204 sprintf((char*)text, "numero 9");
maxenceadnot 4:e629702e7738 205 if(positionCode==0&&touchh==1){int code91=999;code=code+code91;positionCode=1;}
maxenceadnot 4:e629702e7738 206 if(positionCode==1&&touchh==2){int code92=1;code=code+code92;positionCode=2;}
maxenceadnot 4:e629702e7738 207 if(positionCode==2&&touchh==3){int code93=99;code=code+code93;positionCode=3;}
maxenceadnot 4:e629702e7738 208 if(positionCode==3&&touchh==4){int code94=57;code=code+code94;positionCode=4;}
maxenceadnot 4:e629702e7738 209 }
maxenceadnot 4:e629702e7738 210
maxenceadnot 4:e629702e7738 211
maxenceadnot 4:e629702e7738 212 if(y<87&&y>10&&x>378&&x<470)// definir zone de touch //X
maxenceadnot 4:e629702e7738 213 {
maxenceadnot 4:e629702e7738 214 sprintf((char*)text, "effacer");
maxenceadnot 4:e629702e7738 215 code=0;
maxenceadnot 4:e629702e7738 216 positionCode=0;
maxenceadnot 4:e629702e7738 217 touchh=0;
maxenceadnot 4:e629702e7738 218 }
maxenceadnot 4:e629702e7738 219
maxenceadnot 4:e629702e7738 220 if(y<174&&y>97&&x>378&&x<470)// definir zone de touch //0
maxenceadnot 4:e629702e7738 221 {
maxenceadnot 4:e629702e7738 222 ThisThread::sleep_for(200ms);
maxenceadnot 4:e629702e7738 223 sprintf((char*)text, "numero 0");
maxenceadnot 4:e629702e7738 224 if(positionCode==0&&touchh==1){int code01=666;code=code+code01;positionCode=1;}
maxenceadnot 4:e629702e7738 225 if(positionCode==1&&touchh==2){int code02=767;code=code+code02;positionCode=2;}
maxenceadnot 4:e629702e7738 226 if(positionCode==2&&touchh==3){int code03=897;code=code+code03;positionCode=3;}
maxenceadnot 4:e629702e7738 227 if(positionCode==3&&touchh==4){int code04=75;code=code+code04;positionCode=4;}
maxenceadnot 4:e629702e7738 228 }
maxenceadnot 4:e629702e7738 229
maxenceadnot 4:e629702e7738 230 if(y<261&&y>184&&x>378&&x<470)// definir zone de touch //V
maxenceadnot 4:e629702e7738 231 {
maxenceadnot 4:e629702e7738 232 sprintf((char*)text, "valider");
maxenceadnot 4:e629702e7738 233 servo_mot.pulsewidth_us(2000);
maxenceadnot 4:e629702e7738 234 if(code==1370&&positionCode==4){sprintf((char*)text,"code bon");
maxenceadnot 4:e629702e7738 235 if(activer==1){
maxenceadnot 4:e629702e7738 236 activer=0;}
maxenceadnot 4:e629702e7738 237 else{activer=1;};
maxenceadnot 4:e629702e7738 238 motion_detected = 0;
maxenceadnot 4:e629702e7738 239 buzzer = off;}
maxenceadnot 4:e629702e7738 240
maxenceadnot 4:e629702e7738 241 if(code!=1370&&positionCode==4){sprintf((char*)text,"code faux"); }
maxenceadnot 4:e629702e7738 242 ThisThread::sleep_for(300ms);
maxenceadnot 4:e629702e7738 243 code=0;
maxenceadnot 4:e629702e7738 244 positionCode=0;
maxenceadnot 4:e629702e7738 245 touchh=0;
maxenceadnot 4:e629702e7738 246 }
maxenceadnot 4:e629702e7738 247 }
maxenceadnot 4:e629702e7738 248 }
maxenceadnot 4:e629702e7738 249
maxenceadnot 4:e629702e7738 250 int main()
maxenceadnot 4:e629702e7738 251 {
maxenceadnot 4:e629702e7738 252 servo_mot.period_ms(30); // Initialisation période du servo
maxenceadnot 4:e629702e7738 253 motion.rise(&irq_handler);// initialisation capteur de mouvement
maxenceadnot 4:e629702e7738 254
maxenceadnot 4:e629702e7738 255
maxenceadnot 4:e629702e7738 256
maxenceadnot 4:e629702e7738 257 int i, time = 1500;
Jerome Coutant 3:9f66aabe7b3b 258 BSP_LCD_Init();
Jerome Coutant 3:9f66aabe7b3b 259 BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
Jerome Coutant 3:9f66aabe7b3b 260 BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
bcostm 0:9933f7db9a9b 261
maxenceadnot 4:e629702e7738 262
Jerome Coutant 3:9f66aabe7b3b 263
Jerome Coutant 3:9f66aabe7b3b 264 status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
maxenceadnot 4:e629702e7738 265
bcostm 0:9933f7db9a9b 266
Jerome Coutant 3:9f66aabe7b3b 267 HAL_Delay(1000);
maxenceadnot 4:e629702e7738 268 BSP_LCD_SetFont(&Font20); // taille de caractere
maxenceadnot 4:e629702e7738 269 BSP_LCD_SetTextColor(LCD_COLOR_BLACK); //couleur texte
maxenceadnot 4:e629702e7738 270 BSP_LCD_SetBackColor(LCD_COLOR_WHITE); //couleur texte
maxenceadnot 4:e629702e7738 271
bcostm 0:9933f7db9a9b 272 while(1) {
maxenceadnot 4:e629702e7738 273
maxenceadnot 4:e629702e7738 274
maxenceadnot 4:e629702e7738 275 draw();
maxenceadnot 4:e629702e7738 276
maxenceadnot 4:e629702e7738 277 if(activer==0){ // alarme desactivé
maxenceadnot 4:e629702e7738 278 BSP_LCD_DisplayStringAt(0,255,(uint8_t*)"X",LEFT_MODE); // affiche un 'X' en bas a gauche de l'ecran pour signifier que l'alarme est desactivé
maxenceadnot 4:e629702e7738 279 servo_mot.pulsewidth_us(2500);// mettre le servo en mode "ouvert"
bcostm 0:9933f7db9a9b 280 }
maxenceadnot 4:e629702e7738 281
maxenceadnot 4:e629702e7738 282 if(activer==1){ // alarme activé
maxenceadnot 4:e629702e7738 283 servo_mot.pulsewidth_us(700);// mettre le servo en mode "fermer"
maxenceadnot 4:e629702e7738 284 alarme();
maxenceadnot 4:e629702e7738 285 BSP_LCD_DisplayStringAt(0,255,(uint8_t*)"V",LEFT_MODE); // affiche un 'V' en bas a gauche de l'ecran pour signifier que l'alarme est activé
maxenceadnot 4:e629702e7738 286
maxenceadnot 4:e629702e7738 287 }
maxenceadnot 4:e629702e7738 288
maxenceadnot 4:e629702e7738 289 BSP_TS_GetState(&TS_State);
maxenceadnot 4:e629702e7738 290 if (TS_State.touchDetected) {
maxenceadnot 4:e629702e7738 291 cleared = 0;
bcostm 0:9933f7db9a9b 292 for (idx = 0; idx < TS_State.touchDetected; idx++) {
bcostm 0:9933f7db9a9b 293 x = TS_State.touchX[idx];
bcostm 0:9933f7db9a9b 294 y = TS_State.touchY[idx];
maxenceadnot 4:e629702e7738 295 }
bcostm 0:9933f7db9a9b 296 } else {
bcostm 0:9933f7db9a9b 297 if (!cleared) {
maxenceadnot 4:e629702e7738 298 BSP_LCD_Clear(LCD_COLOR_WHITE);
bcostm 0:9933f7db9a9b 299 cleared = 1;
bcostm 0:9933f7db9a9b 300 }
bcostm 0:9933f7db9a9b 301 }
bcostm 0:9933f7db9a9b 302 }
bcostm 0:9933f7db9a9b 303 }
maxenceadnot 4:e629702e7738 304
maxenceadnot 4:e629702e7738 305