diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2f8075b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: c +sudo: false +# Blacklist +branches: + except: + - gh-pages +cache: + directories: + - ~/arduino_ide + - ~/.arduino15/packages/ +git: + depth: false + quiet: true +env: + global: + - PRETTYNAME="Adafruit GPS" +# Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile" +# - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile + +before_install: + - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) + +script: + - build_main_platforms + +# Generate and deploy documentation +after_success: + - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh) + - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh) diff --git a/Adafruit_GPS.cpp b/Adafruit_GPS.cpp index 9e7c713..2cade6e 100755 --- a/Adafruit_GPS.cpp +++ b/Adafruit_GPS.cpp @@ -1,35 +1,56 @@ -/*********************************** -This is our GPS library +/**************************************************************************/ +/*! + @file Adafruit_GPS.cpp -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! + @mainpage Adafruit Ultimate GPS Breakout + + @section intro Introduction + + This is the Adafruit GPS library - the ultimate GPS library + for the ultimate GPS module! + + Tested and works great with the Adafruit Ultimate GPS module + using MTK33x9 chipset + ------> http://www.adafruit.com/products/746 + + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + @section author Author + + Written by Limor Fried/Ladyada for Adafruit Industries. + + @section license License + + BSD license, check license.txt for more information + All text above must be included in any redistribution +*/ +/**************************************************************************/ -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 -****************************************/ #if defined(__AVR__) && defined(USE_SW_SERIAL) // Only include software serial on AVR platforms (i.e. not on Due). #include #endif #include -// how long are max NMEA lines to parse? -#define MAXLINELENGTH 120 - -// we double buffer: read one line in and leave one for the main program -volatile char line1[MAXLINELENGTH]; -volatile char line2[MAXLINELENGTH]; -// our index into filling the current line -volatile uint8_t lineidx=0; -// pointers to the double buffers -volatile char *currentline; -volatile char *lastline; -volatile boolean recvdflag; -volatile boolean inStandbyMode; +#define MAXLINELENGTH 120 ///< how long are max NMEA lines to parse? +volatile char line1[MAXLINELENGTH]; ///< We double buffer: read one line in and leave one for the main program +volatile char line2[MAXLINELENGTH]; ///< Second buffer +volatile uint8_t lineidx=0; ///< our index into filling the current line +volatile char *currentline; ///< Pointer to current line buffer +volatile char *lastline; ///< Pointer to previous line buffer +volatile boolean recvdflag; ///< Received flag +volatile boolean inStandbyMode; ///< In standby flag +/**************************************************************************/ +/*! + @brief Parse a NMEA string + @param nmea Pointer to the NMEA string + @return True if we parsed it, false if it has an invalid checksum or invalid data +*/ +/**************************************************************************/ boolean Adafruit_GPS::parse(char *nmea) { // do checksum check @@ -37,8 +58,8 @@ boolean Adafruit_GPS::parse(char *nmea) { if (nmea[strlen(nmea)-4] == '*') { uint16_t sum = parseHex(nmea[strlen(nmea)-3]) * 16; sum += parseHex(nmea[strlen(nmea)-2]); - - // check checksum + + // check checksum for (uint8_t i=2; i < (strlen(nmea)-4); i++) { sum ^= nmea[i]; } @@ -82,7 +103,7 @@ boolean Adafruit_GPS::parse(char *nmea) { latitudeDegrees = (latitude-100*int(latitude/100))/60.0; latitudeDegrees += int(latitude/100); } - + p = strchr(p, ',')+1; if (',' != *p) { @@ -92,7 +113,7 @@ boolean Adafruit_GPS::parse(char *nmea) { else if (p[0] == ',') lat = 0; else return false; } - + // parse out longitude p = strchr(p, ',')+1; if (',' != *p) @@ -111,7 +132,7 @@ boolean Adafruit_GPS::parse(char *nmea) { longitudeDegrees = (longitude-100*int(longitude/100))/60.0; longitudeDegrees += int(longitude/100); } - + p = strchr(p, ',')+1; if (',' != *p) { @@ -121,31 +142,31 @@ boolean Adafruit_GPS::parse(char *nmea) { else if (p[0] == ',') lon = 0; else return false; } - + p = strchr(p, ',')+1; if (',' != *p) { fixquality = atoi(p); } - + p = strchr(p, ',')+1; if (',' != *p) { satellites = atoi(p); } - + p = strchr(p, ',')+1; if (',' != *p) { HDOP = atof(p); } - + p = strchr(p, ',')+1; if (',' != *p) { altitude = atof(p); } - + p = strchr(p, ',')+1; p = strchr(p, ',')+1; if (',' != *p) @@ -170,7 +191,7 @@ boolean Adafruit_GPS::parse(char *nmea) { p = strchr(p, ',')+1; // Serial.println(p); - if (p[0] == 'A') + if (p[0] == 'A') fix = true; else if (p[0] == 'V') fix = false; @@ -195,7 +216,7 @@ boolean Adafruit_GPS::parse(char *nmea) { latitudeDegrees = (latitude-100*int(latitude/100))/60.0; latitudeDegrees += int(latitude/100); } - + p = strchr(p, ',')+1; if (',' != *p) { @@ -205,7 +226,7 @@ boolean Adafruit_GPS::parse(char *nmea) { else if (p[0] == ',') lat = 0; else return false; } - + // parse out longitude p = strchr(p, ',')+1; if (',' != *p) @@ -224,7 +245,7 @@ boolean Adafruit_GPS::parse(char *nmea) { longitudeDegrees = (longitude-100*int(longitude/100))/60.0; longitudeDegrees += int(longitude/100); } - + p = strchr(p, ',')+1; if (',' != *p) { @@ -240,14 +261,14 @@ boolean Adafruit_GPS::parse(char *nmea) { { speed = atof(p); } - + // angle p = strchr(p, ',')+1; if (',' != *p) { angle = atof(p); } - + p = strchr(p, ',')+1; if (',' != *p) { @@ -263,16 +284,22 @@ boolean Adafruit_GPS::parse(char *nmea) { return false; } +/**************************************************************************/ +/*! + @brief Read one character from the GPS device + @return The character that we received, or 0 if nothing was available +*/ +/**************************************************************************/ char Adafruit_GPS::read(void) { char c = 0; - + if (paused) return c; #if defined(__AVR__) && defined(USE_SW_SERIAL) if(gpsSwSerial) { if(!gpsSwSerial->available()) return c; c = gpsSwSerial->read(); - } else + } else #endif { if(!gpsHwSerial->available()) return c; @@ -310,26 +337,40 @@ char Adafruit_GPS::read(void) { return c; } +/**************************************************************************/ +/*! + @brief Constructor when using SoftwareSerial or NewSoftSerial + @param ser Pointer to SoftwareSerial device or NewSoftSerial device +*/ +/**************************************************************************/ #if defined(__AVR__) && defined(USE_SW_SERIAL) -// Constructor when using SoftwareSerial or NewSoftSerial -#if ARDUINO >= 100 + #if ARDUINO >= 100 Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser) -#else -Adafruit_GPS::Adafruit_GPS(NewSoftSerial *ser) -#endif + #else +Adafruit_GPS::Adafruit_GPS(NewSoftSerial *ser) + #endif { common_init(); // Set everything to common state, then... gpsSwSerial = ser; // ...override gpsSwSerial with value passed. } #endif -// Constructor when using HardwareSerial +/**************************************************************************/ +/*! + @brief Constructor when using HardwareSerial + @param ser Pointer to a HardwareSerial object +*/ +/**************************************************************************/ Adafruit_GPS::Adafruit_GPS(HardwareSerial *ser) { common_init(); // Set everything to common state, then... gpsHwSerial = ser; // ...override gpsHwSerial with value passed. } -// Initialization code used by all constructor types +/**************************************************************************/ +/*! + @brief Initialization code used by all constructor types +*/ +/**************************************************************************/ void Adafruit_GPS::common_init(void) { #if defined(__AVR__) && defined(USE_SW_SERIAL) gpsSwSerial = NULL; // Set both to NULL, then override correct @@ -350,40 +391,77 @@ void Adafruit_GPS::common_init(void) { speed = angle = magvariation = HDOP = 0.0; // float } +/**************************************************************************/ +/*! + @brief Start the HW or SW serial port + @param baud Baud rate +*/ +/**************************************************************************/ void Adafruit_GPS::begin(uint32_t baud) { #if defined(__AVR__) && defined(USE_SW_SERIAL) - if(gpsSwSerial) + if(gpsSwSerial) gpsSwSerial->begin(baud); - else + else #endif gpsHwSerial->begin(baud); delay(10); } +/**************************************************************************/ +/*! + @brief Send a command to the GPS device + @param str Pointer to a string holding the command to send +*/ +/**************************************************************************/ void Adafruit_GPS::sendCommand(const char *str) { #if defined(__AVR__) && defined(USE_SW_SERIAL) - if(gpsSwSerial) + if(gpsSwSerial) gpsSwSerial->println(str); - else + else #endif gpsHwSerial->println(str); } +/**************************************************************************/ +/*! + @brief Check to see if a new NMEA line has been received + @return True if received, false if not +*/ +/**************************************************************************/ boolean Adafruit_GPS::newNMEAreceived(void) { return recvdflag; } +/**************************************************************************/ +/*! + @brief Pause/unpause receiving new data + @param p True = pause, false = unpause +*/ +/**************************************************************************/ void Adafruit_GPS::pause(boolean p) { paused = p; } +/**************************************************************************/ +/*! + @brief Returns the last NMEA line received and unsets the received flag + @return Pointer to the last line string +*/ +/**************************************************************************/ char *Adafruit_GPS::lastNMEA(void) { recvdflag = false; return (char *)lastline; } +/**************************************************************************/ +/*! + @brief Parse a hex character and return the appropriate decimal value + @param c Hex character, e.g. '0' or 'B' + @return Integer value of the hex character. Returns 0 if c is not a proper character +*/ +/**************************************************************************/ // read a Hex value and return the decimal equivalent uint8_t Adafruit_GPS::parseHex(char c) { if (c < '0') @@ -398,6 +476,14 @@ uint8_t Adafruit_GPS::parseHex(char c) { return 0; } +/**************************************************************************/ +/*! + @brief Wait for a specified sentence from the device + @param wait4me Pointer to a string holding the desired response + @param max How long to wait, default is MAXWAITSENTENCE + @return True if we got what we wanted, false otherwise +*/ +/**************************************************************************/ boolean Adafruit_GPS::waitForSentence(const char *wait4me, uint8_t max) { char str[20]; @@ -405,51 +491,69 @@ boolean Adafruit_GPS::waitForSentence(const char *wait4me, uint8_t max) { while (i < max) { read(); - if (newNMEAreceived()) { + if (newNMEAreceived()) { char *nmea = lastNMEA(); strncpy(str, nmea, 20); str[19] = 0; i++; - if (strstr(str, wait4me)) - return true; + if (strstr(str, wait4me)) + return true; } } return false; } +/**************************************************************************/ +/*! + @brief Start the LOCUS logger + @return True on success, false if it failed +*/ +/**************************************************************************/ boolean Adafruit_GPS::LOCUS_StartLogger(void) { sendCommand(PMTK_LOCUS_STARTLOG); recvdflag = false; return waitForSentence(PMTK_LOCUS_STARTSTOPACK); } +/**************************************************************************/ +/*! + @brief Stop the LOCUS logger + @return True on success, false if it failed +*/ +/**************************************************************************/ boolean Adafruit_GPS::LOCUS_StopLogger(void) { sendCommand(PMTK_LOCUS_STOPLOG); recvdflag = false; return waitForSentence(PMTK_LOCUS_STARTSTOPACK); } +/**************************************************************************/ +/*! + @brief Read the logger status + @return True if we read the data, false if there was no response +*/ +/**************************************************************************/ boolean Adafruit_GPS::LOCUS_ReadStatus(void) { sendCommand(PMTK_LOCUS_QUERY_STATUS); - + if (! waitForSentence("$PMTKLOG")) return false; char *response = lastNMEA(); uint16_t parsed[10]; uint8_t i; - + for (i=0; i<10; i++) parsed[i] = -1; - + response = strchr(response, ','); for (i=0; i<10; i++) { - if (!response || (response[0] == 0) || (response[0] == '*')) + if (!response || (response[0] == 0) || (response[0] == '*')) break; response++; parsed[i]=0; - while ((response[0] != ',') && + while ((response[0] != ',') && (response[0] != '*') && (response[0] != 0)) { parsed[i] *= 10; char c = response[0]; @@ -463,7 +567,7 @@ boolean Adafruit_GPS::LOCUS_ReadStatus(void) { LOCUS_serial = parsed[0]; LOCUS_type = parsed[1]; if (isAlpha(parsed[2])) { - parsed[2] = parsed[2] - 'a' + 10; + parsed[2] = parsed[2] - 'a' + 10; } LOCUS_mode = parsed[2]; LOCUS_config = parsed[3]; @@ -477,7 +581,12 @@ boolean Adafruit_GPS::LOCUS_ReadStatus(void) { return true; } -// Standby Mode Switches +/**************************************************************************/ +/*! + @brief Standby Mode Switches + @return False if already in standby, true if it entered standby +*/ +/**************************************************************************/ boolean Adafruit_GPS::standby(void) { if (inStandbyMode) { return false; // Returns false if already in standby mode, so that you do not wake it up by sending commands to GPS @@ -490,6 +599,12 @@ boolean Adafruit_GPS::standby(void) { } } +/**************************************************************************/ +/*! + @brief Wake the sensor up + @return True if woken up, false if not in standby or failed to wake +*/ +/**************************************************************************/ boolean Adafruit_GPS::wakeup(void) { if (inStandbyMode) { inStandbyMode = false; diff --git a/Adafruit_GPS.h b/Adafruit_GPS.h index dc9cb71..174b25d 100755 --- a/Adafruit_GPS.h +++ b/Adafruit_GPS.h @@ -1,28 +1,32 @@ -/*********************************** -This is the Adafruit GPS library - the ultimate GPS library -for the ultimate GPS module! +/**************************************************************************/ +/*! + @file Adafruit_GPS.h -Tested and works great with the Adafruit Ultimate GPS module -using MTK33x9 chipset - ------> http://www.adafruit.com/products/746 -Pick one up today at the Adafruit electronics shop -and help support open source hardware & software! -ada + This is the Adafruit GPS library - the ultimate GPS library + for the ultimate GPS module! -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! + Tested and works great with the Adafruit Ultimate GPS module + using MTK33x9 chipset + ------> http://www.adafruit.com/products/746 + Pick one up today at the Adafruit electronics shop + and help support open source hardware & software! -ada -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 -****************************************/ -// Fllybob added lines 34,35 and 40,41 to add 100mHz logging capability + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + 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 +*/ +/**************************************************************************/ + +// Fllybob added lines 34,35 and 40,41 to add 100mHz logging capability #ifndef _ADAFRUIT_GPS_H #define _ADAFRUIT_GPS_H -//comment this out if you don't want to include software serial in the library -#define USE_SW_SERIAL +#define USE_SW_SERIAL ///< comment this out if you don't want to include software serial in the library #if defined(__AVR__) && defined(USE_SW_SERIAL) #if ARDUINO >= 100 @@ -32,63 +36,58 @@ All text above must be included in any redistribution #endif #endif -// different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz) -// Note that these only control the rate at which the position is echoed, to actually speed up the -// position fix you must also send one of the position fix rate commands below too. -#define PMTK_SET_NMEA_UPDATE_100_MILLIHERTZ "$PMTK220,10000*2F" // Once every 10 seconds, 100 millihertz. -#define PMTK_SET_NMEA_UPDATE_200_MILLIHERTZ "$PMTK220,5000*1B" // Once every 5 seconds, 200 millihertz. -#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F" -#define PMTK_SET_NMEA_UPDATE_2HZ "$PMTK220,500*2B" -#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C" -#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F" +/**************************************************************************/ +/** + Different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz) + Note that these only control the rate at which the position is echoed, to actually speed up the + position fix you must also send one of the position fix rate commands below too. */ +#define PMTK_SET_NMEA_UPDATE_100_MILLIHERTZ "$PMTK220,10000*2F" ///< Once every 10 seconds, 100 millihertz. +#define PMTK_SET_NMEA_UPDATE_200_MILLIHERTZ "$PMTK220,5000*1B" ///< Once every 5 seconds, 200 millihertz. +#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F" ///< 1 Hz +#define PMTK_SET_NMEA_UPDATE_2HZ "$PMTK220,500*2B" ///< 2 Hz +#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C" ///< 5 Hz +#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F" ///< 10 Hz // Position fix update rate commands. -#define PMTK_API_SET_FIX_CTL_100_MILLIHERTZ "$PMTK300,10000,0,0,0,0*2C" // Once every 10 seconds, 100 millihertz. -#define PMTK_API_SET_FIX_CTL_200_MILLIHERTZ "$PMTK300,5000,0,0,0,0*18" // Once every 5 seconds, 200 millihertz. -#define PMTK_API_SET_FIX_CTL_1HZ "$PMTK300,1000,0,0,0,0*1C" -#define PMTK_API_SET_FIX_CTL_5HZ "$PMTK300,200,0,0,0,0*2F" +#define PMTK_API_SET_FIX_CTL_100_MILLIHERTZ "$PMTK300,10000,0,0,0,0*2C" ///< Once every 10 seconds, 100 millihertz. +#define PMTK_API_SET_FIX_CTL_200_MILLIHERTZ "$PMTK300,5000,0,0,0,0*18" ///< Once every 5 seconds, 200 millihertz. +#define PMTK_API_SET_FIX_CTL_1HZ "$PMTK300,1000,0,0,0,0*1C" ///< 1 Hz +#define PMTK_API_SET_FIX_CTL_5HZ "$PMTK300,200,0,0,0,0*2F" ///< 5 Hz // Can't fix position faster than 5 times a second! +#define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C" ///< 57600 bps +#define PMTK_SET_BAUD_9600 "$PMTK251,9600*17" ///< 9600 bps -#define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C" -#define PMTK_SET_BAUD_9600 "$PMTK251,9600*17" - -// 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" -// turn on GPRMC and GGA -#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" -// 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_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" ///< turn on only the second sentence (GPRMC) +#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" ///< turn on GPRMC and GGA +#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 on ALL THE DATA +#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" ///< turn off output // to generate your own sentences, check out the MTK command datasheet and use a checksum calculator // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html -#define PMTK_LOCUS_STARTLOG "$PMTK185,0*22" -#define PMTK_LOCUS_STOPLOG "$PMTK185,1*23" -#define PMTK_LOCUS_STARTSTOPACK "$PMTK001,185,3*3C" -#define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38" -#define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22" -#define LOCUS_OVERLAP 0 -#define LOCUS_FULLSTOP 1 +#define PMTK_LOCUS_STARTLOG "$PMTK185,0*22" ///< Start logging data +#define PMTK_LOCUS_STOPLOG "$PMTK185,1*23" ///< Stop logging data +#define PMTK_LOCUS_STARTSTOPACK "$PMTK001,185,3*3C" ///< Acknowledge the start or stop command +#define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38" ///< Query the logging status +#define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22" ///< Erase the log flash data +#define LOCUS_OVERLAP 0 ///< If flash is full, log will overwrite old data with new logs +#define LOCUS_FULLSTOP 1 ///< If flash is full, logging will stop -#define PMTK_ENABLE_SBAS "$PMTK313,1*2E" -#define PMTK_ENABLE_WAAS "$PMTK301,2*2E" +#define PMTK_ENABLE_SBAS "$PMTK313,1*2E" ///< Enable search for SBAS satellite (only works with 1Hz output rate) +#define PMTK_ENABLE_WAAS "$PMTK301,2*2E" ///< Use WAAS for DGPS correction data -// standby command & boot successful message -#define PMTK_STANDBY "$PMTK161,0*28" -#define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently -#define PMTK_AWAKE "$PMTK010,002*2D" +#define PMTK_STANDBY "$PMTK161,0*28" ///< standby command & boot successful message +#define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" ///< Not needed currently +#define PMTK_AWAKE "$PMTK010,002*2D" ///< Wake up -// ask for the release and version -#define PMTK_Q_RELEASE "$PMTK605*31" +#define PMTK_Q_RELEASE "$PMTK605*31" ///< ask for the release and version -// request for updates on antenna status -#define PGCMD_ANTENNA "$PGCMD,33,1*6C" -#define PGCMD_NOANTENNA "$PGCMD,33,0*6D" -// how long to wait when we're looking for a response -#define MAXWAITSENTENCE 10 +#define PGCMD_ANTENNA "$PGCMD,33,1*6C" ///< request for updates on antenna status +#define PGCMD_NOANTENNA "$PGCMD,33,0*6D" ///< don't show antenna status messages + +#define MAXWAITSENTENCE 10 ///< how long to wait when we're looking for a response +/**************************************************************************/ #if ARDUINO >= 100 #include "Arduino.h" @@ -100,13 +99,16 @@ All text above must be included in any redistribution #include "NewSoftSerial.h" #endif - +/**************************************************************************/ +/*! + @brief The GPS class +*/ class Adafruit_GPS { public: - void begin(uint32_t baud); + void begin(uint32_t baud); #if defined(__AVR__) && defined(USE_SW_SERIAL) - #if ARDUINO >= 100 + #if ARDUINO >= 100 Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial #else Adafruit_GPS(NewSoftSerial *ser); // Constructor when using NewSoftSerial @@ -119,10 +121,9 @@ class Adafruit_GPS { void common_init(void); void sendCommand(const char *); - + void pause(boolean b); - boolean parseNMEA(char *response); uint8_t parseHex(char c); char read(void); @@ -131,31 +132,57 @@ class Adafruit_GPS { boolean wakeup(void); boolean standby(void); - uint8_t hour, minute, seconds, year, month, day; - uint16_t milliseconds; - // Floating point latitude and longitude value in degrees. - float latitude, longitude; - // Fixed point latitude and longitude value with degrees stored in units of 1/100000 degrees, - // and minutes stored in units of 1/100000 degrees. See pull #13 for more details: - // https://github.com/adafruit/Adafruit-GPS-Library/pull/13 - int32_t latitude_fixed, longitude_fixed; - float latitudeDegrees, longitudeDegrees; - float geoidheight, altitude; - float speed, angle, magvariation, HDOP; - char lat, lon, mag; - boolean fix; - uint8_t fixquality, satellites; + uint8_t hour; ///< GMT hours + uint8_t minute; ///< GMT minutes + uint8_t seconds; ///< GMT seconds + uint16_t milliseconds; ///< GMT milliseconds + uint8_t year; ///< GMT year + uint8_t month; ///< GMT month + uint8_t day; ///< GMT day + + float latitude; ///< Floating point latitude value in degrees/minutes as received from the GPS (DDMM.MMMM) + float longitude; ///< Floating point longitude value in degrees/minutes as received from the GPS (DDDMM.MMMM) + + /** Fixed point latitude and longitude value with degrees stored in units of 1/100000 degrees, + and minutes stored in units of 1/100000 degrees. See pull #13 for more details: + https://github.com/adafruit/Adafruit-GPS-Library/pull/13 */ + int32_t latitude_fixed; ///< Fixed point latitude in decimal degrees + int32_t longitude_fixed; ///< Fixed point longitude in decimal degrees + + float latitudeDegrees; ///< Latitude in decimal degrees + float longitudeDegrees; ///< Longitude in decimal degrees + float geoidheight; ///< Diff between geoid height and WGS84 height + float altitude; ///< Altitude in meters above MSL + float speed; ///< Current speed over ground in knots + float angle; ///< Course in degrees from true north + float magvariation; ///< Magnetic variation in degrees (vs. true north) + float HDOP; ///< Horizontal Dilution of Precision - relative accuracy of horizontal position + char lat; ///< N/S + char lon; ///< E/W + char mag; ///< Magnetic variation direction + boolean fix; ///< Have a fix? + uint8_t fixquality; ///< Fix quality (0, 1, 2 = Invalid, GPS, DGPS) + uint8_t satellites; ///< Number of satellites in use boolean waitForSentence(const char *wait, uint8_t max = MAXWAITSENTENCE); boolean LOCUS_StartLogger(void); boolean LOCUS_StopLogger(void); boolean LOCUS_ReadStatus(void); - uint16_t LOCUS_serial, LOCUS_records; - uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent; + uint16_t LOCUS_serial; ///< Log serial number + uint16_t LOCUS_records; ///< Log number of data record + uint8_t LOCUS_type; ///< Log type, 0: Overlap, 1: FullStop + uint8_t LOCUS_mode; ///< Logging mode, 0x08 interval logger + uint8_t LOCUS_config; ///< Contents of configuration + uint8_t LOCUS_interval; ///< Interval setting + uint8_t LOCUS_distance; ///< Distance setting + uint8_t LOCUS_speed; ///< Speed setting + uint8_t LOCUS_status; ///< 0: Logging, 1: Stop logging + uint8_t LOCUS_percent; ///< Log life used percentage + private: boolean paused; - + uint8_t parseResponse(char *response); #if defined(__AVR__) && defined(USE_SW_SERIAL) #if ARDUINO >= 100 @@ -166,6 +193,6 @@ class Adafruit_GPS { #endif HardwareSerial *gpsHwSerial; }; - +/**************************************************************************/ #endif diff --git a/README.md b/README.md new file mode 100644 index 0000000..0bbb3a9 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Adafruit_GPS [![Build Status](https://travis-ci.com/adafruit/Adafruit_GPS.svg?branch=master)](https://travis-ci.com/adafruit/Adafruit_GPS) + +This is the Adafruit GPS library - the ultimate GPS library +for the ultimate GPS module! + +Tested and works great with the Adafruit Ultimate GPS module +using MTK33x9 chipset +------> http://www.adafruit.com/products/746 + +These modules use TTL serial to communicate, 2 pins are required to +interface. + +Adafruit invests time and resources providing this open source code, +please support Adafruit and open-source hardware by purchasing +products from Adafruit! + +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 + +To install, use the Arduino Library Manager to search for 'Adafruit GPS' and install the library. diff --git a/README.txt b/README.txt deleted file mode 100644 index 8f45ba8..0000000 --- a/README.txt +++ /dev/null @@ -1,21 +0,0 @@ -This is the Adafruit GPS library - the ultimate GPS library -for the ultimate GPS module! - -Tested and works great with the Adafruit Ultimate GPS module -using MTK33x9 chipset - ------> http://www.adafruit.com/products/746 - -These modules use TTL serial to communicate, 2 pins are required to -interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -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 - -To download. click the "Download ZIP" at the right side, extract the archive and rename the uncompressed folder Adafruit_GPS. Check that the Adafruit_GPS folder contains Adafruit_GPS.cpp and Adafruit_GPS.h - -Place the Adafruit_GPS library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. diff --git a/code-of-conduct.md b/code-of-conduct.md new file mode 100644 index 0000000..8ee6e44 --- /dev/null +++ b/code-of-conduct.md @@ -0,0 +1,127 @@ +# Adafruit Community Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and leaders pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level or type of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +We are committed to providing a friendly, safe and welcoming environment for +all. + +Examples of behavior that contributes to creating a positive environment +include: + +* Be kind and courteous to others +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Collaborating with other community members +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and sexual attention or advances +* The use of inappropriate images, including in a community member's avatar +* The use of inappropriate language, including in a community member's nickname +* Any spamming, flaming, baiting or other attention-stealing behavior +* Excessive or unwelcome helping; answering outside the scope of the question + asked +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate + +The goal of the standards and moderation guidelines outlined here is to build +and maintain a respectful community. We ask that you don’t just aim to be +"technically unimpeachable", but rather try to be your best self. + +We value many things beyond technical expertise, including collaboration and +supporting others within our community. Providing a positive experience for +other community members can have a much more significant impact than simply +providing the correct answer. + +## Our Responsibilities + +Project leaders are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project leaders have the right and responsibility to remove, edit, or +reject messages, comments, commits, code, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any community member for other behaviors that they deem +inappropriate, threatening, offensive, or harmful. + +## Moderation + +Instances of behaviors that violate the Adafruit Community Code of Conduct +may be reported by any member of the community. Community members are +encouraged to report these situations, including situations they witness +involving other community members. + +You may report in the following ways: + +In any situation, you may send an email to . + +On the Adafruit Discord, you may send an open message from any channel +to all Community Helpers by tagging @community helpers. You may also send an +open message from any channel, or a direct message to @kattni#1507, +@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or +@Andon#8175. + +Email and direct message reports will be kept confidential. + +In situations on Discord where the issue is particularly egregious, possibly +illegal, requires immediate action, or violates the Discord terms of service, +you should also report the message directly to Discord. + +These are the steps for upholding our community’s standards of conduct. + +1. Any member of the community may report any situation that violates the +Adafruit Community Code of Conduct. All reports will be reviewed and +investigated. +2. If the behavior is an egregious violation, the community member who +committed the violation may be banned immediately, without warning. +3. Otherwise, moderators will first respond to such behavior with a warning. +4. Moderators follow a soft "three strikes" policy - the community member may +be given another chance, if they are receptive to the warning and change their +behavior. +5. If the community member is unreceptive or unreasonable when warned by a +moderator, or the warning goes unheeded, they may be banned for a first or +second offense. Repeated offenses will result in the community member being +banned. + +## Scope + +This Code of Conduct and the enforcement policies listed above apply to all +Adafruit Community venues. This includes but is not limited to any community +spaces (both public and private), the entire Adafruit Discord server, and +Adafruit GitHub repositories. Examples of Adafruit Community spaces include +but are not limited to meet-ups, audio chats on the Adafruit Discord, or +interaction at a conference. + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. As a community +member, you are representing our community, and are expected to behave +accordingly. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at +, +and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). + +For other projects adopting the Adafruit Community Code of +Conduct, please contact the maintainers of those projects for enforcement. +If you wish to use this code of conduct for your own project, consider +explicitly mentioning your moderation policy or making a copy with your +own moderation policy so as to avoid confusion.