
Capteur d'empreinte digitale, pin UART PC6, PC7 Alimentation 3.3V Utilisation : Initialisation du capteur en fond Choix de l'utilisateur pour vérifier l'empreinte Retour à la page de menu avec le bouton annuler
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG
Revision 3:9b58c1b47789, committed 2019-06-04
- Comitter:
- arthurborg
- Date:
- Tue Jun 04 14:26:38 2019 +0000
- Parent:
- 2:021843c33b0e
- Commit message:
- Version final
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jun 07 09:31:50 2017 +0200 +++ b/main.cpp Tue Jun 04 14:26:38 2019 +0000 @@ -2,72 +2,194 @@ #include "TS_DISCO_F746NG.h" #include "LCD_DISCO_F746NG.h" +Serial empreinte(PC_6,PC_7,9600); +//Serial pc(USBTX,USBRX,115200); + LCD_DISCO_F746NG lcd; TS_DISCO_F746NG ts; + int main() { TS_StateTypeDef TS_State; uint16_t x, y; - uint8_t text[30]; - uint8_t status; - uint8_t idx; - uint8_t cleared = 0; - uint8_t prev_nb_touches = 0; + char text[30]; + uint8_t idx=0; + int save = 0; + int etat = 0; + char a = 0x55; + char b = 0xAA; + char O = 0x00; + char para = 0x00; + char cmd = 0x01; - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", CENTER_MODE); + short int sum = a+b+O+para+cmd; + empreinte.putc(0x55); wait(0.1); + empreinte.putc(0xAA); wait(0.1); + empreinte.putc(0x01); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0x01); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0x01); wait(0.1); + empreinte.putc(0x01); wait(0.1); + + wait(0.005); + while (empreinte.readable()) { + empreinte.getc(); + wait(0.002); + } wait(1); - status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); - if (status != TS_OK) { - lcd.Clear(LCD_COLOR_RED); - lcd.SetBackColor(LCD_COLOR_RED); - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE); - } else { - lcd.Clear(LCD_COLOR_GREEN); - lcd.SetBackColor(LCD_COLOR_GREEN); - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE); - } + empreinte.putc(0x55); wait(0.1); + empreinte.putc(0xAA); wait(0.1); + empreinte.putc(0x01); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0x01); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0x12); wait(0.1); + empreinte.putc(0); wait(0.1); + empreinte.putc(0x13); wait(0.1); + empreinte.putc(0x01); wait(0.1); + + + - wait(1); - lcd.SetFont(&Font12); - lcd.SetBackColor(LCD_COLOR_BLUE); - lcd.SetTextColor(LCD_COLOR_WHITE); - +/* + empreinte.putc(a); + empreinte.putc(b); + empreinte.putc(O); + empreinte.putc(para); + empreinte.putc(cmd); + empreinte.putc(sum & 0xFF); + empreinte.putc((sum & 0xFF00)>>8); +*/ + lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"Bienvenue dans le programme", CENTER_MODE); + wait(3); + lcd.Clear(LCD_COLOR_WHITE); + lcd.SetFont(&Font20); + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.SetTextColor(LCD_COLOR_BLACK); // initialisation de l'écran tactil while(1) { - + ts.GetState(&TS_State); - if (TS_State.touchDetected) { - // Clear lines corresponding to old touches coordinates - if (TS_State.touchDetected < prev_nb_touches) { - for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) { - lcd.ClearStringLine(idx); - } + if (TS_State.touchDetected) { // récupération de la position de l'appui + x = TS_State.touchX[idx]; + y = TS_State.touchY[idx]; + } + + switch(etat){ + case 0: // écran d'acceuil + lcd.SetFont(&Font20); + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.SetTextColor(LCD_COLOR_BLACK); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Annuler", LEFT_MODE); // 97p par 24p + lcd.DisplayStringAt(0, LINE(3), (uint8_t *)"Mme Fiona LEBEL", LEFT_MODE); //206p par 24p + lcd.DisplayStringAt(0, LINE(3), (uint8_t *)"M Matthieu BICHET", RIGHT_MODE);//206p par 24p + lcd.DisplayStringAt(0, LINE(9), (uint8_t *)"M Ludovic CHERIAUX", LEFT_MODE); // 239p par 24p + lcd.DisplayStringAt(0, LINE(9), (uint8_t *)"M Renaud GOMES", RIGHT_MODE); // 191p par 24p + lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"M BAST22", CENTER_MODE); // 120p par 24p + etat = 1; + break; + + case 1: + if(((x >= 0) && (x <= 206)) && ((y >= 63) && (y <= 87))){ // case fiona + save = 2; + etat = 12; + } + if(((x >= 254) && (x <= 460)) && ((y >= 63) && (y <= 87))){ // case matthieu + save = 3; + etat = 12; + } + if(((x >= 0) && (x <= 239)) && ((y >= 163) && (y <= 187))){ // case Ludo + save = 4; + etat = 12; + } + if(((x >= 269) && (x <= 460)) && ((y >= 163) && (y <= 187))){ // case Renaud + save = 5; + etat = 12; + } + if(((x >= 169) && (x <= 289)) && ((y >= 111) && (y <= 135))){ // case Bast22 + save = 6; + etat = 12; + } + break; + + case 2: // Gestion de l'état correspondant à Fiona + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Annuler", LEFT_MODE); // 97p par 24p + lcd.DisplayStringAt(0,LINE(3),(uint8_t*)"Entrez votre empreinte Mme LEBEL",CENTER_MODE); + O = 0x50; + para = 0x00; + sum = a+b+O+para+cmd;; + empreinte.printf("%c%c%c%c%c%c%d",a,b,O,para,O,cmd,sum); + if(((x >= 0) && (x <= 97)) && ((y >= 0) && (y <= 24))){ // Retour au menu + save = 0; + etat = 12; + } + break; + + case 3: // Gestion de l'état correspondant à Matthieu + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Annuler", LEFT_MODE); // 97p par 24p + lcd.DisplayStringAt(0,LINE(3),(uint8_t*)"Entrez votre empreinte M BICHET",CENTER_MODE); + O = 0x50; + para = 0x01; + sum = a+b+O+para+cmd; + empreinte.printf("%c%c%c%c%c%c%d",a,b,O,para,O,cmd,sum); + if(((x >= 0) && (x <= 97)) && ((y >= 0) && (y <= 24))){ // Retour au menu + save = 0; + etat = 12; + } + break; + + case 4: // Gestion de l'état correspondant à Ludovic + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Annuler", LEFT_MODE); // 97p par 24p + lcd.DisplayStringAt(0,LINE(3),(uint8_t*)"Entrez votre empreinte M CHERIAUX",CENTER_MODE); + O = 0x50; + para = 0x02; + sum = a+b+O+para+cmd; + empreinte.printf("%c%c%c%c%c%c%d",a,b,O,para,O,cmd,sum); + if(((x >= 0) && (x <= 97)) && ((y >= 0) && (y <= 24))){ // Retour au menu + save = 0; + etat = 12; + } + break; + + case 5: // Gestion de l'état correspondant à Renaud + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Annuler", LEFT_MODE); // 97p par 24p + lcd.DisplayStringAt(0,LINE(3),(uint8_t*)"Entrez votre empreinte M GOMES",CENTER_MODE); + O = 0x50; + para = 0x03; + sum = a+b+O+para+cmd; + empreinte.printf("%c%c%c%c%c%c%d",a,b,O,para,O,cmd,sum); + if(((x >= 0) && (x <= 97)) && ((y >= 0) && (y <= 24))){ // Retour au menu + save = 0; + etat = 12; + } + break; + + case 6: // + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Annuler", LEFT_MODE); // 97p par 24p + lcd.DisplayStringAt(0,LINE(3),(uint8_t*)"Entrez votre empreinte BAST22",CENTER_MODE); + O = 0x50; + para = 0x04; + sum = a+b+O+para+cmd; + empreinte.printf("%c%c%c%c%c%c%d",a,b,O,para,O,cmd,sum); + if(((x >= 0) && (x <= 97)) && ((y >= 0) && (y <= 24))){ // Retour au menu + save = 0; + etat = 12; + } + break; + + case 12: + lcd.Clear(LCD_COLOR_WHITE); + etat = save; + break; } - prev_nb_touches = TS_State.touchDetected; - - cleared = 0; - - sprintf((char*)text, "Touches: %d", TS_State.touchDetected); - lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); - - for (idx = 0; idx < TS_State.touchDetected; idx++) { - x = TS_State.touchX[idx]; - y = TS_State.touchY[idx]; - sprintf((char*)text, "Touch %d: x=%d y=%d ", idx+1, x, y); - lcd.DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE); - } - - lcd.DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE); - } else { - if (!cleared) { - lcd.Clear(LCD_COLOR_BLUE); - sprintf((char*)text, "Touches: 0"); - lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); - cleared = 1; - } - } } } +