Datasheet

To get the oldest point from the buffer. TS_Point has .x .y and .z data points. The x and y points range from 0 to 4095.
The STMPE610 does not store any calibration data in it and it doesn't know about rotation. So if you want to rotate the
screen you'll need to manually rotate the x/y points! The z point is 'pressure' and ranges from 0 to 255, we don't use it
here but you can experiment with it on your own, the harder you press, the lower the number.
Since data from the STMPE610 comes in 0-4095 but our screen is 320 pixels by 240 pixels, we can use map to
convert 0-4095 to 0-320 or 0-240. Something like
p.x = map(p.x, 0, 4095, 0, tft.width());
p.y = map(p.y, 0, 4095, 0, tft.height());
However, the touchscreen is a bit bigger than the screen, so we actually need to ignore presses beyond the
touchscreen itself. We found that these numbers reflected the true range that overlaps the screen
#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000
So we use
p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());
instead.
One last point (pun intended!) since the touchscreen driver stores points in a buffer, you may want to ask the driver "is
the touchscreen being pressed RIGHT NOW?" You can do that with
if (ts.touched())
© Adafruit Industries https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing Page 19 of 23