How to rotate touch in TFT_eSPI?

Hi,

I'm working with TFT_eSPI sketch to get a basic grasp on the TFT and touch functionalities.

This function is for the TFT rotation.

tft.setRotation(2);

But how to set the touch rotation too ?

The touchScreen calls a function which returns a struct with either 3 or 2 fields. X, Y and sometimes Z (which is used for pressure). If you want to modify the rotation, you can let the X value make the Y value, or the X or Y value be the Width - X or Height - Y.
Basically you have to calculate it yourself.
the TFT rotation influences character drawing and libraries that take care of that, so the tft library needs to take care of that.

1 Like

Yeah, it turned out that the variables in the header file actually works to serve this purpose:

  uint16_t touchCalibration_x0 = 180, touchCalibration_x1 = 3380, touchCalibration_y0 = 380, touchCalibration_y1 = 3550;

This actually determines whether it's in portrait or landscape mode ?

touchCalibration_rotate

These determine the flip of x and y in each rotation mode:

  uint8_t  touchCalibration_rotate = 0, touchCalibration_invert_x = 0;

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.