#include <SPI.h>
#include <TFT_eSPI.h>
#include <TFT_eTouch.h>
// Its difficult to have two spi at the same time, i have to create virtual spi for touchscreen
// SPI of the LCD and the XPT2046 are not in the same bus
// ESP32-2432S028
// LCD is working fine
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
auto vspi = new SPIClass(VSPI);
TFT_eTouch<TFT_eSPI> touch(tft, 33, 36, *vspi);
void setup() {
Serial.begin( 115200 );
vspi->begin(25, 39, 32, 33);
vspi->setFrequency( 60000000 );
pinMode(vspi->pinSS(), OUTPUT);
tft.init();
touch.init();
``
//RIGHT COLORS
tft.writecommand(TFT_MADCTL);
tft.writedata(0x40);
tft.fillScreen(TFT_BLACK);
tft.drawRect(0, 0, tft.width(), tft.height(), TFT_GREEN);
Serial.println("Config ended");
}
void loop() {
int16_t x = 0;
int16_t y = 0;
// Never entry here
if (touch.getXY(x, y)) {
Serial.print(x);
Serial.print(" ");
Serial.println(y);
}
}
I have tried to create a VSPI bus but only screen is working.
I have tried to create a VSPI bus but only screen is working.