speed up by checking i2c busy byte

This commit is contained in:
ladyada 2018-08-24 14:46:03 -04:00
parent 29679ba8a3
commit aa36758493

View file

@ -262,17 +262,12 @@ class PN532_I2C(object):
status = bytearray(1) status = bytearray(1)
t = time.monotonic() t = time.monotonic()
while (time.monotonic() - t) < timeout: while (time.monotonic() - t) < timeout:
"""
with self._i2c: with self._i2c:
self._i2c.readinto(status) self._i2c.readinto(status)
if status == b'\0x01': if status == b'\x01':
print(".ready.")
return True return True
else: else:
print(".busy.")
time.sleep(0.1) time.sleep(0.1)
"""
time.sleep(timeout)
return True return True
def call_function(self, command, response_length=0, params=[], timeout=1): def call_function(self, command, response_length=0, params=[], timeout=1):