XPT2046_Touchscreen is intentionally designed to mirror the API ofDocumentation 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.
Adafruit_STMPE610, the library used by Adafruit’s resistive touchscreen breakouts. Sketches written for Adafruit touch controllers can be migrated to XPT2046-based displays by changing only the #include directive and the object constructor — every touch-reading call stays identical.
Compatible Functions
The following functions are present in both libraries with the same names, parameter types, and return value ranges:| Function | Description |
|---|---|
touched() | Returns true if the screen is currently being touched |
getPoint() | Returns a TS_Point with x, y, and z fields |
readData(x, y, z) | Writes current touch coordinates into pointer arguments |
bufferEmpty() | Returns true when no fresh data is buffered |
bufferSize() | Returns the number of points in the buffer |
x and y in both libraries, so any existing scaling or mapping code requires no changes.
Migration Steps
Replace the object declaration
Change the class name and remove any I²C address or extra arguments used by the STMPE610 constructor:
Before / After Comparison
Behavioural Differences to Be Aware Of
bufferSize() always returns 1. The STMPE610 has a 128-point hardware FIFO, so sketches that loop on bufferSize() to drain multiple queued points will simply read one point per call. In practice this is rarely a problem, as most sketches only read one point per loop() iteration.bufferEmpty() is time-based. Rather than checking a hardware FIFO, this library returns true when the last successful SPI read occurred fewer than 3 ms ago (MSEC_THRESHOLD). This prevents redundant reads within the same millisecond window and closely mimics the STMPE610 FIFO drain behaviour for typical polling rates.