From e42a1762294e7a0d4e38b236d145a191e94a2fe4 Mon Sep 17 00:00:00 2001 From: hobobandy <30026704+hobobandy@users.noreply.github.com> Date: Sat, 19 Aug 2023 17:28:30 -0400 Subject: [PATCH 1/3] Add support for UNO R4 soft serial --- src/Adafruit_GPS.cpp | 12 ++++++------ src/Adafruit_GPS.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Adafruit_GPS.cpp b/src/Adafruit_GPS.cpp index 014f3bf..04ec08c 100644 --- a/src/Adafruit_GPS.cpp +++ b/src/Adafruit_GPS.cpp @@ -40,7 +40,7 @@ static bool strStartsWith(const char *str, const char *prefix); */ /**************************************************************************/ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) { -#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) +#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) if (gpsSwSerial) { gpsSwSerial->begin(baud_or_i2caddr); } @@ -78,7 +78,7 @@ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) { @param ser Pointer to SoftwareSerial device */ /**************************************************************************/ -#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) +#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser) { common_init(); // Set everything to common state, then... gpsSwSerial = ser; // ...override gpsSwSerial with value passed. @@ -147,7 +147,7 @@ Adafruit_GPS::Adafruit_GPS() { */ /**************************************************************************/ void Adafruit_GPS::common_init(void) { -#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) +#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) gpsSwSerial = NULL; // Set both to NULL, then override correct #endif gpsHwSerial = NULL; // port pointer in corresponding constructor @@ -196,7 +196,7 @@ size_t Adafruit_GPS::available(void) { if (paused) return 0; -#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) +#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) if (gpsSwSerial) { return gpsSwSerial->available(); } @@ -223,7 +223,7 @@ size_t Adafruit_GPS::available(void) { */ /**************************************************************************/ size_t Adafruit_GPS::write(uint8_t c) { -#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) +#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) if (gpsSwSerial) { return gpsSwSerial->write(c); } @@ -279,7 +279,7 @@ char Adafruit_GPS::read(void) { if (paused || noComms) return c; -#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) +#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) if (gpsSwSerial) { if (!gpsSwSerial->available()) return c; diff --git a/src/Adafruit_GPS.h b/src/Adafruit_GPS.h index 4043c04..f3bf0c6 100644 --- a/src/Adafruit_GPS.h +++ b/src/Adafruit_GPS.h @@ -39,7 +39,7 @@ #endif #endif -#if (defined(__AVR__) || defined(ESP8266)) && !defined(NO_SW_SERIAL) +#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) #define USE_SW_SERIAL ///< insert line `#define NO_SW_SERIAL` before this header ///< if you don't want to include software serial in the #endif ///< library From ad02f6ed84585b7e866b9b850233d8c532d53e7c Mon Sep 17 00:00:00 2001 From: hobobandy <30026704+hobobandy@users.noreply.github.com> Date: Sun, 20 Aug 2023 10:31:52 -0400 Subject: [PATCH 2/3] Replace check with appropriate board constant ARDUINO_UNOR4_WIFI is used in compiler -D option --- src/Adafruit_GPS.cpp | 12 ++++++------ src/Adafruit_GPS.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Adafruit_GPS.cpp b/src/Adafruit_GPS.cpp index 04ec08c..25859ee 100644 --- a/src/Adafruit_GPS.cpp +++ b/src/Adafruit_GPS.cpp @@ -40,7 +40,7 @@ static bool strStartsWith(const char *str, const char *prefix); */ /**************************************************************************/ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) { -#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) if (gpsSwSerial) { gpsSwSerial->begin(baud_or_i2caddr); } @@ -78,7 +78,7 @@ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) { @param ser Pointer to SoftwareSerial device */ /**************************************************************************/ -#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser) { common_init(); // Set everything to common state, then... gpsSwSerial = ser; // ...override gpsSwSerial with value passed. @@ -147,7 +147,7 @@ Adafruit_GPS::Adafruit_GPS() { */ /**************************************************************************/ void Adafruit_GPS::common_init(void) { -#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) gpsSwSerial = NULL; // Set both to NULL, then override correct #endif gpsHwSerial = NULL; // port pointer in corresponding constructor @@ -196,7 +196,7 @@ size_t Adafruit_GPS::available(void) { if (paused) return 0; -#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) if (gpsSwSerial) { return gpsSwSerial->available(); } @@ -223,7 +223,7 @@ size_t Adafruit_GPS::available(void) { */ /**************************************************************************/ size_t Adafruit_GPS::write(uint8_t c) { -#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) if (gpsSwSerial) { return gpsSwSerial->write(c); } @@ -279,7 +279,7 @@ char Adafruit_GPS::read(void) { if (paused || noComms) return c; -#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) if (gpsSwSerial) { if (!gpsSwSerial->available()) return c; diff --git a/src/Adafruit_GPS.h b/src/Adafruit_GPS.h index f3bf0c6..06260cb 100644 --- a/src/Adafruit_GPS.h +++ b/src/Adafruit_GPS.h @@ -39,7 +39,7 @@ #endif #endif -#if (defined(__AVR__) || ((defined(ARDUINO_ARCH_RENESAS_UNO) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) #define USE_SW_SERIAL ///< insert line `#define NO_SW_SERIAL` before this header ///< if you don't want to include software serial in the #endif ///< library From ee7dd9c831a78969843fcd14ea1541100a54883c Mon Sep 17 00:00:00 2001 From: hobobandy <30026704+hobobandy@users.noreply.github.com> Date: Sun, 20 Aug 2023 14:33:48 -0400 Subject: [PATCH 3/3] Correct formatting to pass clang check --- src/Adafruit_GPS.cpp | 18 ++++++++++++------ src/Adafruit_GPS.h | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Adafruit_GPS.cpp b/src/Adafruit_GPS.cpp index 25859ee..e3664c6 100644 --- a/src/Adafruit_GPS.cpp +++ b/src/Adafruit_GPS.cpp @@ -40,7 +40,8 @@ static bool strStartsWith(const char *str, const char *prefix); */ /**************************************************************************/ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) { -#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \ + !defined(NO_SW_SERIAL))) if (gpsSwSerial) { gpsSwSerial->begin(baud_or_i2caddr); } @@ -78,7 +79,8 @@ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) { @param ser Pointer to SoftwareSerial device */ /**************************************************************************/ -#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \ + !defined(NO_SW_SERIAL))) Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser) { common_init(); // Set everything to common state, then... gpsSwSerial = ser; // ...override gpsSwSerial with value passed. @@ -147,7 +149,8 @@ Adafruit_GPS::Adafruit_GPS() { */ /**************************************************************************/ void Adafruit_GPS::common_init(void) { -#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \ + !defined(NO_SW_SERIAL))) gpsSwSerial = NULL; // Set both to NULL, then override correct #endif gpsHwSerial = NULL; // port pointer in corresponding constructor @@ -196,7 +199,8 @@ size_t Adafruit_GPS::available(void) { if (paused) return 0; -#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \ + !defined(NO_SW_SERIAL))) if (gpsSwSerial) { return gpsSwSerial->available(); } @@ -223,7 +227,8 @@ size_t Adafruit_GPS::available(void) { */ /**************************************************************************/ size_t Adafruit_GPS::write(uint8_t c) { -#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \ + !defined(NO_SW_SERIAL))) if (gpsSwSerial) { return gpsSwSerial->write(c); } @@ -279,7 +284,8 @@ char Adafruit_GPS::read(void) { if (paused || noComms) return c; -#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \ + !defined(NO_SW_SERIAL))) if (gpsSwSerial) { if (!gpsSwSerial->available()) return c; diff --git a/src/Adafruit_GPS.h b/src/Adafruit_GPS.h index 06260cb..60c5738 100644 --- a/src/Adafruit_GPS.h +++ b/src/Adafruit_GPS.h @@ -39,7 +39,8 @@ #endif #endif -#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && !defined(NO_SW_SERIAL))) +#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \ + !defined(NO_SW_SERIAL))) #define USE_SW_SERIAL ///< insert line `#define NO_SW_SERIAL` before this header ///< if you don't want to include software serial in the #endif ///< library