Documentation 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.
TS_Point is a lightweight data class returned by XPT2046_Touchscreen::getPoint(). It bundles a touch position (x, y) and a pressure reading (z) into a single object, and provides equality and inequality operators so touch positions can be compared directly without inspecting individual fields.
Header Declaration
The complete class definition as it appears inXPT2046_Touchscreen.h:
Fields
Horizontal touch position. Raw ADC output ranges from 0 to 4095; the exact value depends on the rotation mode set via
setRotation(). After the rotation transform, 0 is the left edge and 4095 is the right edge for the default rotation (1).Vertical touch position. Raw ADC output ranges from 0 to 4095; after the rotation transform, 0 is the top edge and 4095 is the bottom edge for the default rotation (1).
Touch pressure.
0 means the screen is not being touched (or pressure was below the internal Z_THRESHOLD of 300 and was zeroed out). Positive values of 300 or above indicate an active touch; higher values correspond to firmer finger pressure, up to a maximum of approximately 4095.Although
x, y, and z are declared as int16_t, the XPT2046 ADC is 12-bit, so only the range 0–4095 is produced in normal operation. Negative values will not appear under normal use.Constructors
TS_Point() — Default Constructor
Creates a TS_Point with all fields initialised to zero, equivalent to a no-touch state at the origin.
TS_Point(x, y, z) — Value Constructor
Creates a TS_Point with explicit coordinate and pressure values. Used internally by getPoint() to package the result of update().
Horizontal coordinate to store (0–4095).
Vertical coordinate to store (0–4095).
Pressure value to store. Typically 0 (no touch) or ≥ 300 (active touch).
Operators
operator==
Returns true only if the x, y, and z fields of both points are equal. All three fields must match for the result to be true.
true when p.x == x && p.y == y && p.z == z; false otherwise.operator!=
Returns true if any field differs between the two points. This is the logical complement of operator==.
true when p.x != x || p.y != y || p.z != z; false otherwise.Usage Examples
Checking for a valid touch
Always inspectz before treating x and y as a current touch position. When the screen is not pressed, z is 0 and x/y hold stale values from the last contact.
Detecting position changes
BecauseTS_Point implements operator!=, you can compare two points directly without checking each field manually:
Storing and replaying touch events
TS_Point is a plain value type with no heap allocations, making it safe to store in arrays or pass by value:
Z Threshold Note
The library definesZ_THRESHOLD = 300 in XPT2046_Touchscreen.cpp. This constant is used in two places:
touched()— returnstrueonly when the measured Z is ≥ 300.update()— setszraw = 0(and skips storing x/y) when Z drops below 300, sogetPoint()returnsz = 0for borderline readings.
Z_THRESHOLD_INT = 75 controls when isrWake is cleared: the flag is reset only once Z falls below 75, providing hysteresis to prevent spurious re-arming during a slow finger lift-off.