parent
c68499182d
commit
efa9bfd857
|
|
@ -64,7 +64,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
||||||
// check checksum
|
// check checksum
|
||||||
char *p = strchr(nmea,'$');
|
char *p = strchr(nmea,'$');
|
||||||
if(p == NULL) return false;
|
if(p == NULL) return false;
|
||||||
else{
|
else{
|
||||||
for (char *p1 = p+1; p1 < ast; p1++) {
|
for (char *p1 = p+1; p1 < ast; p1++) {
|
||||||
sum ^= *p1;
|
sum ^= *p1;
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +78,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
||||||
}
|
}
|
||||||
// look for a few common sentences
|
// look for a few common sentences
|
||||||
char *p = nmea;
|
char *p = nmea;
|
||||||
|
|
||||||
if (strStartsWith(nmea, "$GPGGA")) {
|
if (strStartsWith(nmea, "$GPGGA")) {
|
||||||
// found GGA
|
// found GGA
|
||||||
// get time
|
// get time
|
||||||
|
|
@ -96,13 +96,13 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
||||||
parseLon(p);
|
parseLon(p);
|
||||||
p = strchr(p, ',')+1;
|
p = strchr(p, ',')+1;
|
||||||
if(!parseLonDir(p)) return false;
|
if(!parseLonDir(p)) return false;
|
||||||
|
|
||||||
p = strchr(p, ',')+1;
|
p = strchr(p, ',')+1;
|
||||||
if (',' != *p)
|
if (',' != *p)
|
||||||
{
|
{
|
||||||
fixquality = atoi(p);
|
fixquality = atoi(p);
|
||||||
if(fixquality > 0){
|
if(fixquality > 0){
|
||||||
fix = true;
|
fix = true;
|
||||||
lastFix = recvdTime;
|
lastFix = recvdTime;
|
||||||
} else
|
} else
|
||||||
fix = false;
|
fix = false;
|
||||||
|
|
@ -134,7 +134,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strStartsWith(nmea, "$GPRMC")) {
|
if (strStartsWith(nmea, "$GPRMC")) {
|
||||||
// found RMC
|
// found RMC
|
||||||
// get time
|
// get time
|
||||||
|
|
@ -182,7 +182,7 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strStartsWith(nmea, "$GPGLL")) {
|
if (strStartsWith(nmea, "$GPGLL")) {
|
||||||
// found GLL
|
// found GLL
|
||||||
// parse out latitude
|
// parse out latitude
|
||||||
|
|
@ -220,13 +220,13 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
void Adafruit_GPS::parseTime(char *p) {
|
void Adafruit_GPS::parseTime(char *p) {
|
||||||
// get time
|
// get time
|
||||||
float timef = atof(p);
|
uint32_t time = atol(p);
|
||||||
uint32_t time = timef;
|
|
||||||
hour = time / 10000;
|
hour = time / 10000;
|
||||||
minute = (time % 10000) / 100;
|
minute = (time % 10000) / 100;
|
||||||
seconds = (time % 100);
|
seconds = (time % 100);
|
||||||
|
|
||||||
milliseconds = fmod(timef, 1.0) * 1000;
|
p = strchr(p, '.')+1;
|
||||||
|
milliseconds = atoi(p);
|
||||||
lastTime = recvdTime;
|
lastTime = recvdTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,7 +345,7 @@ boolean Adafruit_GPS::parseFix(char *p) {
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Time in seconds since the last position fix was obtained. Will
|
@brief Time in seconds since the last position fix was obtained. Will
|
||||||
fail by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
|
fail by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
|
||||||
@return float value in seconds since last fix.
|
@return float value in seconds since last fix.
|
||||||
*/
|
*/
|
||||||
|
|
@ -356,7 +356,7 @@ float Adafruit_GPS::secondsSinceFix() {
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Time in seconds since the last GPS time was obtained. Will fail
|
@brief Time in seconds since the last GPS time was obtained. Will fail
|
||||||
by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
|
by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
|
||||||
@return float value in seconds since last GPS time.
|
@return float value in seconds since last GPS time.
|
||||||
*/
|
*/
|
||||||
|
|
@ -367,7 +367,7 @@ float Adafruit_GPS::secondsSinceTime() {
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Time in seconds since the last GPS date was obtained. Will fail
|
@brief Time in seconds since the last GPS date was obtained. Will fail
|
||||||
by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
|
by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
|
||||||
@return float value in seconds since last GPS date.
|
@return float value in seconds since last GPS date.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -83,9 +83,17 @@ void loop() // run over and over again
|
||||||
if (millis() - timer > 2000) {
|
if (millis() - timer > 2000) {
|
||||||
timer = millis(); // reset the timer
|
timer = millis(); // reset the timer
|
||||||
Serial.print("\nTime: ");
|
Serial.print("\nTime: ");
|
||||||
|
if (GPS.hour < 10) { Serial.print('0'); }
|
||||||
Serial.print(GPS.hour, DEC); Serial.print(':');
|
Serial.print(GPS.hour, DEC); Serial.print(':');
|
||||||
|
if (GPS.minute < 10) { Serial.print('0'); }
|
||||||
Serial.print(GPS.minute, DEC); Serial.print(':');
|
Serial.print(GPS.minute, DEC); Serial.print(':');
|
||||||
|
if (GPS.seconds < 10) { Serial.print('0'); }
|
||||||
Serial.print(GPS.seconds, DEC); Serial.print('.');
|
Serial.print(GPS.seconds, DEC); Serial.print('.');
|
||||||
|
if (GPS.milliseconds < 10) {
|
||||||
|
Serial.print("00");
|
||||||
|
} else if (GPS.milliseconds > 9 && GPS.milliseconds < 100) {
|
||||||
|
Serial.print("0");
|
||||||
|
}
|
||||||
Serial.println(GPS.milliseconds);
|
Serial.println(GPS.milliseconds);
|
||||||
Serial.print("Date: ");
|
Serial.print("Date: ");
|
||||||
Serial.print(GPS.day, DEC); Serial.print('/');
|
Serial.print(GPS.day, DEC); Serial.print('/');
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,17 @@ void loop() // run over and over again
|
||||||
timer = millis(); // reset the timer
|
timer = millis(); // reset the timer
|
||||||
|
|
||||||
Serial.print("\nTime: ");
|
Serial.print("\nTime: ");
|
||||||
|
if (GPS.hour < 10) { Serial.print('0'); }
|
||||||
Serial.print(GPS.hour, DEC); Serial.print(':');
|
Serial.print(GPS.hour, DEC); Serial.print(':');
|
||||||
|
if (GPS.minute < 10) { Serial.print('0'); }
|
||||||
Serial.print(GPS.minute, DEC); Serial.print(':');
|
Serial.print(GPS.minute, DEC); Serial.print(':');
|
||||||
|
if (GPS.seconds < 10) { Serial.print('0'); }
|
||||||
Serial.print(GPS.seconds, DEC); Serial.print('.');
|
Serial.print(GPS.seconds, DEC); Serial.print('.');
|
||||||
|
if (GPS.milliseconds < 10) {
|
||||||
|
Serial.print("00");
|
||||||
|
} else if (GPS.milliseconds > 9 && GPS.milliseconds < 100) {
|
||||||
|
Serial.print("0");
|
||||||
|
}
|
||||||
Serial.println(GPS.milliseconds);
|
Serial.println(GPS.milliseconds);
|
||||||
Serial.print("Date: ");
|
Serial.print("Date: ");
|
||||||
Serial.print(GPS.day, DEC); Serial.print('/');
|
Serial.print(GPS.day, DEC); Serial.print('/');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue