Made nfc.py executable, increased tocard_retries to 20 due to increased CPU frequency.
Some checks failed
Build RPi Pico firmware image / Build-Firmware (push) Successful in 2m57s
Check code formatting / Check-C-Format (push) Successful in 6s
Check code formatting / Check-Python-Flake8 (push) Failing after 8s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 7s

This commit is contained in:
2025-03-18 21:02:25 +01:00
parent 5cda9891f5
commit 976bc4053c

View File

@@ -28,7 +28,7 @@ class Nfc:
asyncio.run(main())
'''
def __init__(self):
self.reader = MFRC522(spi_id=1, sck=10, miso=12, mosi=11, cs=13, rst=9, tocard_retries=10)
self.reader = MFRC522(spi_id=1, sck=10, miso=12, mosi=11, cs=13, rst=9, tocard_retries=20)
self.last_uid = None
self.last_uid_timestamp = None
self.task = asyncio.create_task(self._reader_poll_task())
@@ -62,3 +62,13 @@ class Nfc:
Returns the last read nfc tag uid alongside with the timestamp it was stored at.
'''
return self.last_uid, self.last_uid_timestamp
if __name__ == '__main__':
async def main():
n = Nfc()
while True:
await asyncio.sleep_ms(500)
print(f'{n.get_last_uid()}')
asyncio.run(main())