diff --git a/src/main.cpp b/src/main.cpp index 715acc0..7f42cfe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,15 @@ void serial_dump_byte_array(byte *buffer, byte bufferSize); void printMsg(const String &s); void printMsg(unsigned long l); +void oled_dump_byte_array(byte *buffer, byte bufferSize) +{ + for (byte i = 0; i < bufferSize; i++) + { + display.print(buffer[i] < 0x10 ? " 0" : " "); + display.print(buffer[i], HEX); + } +} + void setup() { Serial.begin(9600); @@ -105,8 +114,16 @@ void loop() // UID is a unique four hex pairs, e.g. E6 67 2A 12 Serial.print(F("Card UID:")); serial_dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); + + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(0, 10); display.println("Card UID: "); + oled_dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); display.println(); + display.display(); + // PICC type, e.g. "MIFARE 1K0" Serial.print(F("PICC type: ")); MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);