diff --git a/library.json b/library.json index 4a71165..a877758 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "rdm6300", - "version": "1.1.1", + "version": "1.1.2", "keywords": "rdm6300, rfid", "description": "A simple library to interface with rdm6300 rfid reader.", "repository": diff --git a/library.properties b/library.properties index 7e4c04f..fdf3a13 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Rdm6300 -version=1.1.1 +version=1.1.2 author=Arad Eizen maintainer=Arad Eizen sentence=A simple library to interface with rdm6300 rfid reader. diff --git a/src/rdm6300.cpp b/src/rdm6300.cpp index 5e6a201..2fafeac 100644 --- a/src/rdm6300.cpp +++ b/src/rdm6300.cpp @@ -89,12 +89,12 @@ bool Rdm6300::update(void) /* if a new tag appears- return it */ if (_last_tag_id != tag_id) { _last_tag_id = tag_id; - _next_read_ms = 0; + _last_read_ms = 0; } /* if the old tag is still here set tag_id to zero */ - if (_next_read_ms > millis()) + if (is_tag_near()) tag_id = 0; - _next_read_ms = millis() + RDM6300_NEXT_READ_MS; + _last_read_ms = millis(); _tag_id = tag_id; return tag_id; @@ -102,7 +102,7 @@ bool Rdm6300::update(void) bool Rdm6300::is_tag_near(void) { - return _next_read_ms > millis(); + return millis() - _last_read_ms < RDM6300_NEXT_READ_MS; } uint32_t Rdm6300::get_tag_id(void) diff --git a/src/rdm6300.h b/src/rdm6300.h index c74504e..505d338 100644 --- a/src/rdm6300.h +++ b/src/rdm6300.h @@ -49,7 +49,7 @@ class Rdm6300 Stream *_stream = NULL; uint32_t _tag_id = 0; uint32_t _last_tag_id = 0; - uint32_t _next_read_ms = 0; + uint32_t _last_read_ms = 0; }; #endif