Skip to content

Commit fdf5221

Browse files
authored
Merge pull request #3 from gutierrezps/fix-millis-rollover
Changed _next_read_ms to _last_read_ms to prevent millis() rollover
2 parents 827fac0 + 2f92ce7 commit fdf5221

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rdm6300",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"keywords": "rdm6300, rfid",
55
"description": "A simple library to interface with rdm6300 rfid reader.",
66
"repository":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Rdm6300
2-
version=1.1.1
2+
version=1.1.2
33
author=Arad Eizen
44
maintainer=Arad Eizen <https://github.com/arduino12>
55
sentence=A simple library to interface with rdm6300 rfid reader.

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)