Merge branch 'master' of https://github.com/koehn/Adafruit-GPS-Library into koehn-master

This commit is contained in:
Tony DiCola 2014-08-07 01:16:23 -07:00
commit 32e40234c8
2 changed files with 47 additions and 7 deletions

View File

@ -9,7 +9,7 @@ Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information BSD license, check license.txt for more information
All text above must be included in any redistribution All text above must be included in any redistribution
****************************************/ ****************************************/
#include <SoftwareSerial.h>
#include <Adafruit_GPS.h> #include <Adafruit_GPS.h>
// how long are max NMEA lines to parse? // how long are max NMEA lines to parse?
@ -44,7 +44,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
//return false; //return false;
} }
} }
char degreebuff[10];
// look for a few common sentences // look for a few common sentences
if (strstr(nmea, "$GPGGA")) { if (strstr(nmea, "$GPGGA")) {
// found GGA // found GGA
@ -61,7 +61,16 @@ boolean Adafruit_GPS::parse(char *nmea) {
// parse out latitude // parse out latitude
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
latitude = atof(p); strncpy(degreebuff, p, 2);
p += 2;
degreebuff[2] = '\0';
int32_t degree = atol(degreebuff) * 10000000;
strncpy(degreebuff, p, 2); // minutes
p += 3; // skip decimal point
strncpy(degreebuff + 2, p, 4);
degreebuff[6] = '\0';
long minutes = 50 * atol(degreebuff) / 3;
latitude = degree + minutes;
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (p[0] == 'N') lat = 'N'; if (p[0] == 'N') lat = 'N';
@ -71,7 +80,16 @@ boolean Adafruit_GPS::parse(char *nmea) {
// parse out longitude // parse out longitude
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
longitude = atof(p); strncpy(degreebuff, p, 3);
p += 3;
degreebuff[3] = '\0';
degree = atol(degreebuff) * 10000000;
strncpy(degreebuff, p, 2); // minutes
p += 3; // skip decimal point
strncpy(degreebuff + 2, p, 4);
degreebuff[6] = '\0';
minutes = 50 * atol(degreebuff) / 3;
longitude = degree + minutes;
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (p[0] == 'W') lon = 'W'; if (p[0] == 'W') lon = 'W';
@ -120,7 +138,16 @@ boolean Adafruit_GPS::parse(char *nmea) {
// parse out latitude // parse out latitude
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
latitude = atof(p); strncpy(degreebuff, p, 2);
p += 2;
degreebuff[2] = '\0';
long degree = atol(degreebuff) * 10000000;
strncpy(degreebuff, p, 2); // minutes
p += 3; // skip decimal point
strncpy(degreebuff + 2, p, 4);
degreebuff[6] = '\0';
long minutes = 50 * atol(degreebuff) / 3;
latitude = degree + minutes;
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (p[0] == 'N') lat = 'N'; if (p[0] == 'N') lat = 'N';
@ -130,7 +157,16 @@ boolean Adafruit_GPS::parse(char *nmea) {
// parse out longitude // parse out longitude
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
longitude = atof(p); strncpy(degreebuff, p, 3);
p += 3;
degreebuff[3] = '\0';
degree = atol(degreebuff) * 10000000;
strncpy(degreebuff, p, 2); // minutes
p += 3; // skip decimal point
strncpy(degreebuff + 2, p, 4);
degreebuff[6] = '\0';
minutes = 50 * atol(degreebuff) / 3;
longitude = degree + minutes;
p = strchr(p, ',')+1; p = strchr(p, ',')+1;
if (p[0] == 'W') lon = 'W'; if (p[0] == 'W') lon = 'W';

View File

@ -57,6 +57,9 @@ All text above must be included in any redistribution
#define LOCUS_OVERLAP 0 #define LOCUS_OVERLAP 0
#define LOCUS_FULLSTOP 1 #define LOCUS_FULLSTOP 1
#define PMTK_ENABLE_SBAS "$PMTK313,1*2E"
#define PMTK_ENABLE_WAAS "$PMTK301,2*2E"
// standby command & boot successful message // standby command & boot successful message
#define PMTK_STANDBY "$PMTK161,0*28" #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
@ -116,7 +119,8 @@ class Adafruit_GPS {
uint8_t hour, minute, seconds, year, month, day; uint8_t hour, minute, seconds, year, month, day;
uint16_t milliseconds; uint16_t milliseconds;
float latitude, longitude, geoidheight, altitude; int32_t latitude, longitude;
float geoidheight, altitude;
float speed, angle, magvariation, HDOP; float speed, angle, magvariation, HDOP;
char lat, lon, mag; char lat, lon, mag;
boolean fix; boolean fix;