ILI9488 incompatibility with touch screen + TFT_eSPI + XPT2046_Touchscreen library:

compilation ok but not working.
Just put ts.begin() before tft.begin() for everything to work fine. I don't understand why it doesn't work if ts.begin() is placed after tft.begin().

If someone can explain to me?

No, because you failed to provide the necessary information (p.e. complete code, what exactly fails, etc.). Please read the sticky post at the top of the forum topic.

This test on ESP8266 is ok:

#include <TFT_eSPI.h>
#include <XPT2046_Touchscreen.h>
#include <SPI.h>

#define CS_PIN  4
#define TIRQ_PIN  255
XPT2046_Touchscreen ts(CS_PIN);
TFT_eSPI tft = TFT_eSPI();

void setup() {
  Serial.begin(115200);
   if(ts.begin()==true) Serial.println("\n Touch started..");
  else Serial.println("Touch failed..");
  tft.begin();
  tft.fillScreen(TFT_RED);tft.setTextSize(3);
  tft.setTextColor(TFT_WHITE);
  tft.setCursor(100,100);tft.print("Red Test tft");
}
void loop() {
}

but this one does not succeed:

#include <TFT_eSPI.h>
#include <XPT2046_Touchscreen.h>
#include <SPI.h>

#define CS_PIN  4
#define TIRQ_PIN  255
XPT2046_Touchscreen ts(CS_PIN);
TFT_eSPI tft = TFT_eSPI();

void setup() {
  Serial.begin(115200);
  tft.begin();
  if(ts.begin()==true) Serial.println("\n Touch started..");
  else Serial.println("Touch failed..");
  tft.fillScreen(TFT_BLUE);tft.setTextSize(3);
  tft.setTextColor(TFT_WHITE);
  tft.setCursor(100,100);tft.print("Blue Test tft");
  
}

void loop() {
}

The difference is just the order of tft.begin() and ts.begin()
Is it a bug in the XPT2046_Touchscreen library?

You didn't post the tft_setup.h file you used. I guess the library detected for any reason that your system doesn't support SPI transactions, so the SPI bus configuration gets changed by the touch screen library and the TFT library cannot communicate afterwards.

I only want to help users of the XPT2046_Touchscreen.h library to be careful to place XPT2046_Touchscreen ts(CS_PIN) first and then
TFT_eSPI tft = TFT_eSPI();
I wasted a lot of time to find that out.
These two libraries work when they are used alone or in the order recommended above.

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