The XPT2046 chip has a dedicated interrupt output pin, typically labelledDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/PaulStoffregen/XPT2046_Touchscreen/llms.txt
Use this file to discover all available pages before exploring further.
T_IRQ on low-cost TFT modules. This pin is driven LOW whenever the screen is being touched, and also while the controller is transmitting SPI data. The library provides built-in support for this pin that lets your loop() skip all SPI activity when the screen has not been touched, which reduces CPU overhead and avoids blocking other SPI peripherals.
How T_IRQ Works
WhenT_IRQ is wired to an interrupt-capable GPIO and passed to the constructor, begin() calls attachInterrupt() internally. The library’s ISR sets a single boolean flag (isrWake) on each falling edge. Calling tirqTouched() reads that flag without touching the SPI bus at all — it returns true only when an interrupt has been recorded since the last confirmed read. You then call touched() to confirm the press and retrieve valid coordinates.
Two Modes of Operation
- Built-in support (recommended)
- No interrupt pin
Pass In
TIRQ_PIN to the constructor. The library registers its own ISR automatically — you do not need to call attachInterrupt() yourself.loop(), gate all SPI activity behind tirqTouched():Performance Benefit
tirqTouched() inspects the isrWake boolean directly — there is no SPI transaction, no digitalWrite(), and no bus arbitration. In projects where other SPI devices (displays, SD cards, sensors) share the bus, this prevents unnecessary bus contention on every loop() iteration when the screen is idle.
The internal ISR sets
isrWake = true on every falling edge of T_IRQ. After a successful touch read where pressure falls below the low threshold (Z_THRESHOLD_INT = 75), the library clears the flag automatically so the next tirqTouched() call returns false until the screen is touched again.Warning: Custom Interrupt Handlers
If you need custom interrupt behaviour alongside SPI sharing, inform the SPI library first:Deep Sleep Wakeup
TheT_IRQ falling edge can wake a microcontroller from deep sleep. The key requirement is to stop all touch reads before sleeping and disable the interrupt again before resuming reads on wakeup.