tag-reader: update to pi-rc522 2.1
This version of pi-rc522 gives us a wait_for_tag() method, greatly reducing CPU usage.
This commit is contained in:
parent
39fd4018f6
commit
e5c4923609
@ -1,3 +1,7 @@
|
||||
pi-rc522==1.1.0
|
||||
appdirs==1.4.3
|
||||
packaging==16.8
|
||||
pi-rc522==2.1.0
|
||||
pyparsing==2.2.0
|
||||
RPi.GPIO==0.6.3
|
||||
SPI-Py==1.0
|
||||
six==1.10.0
|
||||
spidev==3.2
|
||||
|
@ -3,11 +3,21 @@ from pirc522 import RFID
|
||||
import RPi.GPIO as GPIO
|
||||
import sys
|
||||
|
||||
import signal
|
||||
|
||||
GPIO.setwarnings(False)
|
||||
|
||||
rdr = RFID()
|
||||
|
||||
def sigint_handler(signal, frame):
|
||||
rdr.cleanup()
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGINT, sigint_handler)
|
||||
signal.signal(signal.SIGTERM, sigint_handler)
|
||||
|
||||
while True:
|
||||
rdr.wait_for_tag()
|
||||
(error, tag_type) = rdr.request()
|
||||
if not error:
|
||||
(error, uid) = rdr.anticoll()
|
||||
|
Loading…
Reference in New Issue
Block a user