parent
c68499182d
commit
efa9bfd857
|
|
@ -220,13 +220,13 @@ boolean Adafruit_GPS::parse(char *nmea) {
|
|||
/**************************************************************************/
|
||||
void Adafruit_GPS::parseTime(char *p) {
|
||||
// get time
|
||||
float timef = atof(p);
|
||||
uint32_t time = timef;
|
||||
uint32_t time = atol(p);
|
||||
hour = time / 10000;
|
||||
minute = (time % 10000) / 100;
|
||||
seconds = (time % 100);
|
||||
|
||||
milliseconds = fmod(timef, 1.0) * 1000;
|
||||
p = strchr(p, '.')+1;
|
||||
milliseconds = atoi(p);
|
||||
lastTime = recvdTime;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,9 +83,17 @@ void loop() // run over and over again
|
|||
if (millis() - timer > 2000) {
|
||||
timer = millis(); // reset the timer
|
||||
Serial.print("\nTime: ");
|
||||
if (GPS.hour < 10) { Serial.print('0'); }
|
||||
Serial.print(GPS.hour, DEC); Serial.print(':');
|
||||
if (GPS.minute < 10) { Serial.print('0'); }
|
||||
Serial.print(GPS.minute, DEC); Serial.print(':');
|
||||
if (GPS.seconds < 10) { Serial.print('0'); }
|
||||
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.print("Date: ");
|
||||
Serial.print(GPS.day, DEC); Serial.print('/');
|
||||
|
|
|
|||
|
|
@ -86,9 +86,17 @@ void loop() // run over and over again
|
|||
timer = millis(); // reset the timer
|
||||
|
||||
Serial.print("\nTime: ");
|
||||
if (GPS.hour < 10) { Serial.print('0'); }
|
||||
Serial.print(GPS.hour, DEC); Serial.print(':');
|
||||
if (GPS.minute < 10) { Serial.print('0'); }
|
||||
Serial.print(GPS.minute, DEC); Serial.print(':');
|
||||
if (GPS.seconds < 10) { Serial.print('0'); }
|
||||
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.print("Date: ");
|
||||
Serial.print(GPS.day, DEC); Serial.print('/');
|
||||
|
|
|
|||
Loading…
Reference in New Issue