SPI,I2C,RTC
Dependencies: MFRC522_Updated ssd1306_library
Revision 11:c996c388d45b, committed 2020-05-21
- Comitter:
- 20172573073
- Date:
- Thu May 21 04:02:33 2020 +0000
- Parent:
- 10:7e62c3111814
- Commit message:
- Escaner RF
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7e62c3111814 -r c996c388d45b main.cpp --- a/main.cpp Wed May 20 21:29:47 2020 +0000 +++ b/main.cpp Thu May 21 04:02:33 2020 +0000 @@ -9,8 +9,9 @@ Serial pc(USBTX, USBRX); MFRC522 RfChip (D11, D12, D13, PTE0, D10); Ticker tiempo1; - -int q,h; +static const char tar[]={0xD7,0x4F,0x88,0x19}; +static const char llav[]={0x27,0x57,0xC1,0x7B}; +int q,a,b,h; void conteo() { if(h!=0) { @@ -20,7 +21,7 @@ int main(void) { tiempo1.attach(&conteo,1); - q=1589866116; + q=1590029272; q=q-((5*60)*60); lcd.init(); lcd.speed (SSD1306::Fast); @@ -31,7 +32,6 @@ lcd.printf ("Andres Arevalo"); lcd.locate (5,1); lcd.printf ("Andres castano"); - pc.printf ("Andres castano"); lcd.redraw(); wait(3); lcd.cls(); @@ -39,7 +39,7 @@ h=1; while (true) { - + set_time(q); lcd.locate (1,0); time_t seconds = time(NULL); @@ -51,10 +51,11 @@ char buffer2[32]; strftime(buffer2, 32, "%m/%d/%y", localtime(&seconds)); pc.printf("%s", buffer2); + char buffer1[32]; strftime(buffer1, 32, "%H:%M:%S", localtime(&seconds)); pc.printf(" , %s", buffer1); - pc.printf(" , sin lectura \n\r"); + pc.printf(" , 0 \n\r"); if ( ! RfChip.PICC_IsNewCardPresent()) { wait_ms(500); @@ -68,20 +69,56 @@ continue; } + lcd.cls(); + set_time(q); + lcd.locate (1,0); + lcd.printf("fecha %s",ctime(&seconds)); + lcd.redraw(); LedRed = 1; LedGreen = 0; - + a=0; + b=0; + for (uint8_t i = 0; i < RfChip.uid.size; i++) { + + if(uint8_t (tar[i])==RfChip.uid.uidByte[i]){ + a=a+1; + }else{ + a=0; + } + } + for (uint8_t i = 0; i < RfChip.uid.size; i++) { + + if(uint8_t (llav[i])==RfChip.uid.uidByte[i]){ + b=b+1; + }else{ + b=0; + } + } - strftime(buffer2, 32, "%m/%d/%y", localtime(&seconds)); + strftime(buffer2, 32, "%m/%d/%y", localtime(&seconds)); pc.printf("%s", buffer2); strftime(buffer1, 32, "%H:%M:%S", localtime(&seconds)); pc.printf(" , %s", buffer1); - pc.printf(" ,"); + pc.printf(" , "); + + lcd.locate (5,1); + + if(a==4){ + + lcd.printf("Tarjeta "); + pc.printf("1"); + }else if(b==4){ + lcd.printf("Lavero "); + pc.printf("2"); + }else{ + lcd.printf("Sitp "); + pc.printf("3"); + } + lcd.locate (6,1); for (uint8_t i = 0; i < RfChip.uid.size; i++) { - pc.printf(" %x ", RfChip.uid.uidByte[i]); lcd.printf(" %x ", RfChip.uid.uidByte[i]); } @@ -90,3 +127,4 @@ wait(1); } } +