Merge pull request #80 from drak7/master

Doxyfied; Added code of conduct; Updated README; Added travis.yml
This commit is contained in:
Limor "Ladyada" Fried 2019-03-13 15:34:16 -04:00 committed by GitHub
commit 7d90723c5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 465 additions and 167 deletions

29
.travis.yml Normal file
View File

@ -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)

View File

@ -1,35 +1,56 @@
/*********************************** /**************************************************************************/
This is our GPS library /*!
@file Adafruit_GPS.cpp
Adafruit invests time and resources providing this open source code, @mainpage Adafruit Ultimate GPS Breakout
please support Adafruit and open-source hardware by purchasing
products from Adafruit! @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) #if defined(__AVR__) && defined(USE_SW_SERIAL)
// Only include software serial on AVR platforms (i.e. not on Due). // Only include software serial on AVR platforms (i.e. not on Due).
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#endif #endif
#include <Adafruit_GPS.h> #include <Adafruit_GPS.h>
// how long are max NMEA lines to parse? #define MAXLINELENGTH 120 ///< 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;
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) { boolean Adafruit_GPS::parse(char *nmea) {
// do checksum check // do checksum check
@ -37,8 +58,8 @@ boolean Adafruit_GPS::parse(char *nmea) {
if (nmea[strlen(nmea)-4] == '*') { if (nmea[strlen(nmea)-4] == '*') {
uint16_t sum = parseHex(nmea[strlen(nmea)-3]) * 16; uint16_t sum = parseHex(nmea[strlen(nmea)-3]) * 16;
sum += parseHex(nmea[strlen(nmea)-2]); sum += parseHex(nmea[strlen(nmea)-2]);
// check checksum // check checksum
for (uint8_t i=2; i < (strlen(nmea)-4); i++) { for (uint8_t i=2; i < (strlen(nmea)-4); i++) {
sum ^= nmea[i]; sum ^= nmea[i];
} }
@ -82,7 +103,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
latitudeDegrees = (latitude-100*int(latitude/100))/60.0; latitudeDegrees = (latitude-100*int(latitude/100))/60.0;
latitudeDegrees += int(latitude/100); latitudeDegrees += int(latitude/100);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
@ -92,7 +113,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
else if (p[0] == ',') lat = 0; else if (p[0] == ',') lat = 0;
else return false; else return false;
} }
// parse out longitude // parse out longitude
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
@ -111,7 +132,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
longitudeDegrees = (longitude-100*int(longitude/100))/60.0; longitudeDegrees = (longitude-100*int(longitude/100))/60.0;
longitudeDegrees += int(longitude/100); longitudeDegrees += int(longitude/100);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
@ -121,31 +142,31 @@ boolean Adafruit_GPS::parse(char *nmea) {
else if (p[0] == ',') lon = 0; else if (p[0] == ',') lon = 0;
else return false; else return false;
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
fixquality = atoi(p); fixquality = atoi(p);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
satellites = atoi(p); satellites = atoi(p);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
HDOP = atof(p); HDOP = atof(p);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
altitude = atof(p); altitude = atof(p);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
@ -170,7 +191,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
// Serial.println(p); // Serial.println(p);
if (p[0] == 'A') if (p[0] == 'A')
fix = true; fix = true;
else if (p[0] == 'V') else if (p[0] == 'V')
fix = false; fix = false;
@ -195,7 +216,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
latitudeDegrees = (latitude-100*int(latitude/100))/60.0; latitudeDegrees = (latitude-100*int(latitude/100))/60.0;
latitudeDegrees += int(latitude/100); latitudeDegrees += int(latitude/100);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
@ -205,7 +226,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
else if (p[0] == ',') lat = 0; else if (p[0] == ',') lat = 0;
else return false; else return false;
} }
// parse out longitude // parse out longitude
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
@ -224,7 +245,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
longitudeDegrees = (longitude-100*int(longitude/100))/60.0; longitudeDegrees = (longitude-100*int(longitude/100))/60.0;
longitudeDegrees += int(longitude/100); longitudeDegrees += int(longitude/100);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
@ -240,14 +261,14 @@ boolean Adafruit_GPS::parse(char *nmea) {
{ {
speed = atof(p); speed = atof(p);
} }
// angle // angle
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
angle = atof(p); angle = atof(p);
} }
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (',' != *p) if (',' != *p)
{ {
@ -263,16 +284,22 @@ boolean Adafruit_GPS::parse(char *nmea) {
return false; 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 Adafruit_GPS::read(void) {
char c = 0; char c = 0;
if (paused) return c; if (paused) return c;
#if defined(__AVR__) && defined(USE_SW_SERIAL) #if defined(__AVR__) && defined(USE_SW_SERIAL)
if(gpsSwSerial) { if(gpsSwSerial) {
if(!gpsSwSerial->available()) return c; if(!gpsSwSerial->available()) return c;
c = gpsSwSerial->read(); c = gpsSwSerial->read();
} else } else
#endif #endif
{ {
if(!gpsHwSerial->available()) return c; if(!gpsHwSerial->available()) return c;
@ -310,26 +337,40 @@ char Adafruit_GPS::read(void) {
return c; 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) #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) Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser)
#else #else
Adafruit_GPS::Adafruit_GPS(NewSoftSerial *ser) Adafruit_GPS::Adafruit_GPS(NewSoftSerial *ser)
#endif #endif
{ {
common_init(); // Set everything to common state, then... common_init(); // Set everything to common state, then...
gpsSwSerial = ser; // ...override gpsSwSerial with value passed. gpsSwSerial = ser; // ...override gpsSwSerial with value passed.
} }
#endif #endif
// Constructor when using HardwareSerial /**************************************************************************/
/*!
@brief Constructor when using HardwareSerial
@param ser Pointer to a HardwareSerial object
*/
/**************************************************************************/
Adafruit_GPS::Adafruit_GPS(HardwareSerial *ser) { Adafruit_GPS::Adafruit_GPS(HardwareSerial *ser) {
common_init(); // Set everything to common state, then... common_init(); // Set everything to common state, then...
gpsHwSerial = ser; // ...override gpsHwSerial with value passed. 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) { void Adafruit_GPS::common_init(void) {
#if defined(__AVR__) && defined(USE_SW_SERIAL) #if defined(__AVR__) && defined(USE_SW_SERIAL)
gpsSwSerial = NULL; // Set both to NULL, then override correct 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 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) void Adafruit_GPS::begin(uint32_t baud)
{ {
#if defined(__AVR__) && defined(USE_SW_SERIAL) #if defined(__AVR__) && defined(USE_SW_SERIAL)
if(gpsSwSerial) if(gpsSwSerial)
gpsSwSerial->begin(baud); gpsSwSerial->begin(baud);
else else
#endif #endif
gpsHwSerial->begin(baud); gpsHwSerial->begin(baud);
delay(10); 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) { void Adafruit_GPS::sendCommand(const char *str) {
#if defined(__AVR__) && defined(USE_SW_SERIAL) #if defined(__AVR__) && defined(USE_SW_SERIAL)
if(gpsSwSerial) if(gpsSwSerial)
gpsSwSerial->println(str); gpsSwSerial->println(str);
else else
#endif #endif
gpsHwSerial->println(str); 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) { boolean Adafruit_GPS::newNMEAreceived(void) {
return recvdflag; return recvdflag;
} }
/**************************************************************************/
/*!
@brief Pause/unpause receiving new data
@param p True = pause, false = unpause
*/
/**************************************************************************/
void Adafruit_GPS::pause(boolean p) { void Adafruit_GPS::pause(boolean p) {
paused = 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) { char *Adafruit_GPS::lastNMEA(void) {
recvdflag = false; recvdflag = false;
return (char *)lastline; 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 // read a Hex value and return the decimal equivalent
uint8_t Adafruit_GPS::parseHex(char c) { uint8_t Adafruit_GPS::parseHex(char c) {
if (c < '0') if (c < '0')
@ -398,6 +476,14 @@ uint8_t Adafruit_GPS::parseHex(char c) {
return 0; 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) { boolean Adafruit_GPS::waitForSentence(const char *wait4me, uint8_t max) {
char str[20]; char str[20];
@ -405,51 +491,69 @@ boolean Adafruit_GPS::waitForSentence(const char *wait4me, uint8_t max) {
while (i < max) { while (i < max) {
read(); read();
if (newNMEAreceived()) { if (newNMEAreceived()) {
char *nmea = lastNMEA(); char *nmea = lastNMEA();
strncpy(str, nmea, 20); strncpy(str, nmea, 20);
str[19] = 0; str[19] = 0;
i++; i++;
if (strstr(str, wait4me)) if (strstr(str, wait4me))
return true; return true;
} }
} }
return false; return false;
} }
/**************************************************************************/
/*!
@brief Start the LOCUS logger
@return True on success, false if it failed
*/
/**************************************************************************/
boolean Adafruit_GPS::LOCUS_StartLogger(void) { boolean Adafruit_GPS::LOCUS_StartLogger(void) {
sendCommand(PMTK_LOCUS_STARTLOG); sendCommand(PMTK_LOCUS_STARTLOG);
recvdflag = false; recvdflag = false;
return waitForSentence(PMTK_LOCUS_STARTSTOPACK); return waitForSentence(PMTK_LOCUS_STARTSTOPACK);
} }
/**************************************************************************/
/*!
@brief Stop the LOCUS logger
@return True on success, false if it failed
*/
/**************************************************************************/
boolean Adafruit_GPS::LOCUS_StopLogger(void) { boolean Adafruit_GPS::LOCUS_StopLogger(void) {
sendCommand(PMTK_LOCUS_STOPLOG); sendCommand(PMTK_LOCUS_STOPLOG);
recvdflag = false; recvdflag = false;
return waitForSentence(PMTK_LOCUS_STARTSTOPACK); 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) { boolean Adafruit_GPS::LOCUS_ReadStatus(void) {
sendCommand(PMTK_LOCUS_QUERY_STATUS); sendCommand(PMTK_LOCUS_QUERY_STATUS);
if (! waitForSentence("$PMTKLOG")) if (! waitForSentence("$PMTKLOG"))
return false; return false;
char *response = lastNMEA(); char *response = lastNMEA();
uint16_t parsed[10]; uint16_t parsed[10];
uint8_t i; uint8_t i;
for (i=0; i<10; i++) parsed[i] = -1; for (i=0; i<10; i++) parsed[i] = -1;
response = strchr(response, ','); response = strchr(response, ',');
for (i=0; i<10; i++) { for (i=0; i<10; i++) {
if (!response || (response[0] == 0) || (response[0] == '*')) if (!response || (response[0] == 0) || (response[0] == '*'))
break; break;
response++; response++;
parsed[i]=0; parsed[i]=0;
while ((response[0] != ',') && while ((response[0] != ',') &&
(response[0] != '*') && (response[0] != 0)) { (response[0] != '*') && (response[0] != 0)) {
parsed[i] *= 10; parsed[i] *= 10;
char c = response[0]; char c = response[0];
@ -463,7 +567,7 @@ boolean Adafruit_GPS::LOCUS_ReadStatus(void) {
LOCUS_serial = parsed[0]; LOCUS_serial = parsed[0];
LOCUS_type = parsed[1]; LOCUS_type = parsed[1];
if (isAlpha(parsed[2])) { if (isAlpha(parsed[2])) {
parsed[2] = parsed[2] - 'a' + 10; parsed[2] = parsed[2] - 'a' + 10;
} }
LOCUS_mode = parsed[2]; LOCUS_mode = parsed[2];
LOCUS_config = parsed[3]; LOCUS_config = parsed[3];
@ -477,7 +581,12 @@ boolean Adafruit_GPS::LOCUS_ReadStatus(void) {
return true; 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) { boolean Adafruit_GPS::standby(void) {
if (inStandbyMode) { if (inStandbyMode) {
return false; // Returns false if already in standby mode, so that you do not wake it up by sending commands to GPS 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) { boolean Adafruit_GPS::wakeup(void) {
if (inStandbyMode) { if (inStandbyMode) {
inStandbyMode = false; inStandbyMode = false;

View File

@ -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 This is the Adafruit GPS library - the ultimate GPS library
using MTK33x9 chipset for the ultimate GPS module!
------> http://www.adafruit.com/products/746
Pick one up today at the Adafruit electronics shop
and help support open source hardware & software! -ada
Adafruit invests time and resources providing this open source code, Tested and works great with the Adafruit Ultimate GPS module
please support Adafruit and open-source hardware by purchasing using MTK33x9 chipset
products from Adafruit! ------> 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. Adafruit invests time and resources providing this open source code,
BSD license, check license.txt for more information please support Adafruit and open-source hardware by purchasing
All text above must be included in any redistribution products from Adafruit!
****************************************/
// Fllybob added lines 34,35 and 40,41 to add 100mHz logging capability 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 #ifndef _ADAFRUIT_GPS_H
#define _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 ///< 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 defined(__AVR__) && defined(USE_SW_SERIAL)
#if ARDUINO >= 100 #if ARDUINO >= 100
@ -32,63 +36,58 @@ All text above must be included in any redistribution
#endif #endif
#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. Different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
#define PMTK_SET_NMEA_UPDATE_100_MILLIHERTZ "$PMTK220,10000*2F" // Once every 10 seconds, 100 millihertz. Note that these only control the rate at which the position is echoed, to actually speed up the
#define PMTK_SET_NMEA_UPDATE_200_MILLIHERTZ "$PMTK220,5000*1B" // Once every 5 seconds, 200 millihertz. position fix you must also send one of the position fix rate commands below too. */
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F" #define PMTK_SET_NMEA_UPDATE_100_MILLIHERTZ "$PMTK220,10000*2F" ///< Once every 10 seconds, 100 millihertz.
#define PMTK_SET_NMEA_UPDATE_2HZ "$PMTK220,500*2B" #define PMTK_SET_NMEA_UPDATE_200_MILLIHERTZ "$PMTK220,5000*1B" ///< Once every 5 seconds, 200 millihertz.
#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C" #define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F" ///< 1 Hz
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F" #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. // 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_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_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_1HZ "$PMTK300,1000,0,0,0,0*1C" ///< 1 Hz
#define PMTK_API_SET_FIX_CTL_5HZ "$PMTK300,200,0,0,0,0*2F" #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! // 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_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_BAUD_9600 "$PMTK251,9600*17" #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
// turn on only the second sentence (GPRMC) #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
#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"
// to generate your own sentences, check out the MTK command datasheet and use a checksum calculator // 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 // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
#define PMTK_LOCUS_STARTLOG "$PMTK185,0*22" #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22" ///< Start logging data
#define PMTK_LOCUS_STOPLOG "$PMTK185,1*23" #define PMTK_LOCUS_STOPLOG "$PMTK185,1*23" ///< Stop logging data
#define PMTK_LOCUS_STARTSTOPACK "$PMTK001,185,3*3C" #define PMTK_LOCUS_STARTSTOPACK "$PMTK001,185,3*3C" ///< Acknowledge the start or stop command
#define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38" #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38" ///< Query the logging status
#define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22" #define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22" ///< Erase the log flash data
#define LOCUS_OVERLAP 0 #define LOCUS_OVERLAP 0 ///< If flash is full, log will overwrite old data with new logs
#define LOCUS_FULLSTOP 1 #define LOCUS_FULLSTOP 1 ///< If flash is full, logging will stop
#define PMTK_ENABLE_SBAS "$PMTK313,1*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" #define PMTK_ENABLE_WAAS "$PMTK301,2*2E" ///< Use WAAS for DGPS correction data
// standby command & boot successful message #define PMTK_STANDBY "$PMTK161,0*28" ///< standby command & boot successful message
#define PMTK_STANDBY "$PMTK161,0*28" #define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" ///< Not needed currently
#define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently #define PMTK_AWAKE "$PMTK010,002*2D" ///< Wake up
#define PMTK_AWAKE "$PMTK010,002*2D"
// ask for the release and version #define PMTK_Q_RELEASE "$PMTK605*31" ///< ask for the release and version
#define PMTK_Q_RELEASE "$PMTK605*31"
// 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 PGCMD_ANTENNA "$PGCMD,33,1*6C" ///< request for updates on antenna status
#define MAXWAITSENTENCE 10 #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 #if ARDUINO >= 100
#include "Arduino.h" #include "Arduino.h"
@ -100,13 +99,16 @@ All text above must be included in any redistribution
#include "NewSoftSerial.h" #include "NewSoftSerial.h"
#endif #endif
/**************************************************************************/
/*!
@brief The GPS class
*/
class Adafruit_GPS { class Adafruit_GPS {
public: public:
void begin(uint32_t baud); void begin(uint32_t baud);
#if defined(__AVR__) && defined(USE_SW_SERIAL) #if defined(__AVR__) && defined(USE_SW_SERIAL)
#if ARDUINO >= 100 #if ARDUINO >= 100
Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial
#else #else
Adafruit_GPS(NewSoftSerial *ser); // Constructor when using NewSoftSerial Adafruit_GPS(NewSoftSerial *ser); // Constructor when using NewSoftSerial
@ -119,10 +121,9 @@ class Adafruit_GPS {
void common_init(void); void common_init(void);
void sendCommand(const char *); void sendCommand(const char *);
void pause(boolean b); void pause(boolean b);
boolean parseNMEA(char *response);
uint8_t parseHex(char c); uint8_t parseHex(char c);
char read(void); char read(void);
@ -131,31 +132,57 @@ class Adafruit_GPS {
boolean wakeup(void); boolean wakeup(void);
boolean standby(void); boolean standby(void);
uint8_t hour, minute, seconds, year, month, day; uint8_t hour; ///< GMT hours
uint16_t milliseconds; uint8_t minute; ///< GMT minutes
// Floating point latitude and longitude value in degrees. uint8_t seconds; ///< GMT seconds
float latitude, longitude; uint16_t milliseconds; ///< GMT milliseconds
// Fixed point latitude and longitude value with degrees stored in units of 1/100000 degrees, uint8_t year; ///< GMT year
// and minutes stored in units of 1/100000 degrees. See pull #13 for more details: uint8_t month; ///< GMT month
// https://github.com/adafruit/Adafruit-GPS-Library/pull/13 uint8_t day; ///< GMT day
int32_t latitude_fixed, longitude_fixed;
float latitudeDegrees, longitudeDegrees; float latitude; ///< Floating point latitude value in degrees/minutes as received from the GPS (DDMM.MMMM)
float geoidheight, altitude; float longitude; ///< Floating point longitude value in degrees/minutes as received from the GPS (DDDMM.MMMM)
float speed, angle, magvariation, HDOP;
char lat, lon, mag; /** Fixed point latitude and longitude value with degrees stored in units of 1/100000 degrees,
boolean fix; and minutes stored in units of 1/100000 degrees. See pull #13 for more details:
uint8_t fixquality, satellites; 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 waitForSentence(const char *wait, uint8_t max = MAXWAITSENTENCE);
boolean LOCUS_StartLogger(void); boolean LOCUS_StartLogger(void);
boolean LOCUS_StopLogger(void); boolean LOCUS_StopLogger(void);
boolean LOCUS_ReadStatus(void); boolean LOCUS_ReadStatus(void);
uint16_t LOCUS_serial, LOCUS_records; uint16_t LOCUS_serial; ///< Log serial number
uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent; 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: private:
boolean paused; boolean paused;
uint8_t parseResponse(char *response); uint8_t parseResponse(char *response);
#if defined(__AVR__) && defined(USE_SW_SERIAL) #if defined(__AVR__) && defined(USE_SW_SERIAL)
#if ARDUINO >= 100 #if ARDUINO >= 100
@ -166,6 +193,6 @@ class Adafruit_GPS {
#endif #endif
HardwareSerial *gpsHwSerial; HardwareSerial *gpsHwSerial;
}; };
/**************************************************************************/
#endif #endif

21
README.md Normal file
View File

@ -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.

View File

@ -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 <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.

127
code-of-conduct.md Normal file
View File

@ -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 dont 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 <support@adafruit.com>.
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 communitys 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
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
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.