From 49feff6df297016036feefb068e1904098ca8a74 Mon Sep 17 00:00:00 2001
From: jgromes <jan.gromes@gmail.com>
Date: Mon, 27 Nov 2023 19:43:01 +0100
Subject: [PATCH] [SX126x] Reworked macro configuration system

---
 src/modules/SX126x/STM32WLx.cpp                |  4 ++--
 src/modules/SX126x/STM32WLx.h                  | 10 +++++-----
 src/modules/SX126x/STM32WLx_Module.cpp         |  4 ++--
 src/modules/SX126x/STM32WLx_Module.h           |  6 +++---
 src/modules/SX126x/SX1261.cpp                  |  2 +-
 src/modules/SX126x/SX1261.h                    |  4 ++--
 src/modules/SX126x/SX1262.cpp                  |  2 +-
 src/modules/SX126x/SX1262.h                    |  4 ++--
 src/modules/SX126x/SX1268.cpp                  |  2 +-
 src/modules/SX126x/SX1268.h                    |  4 ++--
 src/modules/SX126x/SX126x.cpp                  | 14 +++++++-------
 src/modules/SX126x/SX126x.h                    | 10 +++++-----
 src/modules/SX126x/patches/SX126x_patch_scan.h |  2 +-
 13 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/modules/SX126x/STM32WLx.cpp b/src/modules/SX126x/STM32WLx.cpp
index f64b4933..313f8343 100644
--- a/src/modules/SX126x/STM32WLx.cpp
+++ b/src/modules/SX126x/STM32WLx.cpp
@@ -6,7 +6,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT
 */
 
 #include "STM32WLx.h"
-#if !defined(RADIOLIB_EXCLUDE_STM32WLX)
+#if !RADIOLIB_EXCLUDE_STM32WLX
 
 STM32WLx::STM32WLx(STM32WLx_Module* mod) : SX1262(mod) { }
 
@@ -150,4 +150,4 @@ void STM32WLx::clearChannelScanAction() {
   this->clearDio1Action();
 }
 
-#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX)
+#endif
diff --git a/src/modules/SX126x/STM32WLx.h b/src/modules/SX126x/STM32WLx.h
index cab2fc54..16c88cc9 100644
--- a/src/modules/SX126x/STM32WLx.h
+++ b/src/modules/SX126x/STM32WLx.h
@@ -10,7 +10,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT
 
 #include "../../TypeDef.h"
 
-#if !defined(RADIOLIB_EXCLUDE_STM32WLX)
+#if !RADIOLIB_EXCLUDE_STM32WLX
 
 #include "../../Module.h"
 #include "SX1262.h"
@@ -153,16 +153,16 @@ class STM32WLx : public SX1262 {
     */
     void clearChannelScanAction();
 
-#if !defined(RADIOLIB_GODMODE)
+#if !RADIOLIB_GODMODE
   protected:
 #endif
     virtual int16_t clearIrqStatus(uint16_t clearIrqParams) override;
 
-#if !defined(RADIOLIB_GODMODE)
+#if !RADIOLIB_GODMODE
   private:
 #endif
 };
 
-#endif // !defined(RADIOLIB_EXCLUDE_SX126X)
+#endif
 
-#endif // _RADIOLIB_STM32WLX_MODULE_H
+#endif
diff --git a/src/modules/SX126x/STM32WLx_Module.cpp b/src/modules/SX126x/STM32WLx_Module.cpp
index 1336325b..57d0445c 100644
--- a/src/modules/SX126x/STM32WLx_Module.cpp
+++ b/src/modules/SX126x/STM32WLx_Module.cpp
@@ -7,7 +7,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT
 
 #include "STM32WLx_Module.h"
 
-#if !defined(RADIOLIB_EXCLUDE_STM32WLX)
+#if !RADIOLIB_EXCLUDE_STM32WLX
 
 #include "../../ArduinoHal.h"
 
@@ -103,4 +103,4 @@ STM32WLx_Module::STM32WLx_Module():
     RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY
   ) {}
 
-#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX)
+#endif
diff --git a/src/modules/SX126x/STM32WLx_Module.h b/src/modules/SX126x/STM32WLx_Module.h
index f7d1d64d..878ba775 100644
--- a/src/modules/SX126x/STM32WLx_Module.h
+++ b/src/modules/SX126x/STM32WLx_Module.h
@@ -10,7 +10,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT
 
 #include "../../TypeDef.h"
 
-#if !defined(RADIOLIB_EXCLUDE_STM32WLX)
+#if !RADIOLIB_EXCLUDE_STM32WLX
 
 #include "../../Module.h"
 
@@ -33,6 +33,6 @@ class STM32WLx_Module : public Module {
     STM32WLx_Module();
 };
 
-#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX)
+#endif
 
-#endif // _RADIOLIB_STM32WLX_MODULE_H
+#endif
diff --git a/src/modules/SX126x/SX1261.cpp b/src/modules/SX126x/SX1261.cpp
index 999f4f9f..dd39bfef 100644
--- a/src/modules/SX126x/SX1261.cpp
+++ b/src/modules/SX126x/SX1261.cpp
@@ -1,5 +1,5 @@
 #include "SX1261.h"
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 SX1261::SX1261(Module* mod): SX1262(mod) {
   chipType = RADIOLIB_SX1261_CHIP_TYPE;
diff --git a/src/modules/SX126x/SX1261.h b/src/modules/SX126x/SX1261.h
index 8d7663e5..01375d55 100644
--- a/src/modules/SX126x/SX1261.h
+++ b/src/modules/SX126x/SX1261.h
@@ -3,7 +3,7 @@
 
 #include "../../TypeDef.h"
 
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 #include "../../Module.h"
 #include "SX126x.h"
@@ -34,7 +34,7 @@ class SX1261 : public SX1262 {
     */
     int16_t setOutputPower(int8_t power);
 
-#if !defined(RADIOLIB_GODMODE)
+#if !RADIOLIB_GODMODE
   private:
 #endif
 
diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp
index baa27ae8..d24e0f43 100644
--- a/src/modules/SX126x/SX1262.cpp
+++ b/src/modules/SX126x/SX1262.cpp
@@ -1,5 +1,5 @@
 #include "SX1262.h"
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 SX1262::SX1262(Module* mod) : SX126x(mod) {
   chipType = RADIOLIB_SX1262_CHIP_TYPE;
diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h
index d3b67ae5..f47b1a81 100644
--- a/src/modules/SX126x/SX1262.h
+++ b/src/modules/SX126x/SX1262.h
@@ -3,7 +3,7 @@
 
 #include "../../TypeDef.h"
 
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 #include "../../Module.h"
 #include "SX126x.h"
@@ -87,7 +87,7 @@ class SX1262: public SX126x {
     */
     virtual int16_t setOutputPower(int8_t power);
 
-#if !defined(RADIOLIB_GODMODE)
+#if !RADIOLIB_GODMODE
   private:
 #endif
 
diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp
index a2f60f23..596ce7e4 100644
--- a/src/modules/SX126x/SX1268.cpp
+++ b/src/modules/SX126x/SX1268.cpp
@@ -1,5 +1,5 @@
 #include "SX1268.h"
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 SX1268::SX1268(Module* mod) : SX126x(mod) {
   chipType = RADIOLIB_SX1268_CHIP_TYPE;
diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h
index c3e2a607..08b3eb41 100644
--- a/src/modules/SX126x/SX1268.h
+++ b/src/modules/SX126x/SX1268.h
@@ -3,7 +3,7 @@
 
 #include "../../TypeDef.h"
 
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 #include "../../Module.h"
 #include "SX126x.h"
@@ -85,7 +85,7 @@ class SX1268: public SX126x {
     */
     int16_t setOutputPower(int8_t power);
 
-#if !defined(RADIOLIB_GODMODE)
+#if !RADIOLIB_GODMODE
   private:
 #endif
 
diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp
index 51e1b8ae..797968a8 100644
--- a/src/modules/SX126x/SX126x.cpp
+++ b/src/modules/SX126x/SX126x.cpp
@@ -1,7 +1,7 @@
 #include "SX126x.h"
 #include <string.h>
 #include <math.h>
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 SX126x::SX126x(Module* mod) : PhysicalLayer(RADIOLIB_SX126X_FREQUENCY_STEP_SIZE, RADIOLIB_SX126X_MAX_PACKET_LENGTH) {
   this->mod = mod;
@@ -1547,7 +1547,7 @@ int16_t SX126x::invertIQ(bool enable) {
   return(setPacketParams(this->preambleLengthLoRa, this->crcTypeLoRa, this->implicitLen, this->headerType, this->invertIQEnabled));
 }
 
-#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
+#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
 void SX126x::setDirectAction(void (*func)(void)) {
   setDio1Action(func);
 }
@@ -1563,7 +1563,7 @@ int16_t SX126x::uploadPatch(const uint32_t* patch, size_t len, bool nonvolatile)
   RADIOLIB_ASSERT(state);
 
   // check the version
-  #if defined(RADIOLIB_DEBUG)
+  #if RADIOLIB_DEBUG
   char ver_pre[16];
   this->mod->SPIreadRegisterBurst(RADIOLIB_SX126X_REG_VERSION_STRING, 16, (uint8_t*)ver_pre);
   RADIOLIB_DEBUG_PRINTLN("Pre-update version string: %s", ver_pre);
@@ -1595,7 +1595,7 @@ int16_t SX126x::uploadPatch(const uint32_t* patch, size_t len, bool nonvolatile)
   this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_PRAM_UPDATE, NULL, 0);
 
   // check the version again
-  #if defined(RADIOLIB_DEBUG)
+  #if RADIOLIB_DEBUG
   char ver_post[16];
   this->mod->SPIreadRegisterBurst(RADIOLIB_SX126X_REG_VERSION_STRING, 16, (uint8_t*)ver_post);
   RADIOLIB_DEBUG_PRINTLN("Post-update version string: %s", ver_post);
@@ -1839,7 +1839,7 @@ int16_t SX126x::calibrateImage(uint8_t* data) {
   int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_CALIBRATE_IMAGE, data, 2);
 
   // if something failed, show the device errors
-  #if defined(RADIOLIB_DEBUG)
+  #if RADIOLIB_DEBUG
   if(state != RADIOLIB_ERR_NONE) {
     // unless mode is forced to standby, device errors will be 0
     standby();
@@ -2099,7 +2099,7 @@ int16_t SX126x::config(uint8_t modem) {
   state = this->mod->SPIcheckStream();
 
   // if something failed, show the device errors
-  #if defined(RADIOLIB_DEBUG)
+  #if RADIOLIB_DEBUG
   if(state != RADIOLIB_ERR_NONE) {
     // unless mode is forced to standby, device errors will be 0
     standby();
@@ -2142,7 +2142,7 @@ bool SX126x::findChip(const char* verStr) {
       RADIOLIB_DEBUG_PRINTLN();
       flagFound = true;
     } else {
-      #if defined(RADIOLIB_DEBUG)
+      #if RADIOLIB_DEBUG
         RADIOLIB_DEBUG_PRINTLN("SX126x not found! (%d of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING:", i + 1);
         RADIOLIB_DEBUG_HEXDUMP((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
         RADIOLIB_DEBUG_PRINTLN("Expected string: %s", verStr);
diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h
index 0c2f9e20..5e8c03b6 100644
--- a/src/modules/SX126x/SX126x.h
+++ b/src/modules/SX126x/SX126x.h
@@ -3,7 +3,7 @@
 
 #include "../../TypeDef.h"
 
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 #include "../../Module.h"
 
@@ -1039,7 +1039,7 @@ class SX126x: public PhysicalLayer {
     */
     int16_t invertIQ(bool enable) override;
 
-    #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
+    #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
     /*!
       \brief Set interrupt service routine function to call when data bit is received in direct mode.
       \param func Pointer to interrupt service routine.
@@ -1104,7 +1104,7 @@ class SX126x: public PhysicalLayer {
     */
     int16_t setPaConfig(uint8_t paDutyCycle, uint8_t deviceSel, uint8_t hpMax = RADIOLIB_SX126X_PA_CONFIG_HP_MAX, uint8_t paLut = RADIOLIB_SX126X_PA_CONFIG_PA_LUT);
 
-#if !defined(RADIOLIB_GODMODE)
+#if !RADIOLIB_GODMODE
   protected:
 #endif
     // SX126x SPI command implementations
@@ -1146,7 +1146,7 @@ class SX126x: public PhysicalLayer {
     int16_t fixImplicitTimeout();
     int16_t fixInvertedIQ(uint8_t iqConfig);
 
-#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
+#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
   protected:
 #endif
     Module* mod;
@@ -1154,7 +1154,7 @@ class SX126x: public PhysicalLayer {
     // common low-level SPI interface
     static int16_t SPIparseStatus(uint8_t in);
 
-#if !defined(RADIOLIB_GODMODE)
+#if !RADIOLIB_GODMODE
   protected:
 #endif
 
diff --git a/src/modules/SX126x/patches/SX126x_patch_scan.h b/src/modules/SX126x/patches/SX126x_patch_scan.h
index 3dff7be8..bc918749 100644
--- a/src/modules/SX126x/patches/SX126x_patch_scan.h
+++ b/src/modules/SX126x/patches/SX126x_patch_scan.h
@@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "../../../TypeDef.h"
 
-#if !defined(RADIOLIB_EXCLUDE_SX126X)
+#if !RADIOLIB_EXCLUDE_SX126X
 
 // the following is a binary patch to the SX1262
 // this patch is needed to enable spectral scan functionality