From c12e42443936a211d2218e287811a29075623d4c Mon Sep 17 00:00:00 2001 From: driverblock Date: Sun, 25 Sep 2016 10:26:05 -0400 Subject: [PATCH] Add define to use Software Serial Added a #define to enable software serial. Comment it out to not include software serial. Forum user request for ability to eliminate software serial. https://forums.adafruit.com/viewtopic.php?f=51&t=103611#p519211 --- Adafruit_GPS.cpp | 12 ++++++------ Adafruit_GPS.h | 9 ++++++--- library.properties | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Adafruit_GPS.cpp b/Adafruit_GPS.cpp index c898c47..f6ca13a 100755 --- a/Adafruit_GPS.cpp +++ b/Adafruit_GPS.cpp @@ -9,7 +9,7 @@ Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above must be included in any redistribution ****************************************/ -#ifdef __AVR__ +#if defined(__AVR__) && defined(USE_SW_SERIAL) // Only include software serial on AVR platforms (i.e. not on Due). #include #endif @@ -268,7 +268,7 @@ char Adafruit_GPS::read(void) { if (paused) return c; -#ifdef __AVR__ +#if defined(__AVR__) && defined(USE_SW_SERIAL) if(gpsSwSerial) { if(!gpsSwSerial->available()) return c; c = gpsSwSerial->read(); @@ -310,7 +310,7 @@ char Adafruit_GPS::read(void) { return c; } -#ifdef __AVR__ +#if defined(__AVR__) && defined(USE_SW_SERIAL) // Constructor when using SoftwareSerial or NewSoftSerial #if ARDUINO >= 100 Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser) @@ -331,7 +331,7 @@ Adafruit_GPS::Adafruit_GPS(HardwareSerial *ser) { // Initialization code used by all constructor types void Adafruit_GPS::common_init(void) { -#ifdef __AVR__ +#if defined(__AVR__) && defined(USE_SW_SERIAL) gpsSwSerial = NULL; // Set both to NULL, then override correct #endif gpsHwSerial = NULL; // port pointer in corresponding constructor @@ -352,7 +352,7 @@ void Adafruit_GPS::common_init(void) { void Adafruit_GPS::begin(uint32_t baud) { -#ifdef __AVR__ +#if defined(__AVR__) && defined(USE_SW_SERIAL) if(gpsSwSerial) gpsSwSerial->begin(baud); else @@ -363,7 +363,7 @@ void Adafruit_GPS::begin(uint32_t baud) } void Adafruit_GPS::sendCommand(const char *str) { -#ifdef __AVR__ +#if defined(__AVR__) && defined(USE_SW_SERIAL) if(gpsSwSerial) gpsSwSerial->println(str); else diff --git a/Adafruit_GPS.h b/Adafruit_GPS.h index 8a91531..13714aa 100755 --- a/Adafruit_GPS.h +++ b/Adafruit_GPS.h @@ -21,7 +21,10 @@ All text above must be included in any redistribution #ifndef _ADAFRUIT_GPS_H #define _ADAFRUIT_GPS_H -#ifdef __AVR__ +//comment this out if you don't want to include software serial in the library +#define USE_SW_SERIAL + +#if defined(__AVR__) && defined(USE_SW_SERIAL) #if ARDUINO >= 100 #include #else @@ -101,7 +104,7 @@ class Adafruit_GPS { public: void begin(uint32_t baud); -#ifdef __AVR__ +#if defined(__AVR__) && defined(USE_SW_SERIAL) #if ARDUINO >= 100 Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial #else @@ -154,7 +157,7 @@ class Adafruit_GPS { boolean paused; uint8_t parseResponse(char *response); -#ifdef __AVR__ +#if defined(__AVR__) && defined(USE_SW_SERIAL) #if ARDUINO >= 100 SoftwareSerial *gpsSwSerial; #else diff --git a/library.properties b/library.properties index b2218b6..ebc7483 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit GPS Library -version=1.0.1 +version=1.0.2 author=Adafruit maintainer=Adafruit sentence=An interrupt-based GPS library for no-parsing-required use