diff --git a/examples/GPS_HardwareSerial_EchoTest/GPS_HardwareSerial_EchoTest.ino b/examples/GPS_HardwareSerial_EchoTest/GPS_HardwareSerial_EchoTest.ino new file mode 100644 index 0000000..3208144 --- /dev/null +++ b/examples/GPS_HardwareSerial_EchoTest/GPS_HardwareSerial_EchoTest.ino @@ -0,0 +1,43 @@ +// Test code for Ultimate GPS Using Hardware Serial +// (e.g. GPS for Leonardo, Flora or FeatherWing) +// +// This code shows how to test a passthru between USB and hardware serial +// +// Tested and works great with the Adafruit GPS FeatherWing +// ------> https://www.adafruit.com/products/3133 +// or Flora GPS +// ------> https://www.adafruit.com/products/1059 +// but also works with the shield, breakout +// ------> https://www.adafruit.com/products/1272 +// ------> https://www.adafruit.com/products/746 +// +// Pick one up today at the Adafruit electronics shop +// and help support open source hardware & software! -ada + + +// what's the name of the hardware serial port? +#define GPSSerial Serial1 + + +void setup() { + // wait for hardware serial to appear + while (!Serial); + + // make this baud rate fast enough to we aren't waiting on it + Serial.begin(115200); + + // 9600 baud is the default rate for the Ultimate GPS + GPSSerial.begin(9600); +} + + +void loop() { + if (Serial.available()) { + char c = Serial.read(); + GPSSerial.write(c); + } + if (GPSSerial.available()) { + char c = GPSSerial.read(); + Serial.write(c); + } +} diff --git a/examples/flora_parsing/flora_parsing.ino b/examples/GPS_HardwareSerial_Parsing/GPS_HardwareSerial_Parsing.ino similarity index 80% rename from examples/flora_parsing/flora_parsing.ino rename to examples/GPS_HardwareSerial_Parsing/GPS_HardwareSerial_Parsing.ino index 33249bb..a059e9c 100644 --- a/examples/flora_parsing/flora_parsing.ino +++ b/examples/GPS_HardwareSerial_Parsing/GPS_HardwareSerial_Parsing.ino @@ -1,35 +1,38 @@ -// Test code for Ultimate GPS Using Hardware Serial ( -// e.g. Adafruit Flora GPS modules or GPS FeatherWing +// Test code for Ultimate GPS Using Hardware Serial (e.g. GPS Flora or FeatherWing) // -// This code shows how to listen to the GPS module in an interrupt -// which allows the program to have more 'freedom' - just parse -// when a new NMEA sentence is available! Then access data when -// desired. +// This code shows how to listen to the GPS module via polling. Best used with +// Feathers or Flora where you have hardware Serial and no interrupt // -// Tested and works great with the Adafruit Flora GPS module -// ------> http://adafruit.com/products/1059 -// ------> http://adafruit.com/products/3133 +// Tested and works great with the Adafruit GPS FeatherWing +// ------> https://www.adafruit.com/products/3133 +// or Flora GPS +// ------> https://www.adafruit.com/products/1059 +// but also works with the shield, breakout +// ------> https://www.adafruit.com/products/1272 +// ------> https://www.adafruit.com/products/746 +// // Pick one up today at the Adafruit electronics shop // and help support open source hardware & software! -ada #include -#ifdef __AVR__ - #include -#endif -// Connect to the GPS on the Serial1 hardware port -Adafruit_GPS GPS(&Serial1); +// what's the name of the hardware serial port? +#define GPSSerial Serial1 + +// Connect to the GPS on the hardware port +Adafruit_GPS GPS(&GPSSerial); // Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console // Set to 'true' if you want to debug and listen to the raw GPS sentences #define GPSECHO false - -// this keeps track of whether we're using the interrupt -// off by default! -boolean usingInterrupt = false; - + +uint32_t timer = millis(); + + void setup() { + //while (!Serial); // uncomment to have the sketch wait until Serial is ready + // connect at 115200 so we can read the GPS fast enough and echo without dropping chars // also spit it out Serial.begin(115200); @@ -52,13 +55,11 @@ void setup() GPS.sendCommand(PGCMD_ANTENNA); delay(1000); + // Ask for firmware version - Serial1.println(PMTK_Q_RELEASE); + GPSSerial.println(PMTK_Q_RELEASE); } - - - -uint32_t timer = millis(); + void loop() // run over and over again { // read data from the GPS in the 'main loop' @@ -103,4 +104,4 @@ void loop() // run over and over again Serial.print("Satellites: "); Serial.println((int)GPS.satellites); } } -} +} \ No newline at end of file diff --git a/examples/flora_gpstest/flora_gpstest.ino b/examples/flora_gpstest/flora_gpstest.ino deleted file mode 100644 index c8135ec..0000000 --- a/examples/flora_gpstest/flora_gpstest.ino +++ /dev/null @@ -1,19 +0,0 @@ -// test a passthru between USB and hardware serial - -void setup() { - while (!Serial); - Serial.begin(9600); - Serial1.begin(9600); -} - - -void loop() { - if (Serial.available()) { - char c = Serial.read(); - Serial1.write(c); - } - if (Serial1.available()) { - char c = Serial1.read(); - Serial.write(c); - } -}