Xpt2046 touch gestures are weird

I am implementing LCD and touch using tft_espi and xpt2046 on esp32-s3 custom board
But the touch function does not work properly
Even if I do not touch, the value always comes out as
X = -26, Y = -20 Pressure = 4095
And the touch does not work
Just in case, I disconnected the MISO of the LCD
I am using spi2 of esp32-s3
Is there a way to use spi2 on xpt2046?

Could the LCD be broken?

The source code is below

XPT2046_Touchscreen touchscreen(TOUCH_CS);
TFT_eSPI tft = TFT_eSPI();
void setup() {
  Serial.begin(115200);
  tft.init();
  tft.fillScreen(TFT_WHITE);
  tft.setTextColor(TFT_BLACK, TFT_WHITE);

  touchscreen.begin();
}

void loop() {
  if (touchscreen.touched()) {

    TS_Point p = touchscreen.getPoint();

    Serial.print("X = ");
    Serial.print(p.x);
    Serial.print(" | Y = ");
    Serial.print(p.y);
    Serial.print(" | Pressure = ");
    Serial.print(p.z);
    Serial.println();
  
    delay(100);
  }
}

The prototype of begin() in XPT2046_Touchscreen.h is like this:

class XPT2046_Touchscreen {
public:
	constexpr XPT2046_Touchscreen(uint8_t cspin, uint8_t tirq=255)
		: csPin(cspin), tirqPin(tirq) { }
	bool begin(SPIClass &wspi = SPI);
...
}

So how about this:

touchscreen.begin(SPI2);

TFT_eSPI can handle touch events by itself. Why do you use SPI2 in addition to XPT2046_Touchscreen instead of just using SPI + TFT_eSPI ?

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