From f9c62da0811d154f55e2169db4761a093c603726 Mon Sep 17 00:00:00 2001 From: Baozhu Zuo Date: Mon, 26 Aug 2019 11:08:23 +0800 Subject: [PATCH] use SERIAL replace Serial --- PN532/PN532.cpp | 22 +++++++++++----------- PN532/PN532_debug.h | 14 ++++++++++---- PN532_SWHSU/PN532_SWHSU.cpp | 4 ++-- PN532_SWHSU/PN532_SWHSU.h | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/PN532/PN532.cpp b/PN532/PN532.cpp index 7f25a3f..7c13335 100644 --- a/PN532/PN532.cpp +++ b/PN532/PN532.cpp @@ -42,13 +42,13 @@ void PN532::PrintHex(const uint8_t *data, const uint32_t numBytes) #ifdef ARDUINO for (uint8_t i = 0; i < numBytes; i++) { if (data[i] < 0x10) { - Serial.print(" 0"); + SERIAL.print(" 0"); } else { - Serial.print(' '); + SERIAL.print(' '); } - Serial.print(data[i], HEX); + SERIAL.print(data[i], HEX); } - Serial.println(""); + SERIAL.println(""); #else for (uint8_t i = 0; i < numBytes; i++) { printf(" %2X", data[i]); @@ -73,22 +73,22 @@ void PN532::PrintHexChar(const uint8_t *data, const uint32_t numBytes) #ifdef ARDUINO for (uint8_t i = 0; i < numBytes; i++) { if (data[i] < 0x10) { - Serial.print(" 0"); + SERIAL.print(" 0"); } else { - Serial.print(' '); + SERIAL.print(' '); } - Serial.print(data[i], HEX); + SERIAL.print(data[i], HEX); } - Serial.print(" "); + SERIAL.print(" "); for (uint8_t i = 0; i < numBytes; i++) { char c = data[i]; if (c <= 0x1f || c > 0x7f) { - Serial.print('.'); + SERIAL.print('.'); } else { - Serial.print(c); + SERIAL.print(c); } } - Serial.println(""); + SERIAL.println(""); #else for (uint8_t i = 0; i < numBytes; i++) { printf(" %2X", data[i]); diff --git a/PN532/PN532_debug.h b/PN532/PN532_debug.h index 8b845e6..a123a03 100644 --- a/PN532/PN532_debug.h +++ b/PN532/PN532_debug.h @@ -5,11 +5,17 @@ #include "Arduino.h" +#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE + #define SERIAL SerialUSB +#else + #define SERIAL Serial +#endif + #ifdef DEBUG -#define DMSG(args...) Serial.print(args) -#define DMSG_STR(str) Serial.println(str) -#define DMSG_HEX(num) Serial.print(' '); Serial.print((num>>4)&0x0F, HEX); Serial.print(num&0x0F, HEX) -#define DMSG_INT(num) Serial.print(' '); Serial.print(num) +#define DMSG(args...) SERIAL.print(args) +#define DMSG_STR(str) SERIAL.println(str) +#define DMSG_HEX(num) SERIAL.print(' '); SERIAL.print((num>>4)&0x0F, HEX); SERIAL.print(num&0x0F, HEX) +#define DMSG_INT(num) SERIAL.print(' '); SERIAL.print(num) #else #define DMSG(args...) #define DMSG_STR(str) diff --git a/PN532_SWHSU/PN532_SWHSU.cpp b/PN532_SWHSU/PN532_SWHSU.cpp index ee04ab9..17d12d2 100755 --- a/PN532_SWHSU/PN532_SWHSU.cpp +++ b/PN532_SWHSU/PN532_SWHSU.cpp @@ -1,6 +1,6 @@ -#include "PN532_SWHSU.h" -#include "PN532_debug.h" +#include "PN532/PN532_SWHSU/PN532_SWHSU.h" +#include "PN532/PN532/PN532_debug.h" PN532_SWHSU::PN532_SWHSU(SoftwareSerial &serial) diff --git a/PN532_SWHSU/PN532_SWHSU.h b/PN532_SWHSU/PN532_SWHSU.h index 2f92d18..8d2dba7 100755 --- a/PN532_SWHSU/PN532_SWHSU.h +++ b/PN532_SWHSU/PN532_SWHSU.h @@ -4,7 +4,7 @@ #include -#include "PN532Interface.h" +#include "PN532/PN532/PN532Interface.h" #include "Arduino.h" #define PN532_SWHSU_DEBUG