parent
c68499182d
commit
efa9bfd857
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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