diff --git a/src/TypeDef.h b/src/TypeDef.h index 91f6a49..49239a4 100644 --- a/src/TypeDef.h +++ b/src/TypeDef.h @@ -7,11 +7,13 @@ #error "Unsupported Arduino version (< 1.0.0)" #endif +#define RADIOLIB_DEBUG_PORT Serial + //#define RADIOLIB_DEBUG #ifdef RADIOLIB_DEBUG - #define RADIOLIB_DEBUG_PRINT(...) { Serial.print(__VA_ARGS__); } - #define RADIOLIB_DEBUG_PRINTLN(...) { Serial.println(__VA_ARGS__); } + #define RADIOLIB_DEBUG_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); } + #define RADIOLIB_DEBUG_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); } #else #define RADIOLIB_DEBUG_PRINT(...) {} #define RADIOLIB_DEBUG_PRINTLN(...) {} diff --git a/src/modules/SX127x.cpp b/src/modules/SX127x.cpp index a9cf2dd..7411e99 100644 --- a/src/modules/SX127x.cpp +++ b/src/modules/SX127x.cpp @@ -1015,16 +1015,15 @@ bool SX127x::findChip(uint8_t ver) { flagFound = true; } else { #ifdef RADIOLIB_DEBUG - Serial.print(F("SX127x not found! (")); - Serial.print(i + 1); - Serial.print(F(" of 10 tries) SX127X_REG_VERSION == ")); + RADIOLIB_DEBUG_PRINT(F("SX127x not found! (")); + RADIOLIB_DEBUG_PRINT(i + 1); + RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SX127X_REG_VERSION == ")); char buffHex[5]; sprintf(buffHex, "0x%02X", version); - Serial.print(buffHex); - Serial.print(F(", expected 0x00")); - Serial.print(ver, HEX); - Serial.println(); + RADIOLIB_DEBUG_PRINT(buffHex); + RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); + RADIOLIB_DEBUG_PRINTLN(ver, HEX); #endif delay(1000); i++; @@ -1073,23 +1072,23 @@ void SX127x::clearFIFO(size_t count) { #ifdef RADIOLIB_DEBUG void SX127x::regDump() { - Serial.println(); - Serial.println(F("ADDR\tVALUE")); + RADIOLIB_DEBUG_PRINTLN(); + RADIOLIB_DEBUG_PRINTLN(F("ADDR\tVALUE")); for(uint16_t addr = 0x01; addr <= 0x70; addr++) { if(addr <= 0x0F) { - Serial.print(F("0x0")); + RADIOLIB_DEBUG_PRINT(F("0x0")); } else { - Serial.print(F("0x")); + RADIOLIB_DEBUG_PRINT(F("0x")); } - Serial.print(addr, HEX); - Serial.print('\t'); + RADIOLIB_DEBUG_PRINT(addr, HEX); + RADIOLIB_DEBUG_PRINT('\t'); uint8_t val = _mod->SPIreadRegister(addr); if(val <= 0x0F) { - Serial.print(F("0x0")); + RADIOLIB_DEBUG_PRINT(F("0x0")); } else { - Serial.print(F("0x")); + RADIOLIB_DEBUG_PRINT(F("0x")); } - Serial.println(val, HEX); + RADIOLIB_DEBUG_PRINTLN(val, HEX); delay(50); }