k

Dependencies:   TFT-RFID_Finish3ja mbed MFRC522 UniGraphic

Revision:
11:7f4df462b2a5
Parent:
10:2985dc4e40a5
Child:
12:09c678c7e70a
--- a/main.cpp	Sat Dec 15 09:08:34 2018 +0000
+++ b/main.cpp	Tue Dec 18 12:42:00 2018 +0000
@@ -12,6 +12,7 @@
 #include "MFRC522.h"
 #define MF_RESET PC_6
 Serial pc(SERIAL_TX, SERIAL_RX);
+Serial esp(PA_15,PB_7);
 MFRC522    RfChip   (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET);
 PinName buspins[] = { PA_9, PC_7, PA_10, PB_3, PB_5, PB_4, PB_10, PA_8 };
 TFT_MIPI myLCD(BUS_8, buspins, A3, A4, A2, A1, A0, "myLCD");
@@ -26,7 +27,17 @@
 int k=0;
 int Pagejawjiw = 0;
 int state = 0;
+int typeA = 0;
+int typeB = 0;
+int typeC = 0;
+int typeD = 0;
+int queueA = 0;
+int queueB = 0;
+int queueC = 0;
+int queueD = 0;
 int main(){
+    pc.baud(9600);
+    esp.baud(9600);
     char *StudentID;
     uint8_t UIDCard[4]={};
     pc.printf("starting...\n");
@@ -60,8 +71,17 @@
             if ( ! RfChip.PICC_ReadCardSerial()){pc.printf("!!!!!!!!!!!!!!!");continue;}
             pc.printf("Studen's ID: ");
             for (uint8_t i = 0; i < RfChip.uid.size; i++){UIDCard[i] = RfChip.uid.uidByte[i];}
-            if (UIDCard[0]==187 and UIDCard[1]==164 and UIDCard[2]==90 and UIDCard[3]==127){StudentID = "60340500033"; pc.printf("%s\n",StudentID);Pagejawjiw = 1;myLCD.cls();}
-            else if (UIDCard[0]==60 and UIDCard[1]==135 and UIDCard[2]==56 and UIDCard[3]==59){StudentID = "60340500066"; pc.printf("%s\n",StudentID);Pagejawjiw = 0;}
+            if (UIDCard[0]==187 and UIDCard[1]==164 and UIDCard[2]==90 and UIDCard[3]==127){StudentID = "60340500033"; 
+            pc.printf("%s\n",StudentID);Pagejawjiw = 1;myLCD.cls();
+            char b[] = "X";
+            esp.putc(b[0]);
+            }
+            
+            else if (UIDCard[0]==60 and UIDCard[1]==135 and UIDCard[2]==56 and UIDCard[3]==59){StudentID = "60340500066"; 
+            pc.printf("%s\n",StudentID);Pagejawjiw = 0;
+            char b[] = "Y";
+            esp.putc(b[0]);
+            }
             else {StudentID="0"; pc.printf("%s\n",StudentID);}
             }
         else if (Pagejawjiw == 1) {
@@ -69,6 +89,7 @@
                     i++;
                     switch(i){
                         case 1:
+                            typeA = 1;
                             myLCD.fillrect(0,0,500,50,Orange);
                             myLCD.rect(155,70,320,120,Orange);
                             myLCD.rect(155,130,320,180,Orange);
@@ -98,7 +119,8 @@
                             myLCD.printf("Other");
                             wait(0.3);
                             break; 
-                        case 2:
+                        case 2:             
+                            typeB = 2;               
                             //myLCD.cls();
                             myLCD.fillrect(0,0,500,50,Orange);
                             myLCD.rect(155,70,320,120,Orange);
@@ -130,6 +152,7 @@
                             wait(0.3);
                             break;  
                         case 3:
+                            typeC = 3;   
                             myLCD.fillrect(0,0,500,50,Orange);
                             myLCD.rect(155,70,320,120,Orange);
                             myLCD.rect(155,130,320,180,Orange);
@@ -159,7 +182,8 @@
                             myLCD.printf("Other");
                             wait(0.3);
                             break; 
-                        case 4:
+                        case 4:            
+                            typeD = 4;                 
                             myLCD.fillrect(0,0,500,50,Orange);
                             myLCD.rect(155,70,320,120,Orange);
                             myLCD.rect(155,130,320,180,Orange);
@@ -326,6 +350,27 @@
                 else if(Sw[4] == 0){
                     Pagejawjiw++;
                     wait(0.3);
+                    if(typeA == 1){
+                        char a[] = "1";
+                        esp.putc(a[0]); 
+                        }
+                    if(typeB == 2){
+                        char b[] = "2";
+                        esp.putc(b[0]); 
+                        }                    
+                    if(typeC == 3){
+                        char c[] = "3";
+                        esp.putc(c[0]); 
+                        }
+                    if(typeD == 4){
+                        char d[] = "4";
+                        esp.putc(d[0]); 
+                        }
+                        
+                    
+                    
+                    
+                    
                     }
                 }
             else if(Pagejawjiw == 2){