Skip to content

Commit 076ae4c

Browse files
committed
Changed _next_read_ms to _last_read_ms to prevent millis() rollover
1 parent 827fac0 commit 076ae4c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/rdm6300.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,20 @@ bool Rdm6300::update(void)
8989
/* if a new tag appears- return it */
9090
if (_last_tag_id != tag_id) {
9191
_last_tag_id = tag_id;
92-
_next_read_ms = 0;
92+
_last_read_ms = 0;
9393
}
9494
/* if the old tag is still here set tag_id to zero */
95-
if (_next_read_ms > millis())
95+
if (is_tag_near())
9696
tag_id = 0;
97-
_next_read_ms = millis() + RDM6300_NEXT_READ_MS;
97+
_last_read_ms = millis();
9898

9999
_tag_id = tag_id;
100100
return tag_id;
101101
}
102102

103103
bool Rdm6300::is_tag_near(void)
104104
{
105-
return _next_read_ms > millis();
105+
return millis() - _last_read_ms < RDM6300_NEXT_READ_MS;
106106
}
107107

108108
uint32_t Rdm6300::get_tag_id(void)

src/rdm6300.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Rdm6300
4949
Stream *_stream = NULL;
5050
uint32_t _tag_id = 0;
5151
uint32_t _last_tag_id = 0;
52-
uint32_t _next_read_ms = 0;
52+
uint32_t _last_read_ms = 0;
5353
};
5454

5555
#endif

0 commit comments

Comments
 (0)