cleaned up a tad
This commit is contained in:
parent
1b3b0b0836
commit
3b48046a6e
|
|
@ -64,6 +64,7 @@ All text above must be included in any redistribution
|
||||||
|
|
||||||
// request for updates on antenna status
|
// request for updates on antenna status
|
||||||
#define PGCMD_ANTENNA "$PGCMD,33,1*6C"
|
#define PGCMD_ANTENNA "$PGCMD,33,1*6C"
|
||||||
|
#define PGCMD_NOANTENNA "$PGCMD,33,0*6C"
|
||||||
|
|
||||||
// how long to wait when we're looking for a response
|
// how long to wait when we're looking for a response
|
||||||
#define MAXWAITSENTENCE 5
|
#define MAXWAITSENTENCE 5
|
||||||
|
|
|
||||||
|
|
@ -26,52 +26,51 @@
|
||||||
// If using software serial, keep these lines enabled
|
// If using software serial, keep these lines enabled
|
||||||
// (you can change the pin numbers to match your wiring):
|
// (you can change the pin numbers to match your wiring):
|
||||||
//SoftwareSerial mySerial(8, 7);
|
//SoftwareSerial mySerial(8, 7);
|
||||||
//Adafruit_GPS GPS(&mySerial);
|
|
||||||
|
|
||||||
// If using hardware serial, comment
|
// If using hardware serial, comment
|
||||||
// out the above two lines and enable these two lines instead:
|
// out the above two lines and enable these two lines instead:
|
||||||
Adafruit_GPS GPS(&Serial1);
|
|
||||||
HardwareSerial mySerial = Serial1;
|
HardwareSerial mySerial = Serial1;
|
||||||
|
|
||||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
|
||||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
|
||||||
#define GPSECHO true
|
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
|
||||||
|
|
||||||
void setup()
|
// turn on only the second sentence (GPRMC)
|
||||||
{
|
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
|
||||||
// connect at 115200 so we can read the GPS fast enuf and
|
// turn on GPRMC and GGA
|
||||||
// also spit it out
|
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||||
Serial.begin(115200);
|
// turn on ALL THE DATA
|
||||||
|
#define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||||
|
// turn off output
|
||||||
|
#define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||||
|
|
||||||
|
#define PMTK_Q_RELEASE "$PMTK605*31"
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
while (!Serial); // wait for leo to be ready
|
||||||
|
|
||||||
|
Serial.begin(57600); // this baud rate doesn't actually matter!
|
||||||
|
Serial1.begin(9600);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
Serial.println("Adafruit GPS library basic test!");
|
Serial.println("Get version!");
|
||||||
|
Serial1.println(PMTK_Q_RELEASE);
|
||||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
|
||||||
GPS.begin(9600);
|
|
||||||
|
|
||||||
// You can adjust which sentences to have the module emit, below
|
// you can send various commands to get it started
|
||||||
|
//mySerial.println(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||||
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
|
mySerial.println(PMTK_SET_NMEA_OUTPUT_ALLDATA);
|
||||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
|
||||||
// uncomment this line to turn on only the "minimum recommended" data for high update rates!
|
|
||||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
|
|
||||||
// uncomment this line to turn on all the available data - for 9600 baud you'll want 1 Hz rate
|
|
||||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_ALLDATA);
|
|
||||||
|
|
||||||
// Set the update rate
|
|
||||||
// 1 Hz update rate
|
|
||||||
//GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
|
|
||||||
// 5 Hz update rate- for 9600 baud you'll have to set the output to RMC or RMCGGA only (see above)
|
|
||||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ);
|
|
||||||
// 10 Hz update rate - for 9600 baud you'll have to set the output to RMC only (see above)
|
|
||||||
//GPS.sendCommand(PMTK_SET_NMEA_UPDATE_10HZ);
|
|
||||||
|
|
||||||
delay(1000);
|
mySerial.println(PMTK_SET_NMEA_UPDATE_1HZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() // run over and over again
|
|
||||||
{
|
void loop() {
|
||||||
char c = GPS.read();
|
if (Serial.available()) {
|
||||||
// if you want to debug, this is a good time to do it!
|
char c = Serial.read();
|
||||||
if (GPSECHO)
|
Serial.write(c);
|
||||||
if (c) Serial.write(c);
|
mySerial.write(c);
|
||||||
}
|
}
|
||||||
|
if (mySerial.available()) {
|
||||||
|
char c = mySerial.read();
|
||||||
|
Serial.write(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -43,6 +43,8 @@ Adafruit_GPS GPS(&mySerial);
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
while (!Serial); // Leonardo will wait till serial connects
|
||||||
|
|
||||||
// connect at 115200 so we can read the GPS fast enuf and
|
// connect at 115200 so we can read the GPS fast enuf and
|
||||||
// also spit it out
|
// also spit it out
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
@ -68,7 +70,13 @@ void loop() // run over and over again
|
||||||
// If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
|
// If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
|
||||||
if (mySerial.available()) {
|
if (mySerial.available()) {
|
||||||
char c = mySerial.read();
|
char c = mySerial.read();
|
||||||
if (c) UDR0 = c;
|
if (c) {
|
||||||
|
#ifdef UDR0
|
||||||
|
UDR0 = c;
|
||||||
|
#else
|
||||||
|
Serial.print(c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
while (!Serial); // the Leonardo will 'wait' until the USB plug is connected
|
||||||
|
|
||||||
// connect at 115200 so we can read the GPS fast enuf and
|
// connect at 115200 so we can read the GPS fast enuf and
|
||||||
// also spit it out
|
// also spit it out
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
@ -88,14 +90,18 @@ void loop() // run over and over again
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||||
SIGNAL(TIMER0_COMPA_vect) {
|
SIGNAL(TIMER0_COMPA_vect) {
|
||||||
char c = GPS.read();
|
char c = GPS.read();
|
||||||
// if you want to debug, this is a good time to do it!
|
// if you want to debug, this is a good time to do it!
|
||||||
if (GPSECHO)
|
if (GPSECHO && c) {
|
||||||
if (c) UDR0 = c;
|
#ifdef UDR0
|
||||||
|
UDR0 = c;
|
||||||
// writing direct to UDR0 is much much faster than Serial.print
|
// writing direct to UDR0 is much much faster than Serial.print
|
||||||
// but only one character can be written at a time.
|
// but only one character can be written at a time.
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void useInterrupt(boolean v) {
|
void useInterrupt(boolean v) {
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,7 @@
|
||||||
// and help support open source hardware & software! -ada
|
// and help support open source hardware & software! -ada
|
||||||
|
|
||||||
#include <Adafruit_GPS.h>
|
#include <Adafruit_GPS.h>
|
||||||
#if ARDUINO >= 100
|
#include <SoftwareSerial.h>
|
||||||
#include <SoftwareSerial.h>
|
|
||||||
#else
|
|
||||||
// Older Arduino IDE requires NewSoftSerial, download from:
|
|
||||||
// http://arduiniana.org/libraries/newsoftserial/
|
|
||||||
// #include <NewSoftSerial.h>
|
|
||||||
// DO NOT install NewSoftSerial if using Arduino 1.0 or later!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Connect the GPS Power pin to 5V
|
// Connect the GPS Power pin to 5V
|
||||||
// Connect the GPS Ground pin to ground
|
// Connect the GPS Ground pin to ground
|
||||||
|
|
@ -31,11 +24,8 @@
|
||||||
|
|
||||||
// If using software serial, keep these lines enabled
|
// If using software serial, keep these lines enabled
|
||||||
// (you can change the pin numbers to match your wiring):
|
// (you can change the pin numbers to match your wiring):
|
||||||
#if ARDUINO >= 100
|
SoftwareSerial mySerial(3, 2);
|
||||||
SoftwareSerial mySerial(3, 2);
|
|
||||||
#else
|
|
||||||
NewSoftSerial mySerial(3, 2);
|
|
||||||
#endif
|
|
||||||
Adafruit_GPS GPS(&mySerial);
|
Adafruit_GPS GPS(&mySerial);
|
||||||
// If using hardware serial (e.g. Arduino Mega), comment
|
// If using hardware serial (e.g. Arduino Mega), comment
|
||||||
// out the above six lines and enable this line instead:
|
// out the above six lines and enable this line instead:
|
||||||
|
|
@ -53,6 +43,8 @@ void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
while (!Serial); // the Leonardo will 'wait' until the USB plug is connected
|
||||||
|
|
||||||
// connect at 115200 so we can read the GPS fast enuf and
|
// connect at 115200 so we can read the GPS fast enuf and
|
||||||
// also spit it out
|
// also spit it out
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
@ -124,13 +116,16 @@ void loop() // run over and over again
|
||||||
SIGNAL(TIMER0_COMPA_vect) {
|
SIGNAL(TIMER0_COMPA_vect) {
|
||||||
char c = GPS.read();
|
char c = GPS.read();
|
||||||
// if you want to debug, this is a good time to do it!
|
// if you want to debug, this is a good time to do it!
|
||||||
if (GPSECHO)
|
if (GPSECHO && c) {
|
||||||
if (c) UDR0 = c;
|
#ifdef UDR0
|
||||||
|
UDR0 = c;
|
||||||
// writing direct to UDR0 is much much faster than Serial.print
|
// writing direct to UDR0 is much much faster than Serial.print
|
||||||
// but only one character can be written at a time.
|
// but only one character can be written at a time.
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void useInterrupt(boolean v) {
|
void useInterrupt(boolean v) {
|
||||||
if (v) {
|
if (v) {
|
||||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue