Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 169 lines (136 sloc) 5.761 kb
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
1 /***********************************
2488eb4 @ladyada fixed readme
ladyada authored
2 This is the Adafruit GPS library - the ultimate GPS library
3 for the ultimate GPS module!
4
5 Tested and works great with the Adafruit Ultimate GPS module
6 using MTK33x9 chipset
7 ------> http://www.adafruit.com/products/746
8 Pick one up today at the Adafruit electronics shop
9 and help support open source hardware & software! -ada
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
10
11 Adafruit invests time and resources providing this open source code,
12 please support Adafruit and open-source hardware by purchasing
13 products from Adafruit!
14
15 Written by Limor Fried/Ladyada for Adafruit Industries.
16 BSD license, check license.txt for more information
17 All text above must be included in any redistribution
18 ****************************************/
1a8a9f4 Update Adafruit_GPS.h
Fltbob authored
19 // Fllybob added lines 34,35 and 40,41 to add 100mHz logging capability
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
20
21 #ifndef _ADAFRUIT_GPS_H
22 #define _ADAFRUIT_GPS_H
23
2d220aa @driverblock Due support
driverblock authored
24 #ifdef __AVR__
25 #if ARDUINO >= 100
26 #include <SoftwareSerial.h>
27 #else
28 #include <NewSoftSerial.h>
29 #endif
9dce498 add header includes
lady ada authored
30 #endif
31
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
32 // different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
11cb409 @tdicola Fix #22 by adding 1hz and 5hz position fix update commands. Update echo...
tdicola authored
33 // Note that these only control the rate at which the position is echoed, to actually speed up the
34 // position fix you must also send one of the position fix rate commands below too.
43b9093 @tdicola Update Adafruit_GPS.h
tdicola authored
35 #define PMTK_SET_NMEA_UPDATE_100_MILLIHERTZ "$PMTK220,10000*2F" // Once every 10 seconds, 100 millihertz.
0465ef1 @Max13 Adde PMTK updates for 5 times/seconds
Max13 authored
36 #define PMTK_SET_NMEA_UPDATE_200_MILLIHERTZ "$PMTK220,5000*1B" // Once every 5 seconds, 200 millihertz.
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
37 #define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
38 #define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
39 #define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
11cb409 @tdicola Fix #22 by adding 1hz and 5hz position fix update commands. Update echo...
tdicola authored
40 // Position fix update rate commands.
43b9093 @tdicola Update Adafruit_GPS.h
tdicola authored
41 #define PMTK_API_SET_FIX_CTL_100_MILLIHERTZ "$PMTK300,10000,0,0,0,0*2C" // Once every 10 seconds, 100 millihertz.
0465ef1 @Max13 Adde PMTK updates for 5 times/seconds
Max13 authored
42 #define PMTK_API_SET_FIX_CTL_200_MILLIHERTZ "$PMTK300,5000,0,0,0,0*18" // Once every 5 seconds, 200 millihertz.
11cb409 @tdicola Fix #22 by adding 1hz and 5hz position fix update commands. Update echo...
tdicola authored
43 #define PMTK_API_SET_FIX_CTL_1HZ "$PMTK300,1000,0,0,0,0*1C"
44 #define PMTK_API_SET_FIX_CTL_5HZ "$PMTK300,200,0,0,0,0*2F"
45 // Can't fix position faster than 5 times a second!
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
46
319531f @ladyada added locus erase example
ladyada authored
47
3955abd @eckyecky Correct SET_BAUD's
eckyecky authored
48 #define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C"
49 #define PMTK_SET_BAUD_9600 "$PMTK251,9600*17"
319531f @ladyada added locus erase example
ladyada authored
50
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
51 // turn on only the second sentence (GPRMC)
52 #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"
53 // turn on GPRMC and GGA
54 #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"
55 // turn on ALL THE DATA
56 #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"
47b173d @ladyada added logging dump sketch
ladyada authored
57 // turn off output
58 #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"
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
59
60 // to generate your own sentences, check out the MTK command datasheet and use a checksum calculator
61 // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
62
723d26d @ladyada parsing LOCUS status
ladyada authored
63 #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
f4dba8e @djix123 Add support for stopping logging
djix123 authored
64 #define PMTK_LOCUS_STOPLOG "$PMTK185,1*23"
65 #define PMTK_LOCUS_STARTSTOPACK "$PMTK001,185,3*3C"
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
66 #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
319531f @ladyada added locus erase example
ladyada authored
67 #define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
723d26d @ladyada parsing LOCUS status
ladyada authored
68 #define LOCUS_OVERLAP 0
69 #define LOCUS_FULLSTOP 1
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
70
7a3956f @koehn Made lat/long int32_t instead of floats for performance and precision
koehn authored
71 #define PMTK_ENABLE_SBAS "$PMTK313,1*2E"
72 #define PMTK_ENABLE_WAAS "$PMTK301,2*2E"
73
bd05ebf @ladyada sleepy messages
ladyada authored
74 // standby command & boot successful message
75 #define PMTK_STANDBY "$PMTK161,0*28"
dbef3e9 @jrcutler Typo fix
jrcutler authored
76 #define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently
bd05ebf @ladyada sleepy messages
ladyada authored
77 #define PMTK_AWAKE "$PMTK010,002*2D"
78
2c95414 @ladyada Now with firmware version report query
ladyada authored
79 // ask for the release and version
80 #define PMTK_Q_RELEASE "$PMTK605*31"
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
81
c9adf10 @ladyada add antenna request status command name
ladyada authored
82 // request for updates on antenna status
83 #define PGCMD_ANTENNA "$PGCMD,33,1*6C"
6a51743 @orpheus88 Update Adafruit_GPS.h
orpheus88 authored
84 #define PGCMD_NOANTENNA "$PGCMD,33,0*6D"
c9adf10 @ladyada add antenna request status command name
ladyada authored
85
723d26d @ladyada parsing LOCUS status
ladyada authored
86 // how long to wait when we're looking for a response
87 #define MAXWAITSENTENCE 5
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
88
89 #if ARDUINO >= 100
90 #include "Arduino.h"
2d220aa @driverblock Due support
driverblock authored
91 #if defined (__AVR__) && !defined(__AVR_ATmega32U4__)
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
92 #include "SoftwareSerial.h"
9dce498 add header includes
lady ada authored
93 #endif
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
94 #else
95 #include "WProgram.h"
96 #include "NewSoftSerial.h"
97 #endif
98
99
100 class Adafruit_GPS {
101 public:
b8ce3c6 @ladyada Parsing works with RMC & GGA with a nice example as well
ladyada authored
102 void begin(uint16_t baud);
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
103
2d220aa @driverblock Due support
driverblock authored
104 #ifdef __AVR__
105 #if ARDUINO >= 100
106 Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial
107 #else
108 Adafruit_GPS(NewSoftSerial *ser); // Constructor when using NewSoftSerial
109 #endif
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
110 #endif
b8ce3c6 @ladyada Parsing works with RMC & GGA with a nice example as well
ladyada authored
111 Adafruit_GPS(HardwareSerial *ser); // Constructor when using HardwareSerial
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
112
113 char *lastNMEA(void);
114 boolean newNMEAreceived();
115 void common_init(void);
91d1657 @MrMoose use const char ptr instead of non-const in string literal parameters
MrMoose authored
116
117 void sendCommand(const char *);
118
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
119 void pause(boolean b);
120
121 boolean parseNMEA(char *response);
122 uint8_t parseHex(char c);
123
b8ce3c6 @ladyada Parsing works with RMC & GGA with a nice example as well
ladyada authored
124 char read(void);
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
125 boolean parse(char *);
126 void interruptReads(boolean r);
127
bd05ebf @ladyada sleepy messages
ladyada authored
128 boolean wakeup(void);
2d220aa @driverblock Due support
driverblock authored
129 boolean standby(void);
bd05ebf @ladyada sleepy messages
ladyada authored
130
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
131 uint8_t hour, minute, seconds, year, month, day;
132 uint16_t milliseconds;
5523d30 @tdicola Move fixed point value to latitude_fixed and longitude_fixed members.
tdicola authored
133 // Floating point latitude and longitude value in degrees.
134 float latitude, longitude;
240f1bb @tdicola Add fixed point minute scaling back with correct floating point conversi...
tdicola authored
135 // Fixed point latitude and longitude value with degrees stored in units of 1/100000 degrees,
136 // and minutes stored in units of 1/100000 degrees. See pull #13 for more details:
137 // https://github.com/adafruit/Adafruit-GPS-Library/pull/13
5523d30 @tdicola Move fixed point value to latitude_fixed and longitude_fixed members.
tdicola authored
138 int32_t latitude_fixed, longitude_fixed;
3f4a1a5 @Jcps Addition of Google Maps friendly coordinates
Jcps authored
139 float latitudeDegrees, longitudeDegrees;
7a3956f @koehn Made lat/long int32_t instead of floats for performance and precision
koehn authored
140 float geoidheight, altitude;
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
141 float speed, angle, magvariation, HDOP;
142 char lat, lon, mag;
143 boolean fix;
144 uint8_t fixquality, satellites;
145
c85ca30 @plattrap Fix warning about deprecated cast from string to char *.
plattrap authored
146 boolean waitForSentence(const char *wait, uint8_t max = MAXWAITSENTENCE);
723d26d @ladyada parsing LOCUS status
ladyada authored
147 boolean LOCUS_StartLogger(void);
f4dba8e @djix123 Add support for stopping logging
djix123 authored
148 boolean LOCUS_StopLogger(void);
723d26d @ladyada parsing LOCUS status
ladyada authored
149 boolean LOCUS_ReadStatus(void);
150
151 uint16_t LOCUS_serial, LOCUS_records;
152 uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent;
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
153 private:
154 boolean paused;
155
156 uint8_t parseResponse(char *response);
2d220aa @driverblock Due support
driverblock authored
157 #ifdef __AVR__
158 #if ARDUINO >= 100
159 SoftwareSerial *gpsSwSerial;
160 #else
161 NewSoftSerial *gpsSwSerial;
162 #endif
b05daca @ladyada Have to test parsing, but seems OK
ladyada authored
163 #endif
164 HardwareSerial *gpsHwSerial;
165 };
166
167
168 #endif
Something went wrong with that request. Please try again.