2012-03-27 22:56:07 +01:00
|
|
|
/***********************************
|
2012-03-28 17:23:26 +01:00
|
|
|
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
|
|
|
|
|
Pick one up today at the Adafruit electronics shop
|
|
|
|
|
and help support open source hardware & software! -ada
|
2012-03-27 22:56:07 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
****************************************/
|
2014-08-11 17:13:21 +01:00
|
|
|
// Fllybob added lines 34,35 and 40,41 to add 100mHz logging capability
|
2012-03-27 22:56:07 +01:00
|
|
|
|
|
|
|
|
#ifndef _ADAFRUIT_GPS_H
|
|
|
|
|
#define _ADAFRUIT_GPS_H
|
|
|
|
|
|
2016-09-25 15:26:05 +01:00
|
|
|
//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)
|
2014-06-08 20:46:05 +01:00
|
|
|
#if ARDUINO >= 100
|
|
|
|
|
#include <SoftwareSerial.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <NewSoftSerial.h>
|
|
|
|
|
#endif
|
2012-11-03 23:27:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
2012-03-27 22:56:07 +01:00
|
|
|
// different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
|
2014-08-07 20:00:36 +01:00
|
|
|
// 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.
|
2014-08-18 19:09:55 +01:00
|
|
|
#define PMTK_SET_NMEA_UPDATE_100_MILLIHERTZ "$PMTK220,10000*2F" // Once every 10 seconds, 100 millihertz.
|
2014-12-25 14:48:57 +00:00
|
|
|
#define PMTK_SET_NMEA_UPDATE_200_MILLIHERTZ "$PMTK220,5000*1B" // Once every 5 seconds, 200 millihertz.
|
2012-03-27 22:56:07 +01:00
|
|
|
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
|
2017-08-02 03:55:52 +01:00
|
|
|
#define PMTK_SET_NMEA_UPDATE_2HZ "$PMTK220,500*2B"
|
2012-03-27 22:56:07 +01:00
|
|
|
#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
|
|
|
|
|
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
|
2014-08-07 20:00:36 +01:00
|
|
|
// Position fix update rate commands.
|
2014-08-18 19:09:55 +01:00
|
|
|
#define PMTK_API_SET_FIX_CTL_100_MILLIHERTZ "$PMTK300,10000,0,0,0,0*2C" // Once every 10 seconds, 100 millihertz.
|
2014-12-25 14:48:57 +00:00
|
|
|
#define PMTK_API_SET_FIX_CTL_200_MILLIHERTZ "$PMTK300,5000,0,0,0,0*18" // Once every 5 seconds, 200 millihertz.
|
2014-08-07 20:00:36 +01:00
|
|
|
#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"
|
|
|
|
|
// Can't fix position faster than 5 times a second!
|
2012-03-27 22:56:07 +01:00
|
|
|
|
2012-09-08 01:25:48 +01:00
|
|
|
|
2012-10-17 10:32:37 +01:00
|
|
|
#define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C"
|
|
|
|
|
#define PMTK_SET_BAUD_9600 "$PMTK251,9600*17"
|
2012-09-08 01:25:48 +01:00
|
|
|
|
2012-03-27 22:56:07 +01:00
|
|
|
// 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"
|
2012-04-17 16:42:20 +01:00
|
|
|
// 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"
|
2012-03-27 22:56:07 +01:00
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
2012-03-28 19:14:32 +01:00
|
|
|
#define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
|
2013-10-27 16:15:00 +00:00
|
|
|
#define PMTK_LOCUS_STOPLOG "$PMTK185,1*23"
|
|
|
|
|
#define PMTK_LOCUS_STARTSTOPACK "$PMTK001,185,3*3C"
|
2012-03-27 22:56:07 +01:00
|
|
|
#define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
|
2012-09-08 01:25:48 +01:00
|
|
|
#define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
|
2012-03-28 19:14:32 +01:00
|
|
|
#define LOCUS_OVERLAP 0
|
|
|
|
|
#define LOCUS_FULLSTOP 1
|
2012-03-27 22:56:07 +01:00
|
|
|
|
2013-02-26 02:59:43 +00:00
|
|
|
#define PMTK_ENABLE_SBAS "$PMTK313,1*2E"
|
|
|
|
|
#define PMTK_ENABLE_WAAS "$PMTK301,2*2E"
|
|
|
|
|
|
2012-11-09 17:01:23 +00:00
|
|
|
// standby command & boot successful message
|
|
|
|
|
#define PMTK_STANDBY "$PMTK161,0*28"
|
2013-07-21 02:45:03 +01:00
|
|
|
#define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently
|
2012-11-09 17:01:23 +00:00
|
|
|
#define PMTK_AWAKE "$PMTK010,002*2D"
|
|
|
|
|
|
2012-06-12 16:09:02 +01:00
|
|
|
// ask for the release and version
|
|
|
|
|
#define PMTK_Q_RELEASE "$PMTK605*31"
|
2012-03-27 22:56:07 +01:00
|
|
|
|
2013-02-13 18:35:19 +00:00
|
|
|
// request for updates on antenna status
|
|
|
|
|
#define PGCMD_ANTENNA "$PGCMD,33,1*6C"
|
2014-06-20 14:30:38 +01:00
|
|
|
#define PGCMD_NOANTENNA "$PGCMD,33,0*6D"
|
2013-02-13 18:35:19 +00:00
|
|
|
|
2012-03-28 19:14:32 +01:00
|
|
|
// how long to wait when we're looking for a response
|
2017-08-02 16:24:18 +01:00
|
|
|
#define MAXWAITSENTENCE 10
|
2012-03-27 22:56:07 +01:00
|
|
|
|
|
|
|
|
#if ARDUINO >= 100
|
|
|
|
|
#include "Arduino.h"
|
2014-06-08 20:46:05 +01:00
|
|
|
#if defined (__AVR__) && !defined(__AVR_ATmega32U4__)
|
2012-03-27 22:56:07 +01:00
|
|
|
#include "SoftwareSerial.h"
|
2012-11-03 23:27:41 +00:00
|
|
|
#endif
|
2012-03-27 22:56:07 +01:00
|
|
|
#else
|
|
|
|
|
#include "WProgram.h"
|
|
|
|
|
#include "NewSoftSerial.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Adafruit_GPS {
|
|
|
|
|
public:
|
2016-07-12 04:36:54 +01:00
|
|
|
void begin(uint32_t baud);
|
2012-03-27 22:56:07 +01:00
|
|
|
|
2016-09-25 15:26:05 +01:00
|
|
|
#if defined(__AVR__) && defined(USE_SW_SERIAL)
|
2014-06-08 20:46:05 +01:00
|
|
|
#if ARDUINO >= 100
|
|
|
|
|
Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial
|
|
|
|
|
#else
|
|
|
|
|
Adafruit_GPS(NewSoftSerial *ser); // Constructor when using NewSoftSerial
|
|
|
|
|
#endif
|
2012-03-27 22:56:07 +01:00
|
|
|
#endif
|
2012-03-28 17:20:38 +01:00
|
|
|
Adafruit_GPS(HardwareSerial *ser); // Constructor when using HardwareSerial
|
2012-03-27 22:56:07 +01:00
|
|
|
|
|
|
|
|
char *lastNMEA(void);
|
|
|
|
|
boolean newNMEAreceived();
|
|
|
|
|
void common_init(void);
|
2013-06-02 13:44:40 +01:00
|
|
|
|
|
|
|
|
void sendCommand(const char *);
|
|
|
|
|
|
2012-03-27 22:56:07 +01:00
|
|
|
void pause(boolean b);
|
|
|
|
|
|
|
|
|
|
boolean parseNMEA(char *response);
|
|
|
|
|
uint8_t parseHex(char c);
|
|
|
|
|
|
2012-03-28 17:20:38 +01:00
|
|
|
char read(void);
|
2012-03-27 22:56:07 +01:00
|
|
|
boolean parse(char *);
|
|
|
|
|
|
2012-11-09 17:01:23 +00:00
|
|
|
boolean wakeup(void);
|
2014-06-08 20:46:05 +01:00
|
|
|
boolean standby(void);
|
2012-11-09 17:01:23 +00:00
|
|
|
|
2012-03-27 22:56:07 +01:00
|
|
|
uint8_t hour, minute, seconds, year, month, day;
|
|
|
|
|
uint16_t milliseconds;
|
2014-08-07 10:04:24 +01:00
|
|
|
// Floating point latitude and longitude value in degrees.
|
|
|
|
|
float latitude, longitude;
|
2014-08-11 19:01:50 +01:00
|
|
|
// 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
|
2014-08-07 10:04:24 +01:00
|
|
|
int32_t latitude_fixed, longitude_fixed;
|
2014-10-16 15:44:05 +01:00
|
|
|
float latitudeDegrees, longitudeDegrees;
|
2013-02-26 02:59:43 +00:00
|
|
|
float geoidheight, altitude;
|
2012-03-27 22:56:07 +01:00
|
|
|
float speed, angle, magvariation, HDOP;
|
|
|
|
|
char lat, lon, mag;
|
|
|
|
|
boolean fix;
|
|
|
|
|
uint8_t fixquality, satellites;
|
|
|
|
|
|
2014-10-18 23:31:07 +01:00
|
|
|
boolean waitForSentence(const char *wait, uint8_t max = MAXWAITSENTENCE);
|
2012-03-28 19:14:32 +01:00
|
|
|
boolean LOCUS_StartLogger(void);
|
2013-10-27 16:15:00 +00:00
|
|
|
boolean LOCUS_StopLogger(void);
|
2012-03-28 19:14:32 +01:00
|
|
|
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;
|
2012-03-27 22:56:07 +01:00
|
|
|
private:
|
|
|
|
|
boolean paused;
|
|
|
|
|
|
|
|
|
|
uint8_t parseResponse(char *response);
|
2016-09-25 15:26:05 +01:00
|
|
|
#if defined(__AVR__) && defined(USE_SW_SERIAL)
|
2014-06-08 20:46:05 +01:00
|
|
|
#if ARDUINO >= 100
|
|
|
|
|
SoftwareSerial *gpsSwSerial;
|
|
|
|
|
#else
|
|
|
|
|
NewSoftSerial *gpsSwSerial;
|
|
|
|
|
#endif
|
2012-03-27 22:56:07 +01:00
|
|
|
#endif
|
|
|
|
|
HardwareSerial *gpsHwSerial;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|