Verified Commit 869310ad authored by Jakob Moser's avatar Jakob Moser
Browse files

Try waiting for tag

parent ea119a8c
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -37,10 +37,11 @@ class Pirc522CardReader(CardReader):
        print("Reading block 10: " + str(self._reader.read(10)))

    def on_card_presented(self, handle_card: Callable[[CardReader], None]) -> None:
        # TODO Do all this repeatedly in a background thread
        # TODO This only works if the interrupt pin (pin_irq) is correctly initialized
        # TODO Run this in a background thread
        while True:
            # This only works if the interrupt pin (pin_irq) is correctly initialized
            self._reader.wait_for_tag()
        # TODO Call handle method
            handle_card(self)

    def on_card_removed(self, handle_removal: Callable[[CardReader], None]) -> None:
        # TODO Implement
+6 −0
Original line number Diff line number Diff line
@@ -14,10 +14,16 @@ DEFAULT_READER = "pirc522"


def action_id(reader: CardReader) -> None:
    def _read_and_print_id():
        card_id = reader.read_id()
        print("Card ID (base 10)", card_id)
        print("Card ID (base 16)", hex(card_id))

    try:
        reader.on_card_presented(lambda _: _read_and_print_id())
    except NotImplementedError:
        _read_and_print_id()


ACTIONS = {"id": action_id}