mirror of
https://github.com/adafruit/Adafruit_GPS.git
synced 2026-10-26 22:10:17 +00:00
added wrapping fix for timer
This commit is contained in:
1 parent
0d52221ff1
commit
df8764f196
1 file changed
+4
-1
@@ -94,7 +94,7 @@ void useInterrupt(boolean v) {
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t timer = millis();
|
||||
uint32_t timer = millis();
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// in case you are not using the interrupt above, you'll
|
||||
@@ -120,6 +120,9 @@ void loop() // run over and over again
|
||||
return; // we can fail to parse a sentence in which case we should just wait for another
|
||||
}
|
||||
|
||||
// if millis() or timer wraps around, we'll just reset it
|
||||
if (timer > millis()) timer = millis();
|
||||
|
||||
// approximately every 2 seconds or so, print out the current stats
|
||||
if (millis() - timer > 2000) {
|
||||
timer = millis(); // reset the timer
|
||||
|
||||
Reference in new issue
Block a user