@@ -25,7 +25,11 @@ def query_customization() -> dict:
2525 spi_ce = pyil .input_int ("SPI CEx (CE0=GPIO8, CE1=GPIO7)?" , blank = 0 , min = 0 , max = 1 , prompt_color = prompt_color ,
2626 prompt_hint = True )
2727
28- pin_irq = pyil .input_int ("IRQ GPIO pin (BCM numbering)?" , blank = 24 , min = 1 , max = 27 , prompt_color = prompt_color ,
28+ print ("\n The IRQ GPIO pin for card detection.\n "
29+ "This pin is REQUIRED for interrupt-driven card detection.\n "
30+ "WARNING: Polling mode (pin=0) has high CPU usage and may cause performance issues!\n "
31+ "Only disable IRQ if you have serious interrupt conflicts." )
32+ pin_irq = pyil .input_int ("IRQ GPIO pin (BCM numbering)?" , blank = 24 , min = 0 , max = 27 , prompt_color = prompt_color ,
2933 prompt_hint = True )
3034
3135 print ("\n Reset GPIO pin for hardware reset. This is an optional pin.\n "
@@ -68,6 +72,15 @@ def __init__(self, reader_cfg_key):
6872 spi_bus = config .setdefault ('spi_bus' , None )
6973 spi_ce = config .setdefault ('spi_ce' , None )
7074 pin_irq = config .setdefault ('pin_irq' , None )
75+ if pin_irq == 0 :
76+ pin_irq = None
77+ self .pin_irq = pin_irq
78+ if self .pin_irq is None :
79+ self ._logger .warning ("No IRQ pin configured - using POLLING MODE" )
80+ self ._logger .warning ("WARNING: Polling mode has high CPU usage and may impact system performance!" )
81+ self ._logger .warning ("Consider using an IRQ pin for better performance" )
82+ else :
83+ self ._logger .info (f"Using IRQ pin { self .pin_irq } for interrupt-driven card detection" )
7184
7285 if 'pin_rst' not in config :
7386 self ._logger .warning ("No parameter 'pin_rst' found. Disabling hardware reset." )
@@ -131,7 +144,8 @@ def _read_card_normal(self) -> str:
131144
132145 def read_card (self ) -> str :
133146 # Scan for cards
134- self .device .wait_for_tag ()
147+ if self .pin_irq is not None :
148+ self .device .wait_for_tag ()
135149 if not self ._keep_running :
136150 return ''
137151 return self ._read_function ()
0 commit comments