I am using an ESP32 NodeMCU-32S and a 2.4" TFT ILI9341 display with XPT2046 touch controller (this one http://www.lcdwiki.com/2.4inch_SPI_Modu ... KU:MSP2402)
I understood that I could save both, TFT and Touch, off the VSPI, and thus connected both to the default VSPI pins, the only custom pin is CS, as follows:
Code: Select all
// Display SPI - default VSPI for ESP32 WROOM32
#define TFT_MISO 19 // shared with T_DO
#define TFT_MOSI 23 // shared with T_DIN
#define TFT_SCLK 18 // shared with T_CLK
#define TFT_CS 5 // Chip select control pin
#define TFT_DC 4 // Data Command control pin
#define TFT_RST 2 // Reset pin (could connect to RST pin)
#define TFT_BL 16 // backlight
// screen initialization
Adafruit_ILI9341 display = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST, TFT_MISO);
U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx;
#define TOUCH_CS 15 //HSPI CS
// touch controller init
XPT2046_Touchscreen touch(TOUCH_CS);
TS_Point rawLocation;
Code: Select all
void setup() {
Serial.begin(115200);
//analogReference(INTERNAL); //2.56V for micro
//initialize I2C SPL06 Sensor
Wire.begin();
SPL_init();
//initialize the display
initDisplay();
drawStaticSensorScreen(); //draw static screen for sensor measurements, including banner
touch.begin();
touch.setRotation(3);
u8g2_for_adafruit_gfx.setCursor(100,100);
u8g2_for_adafruit_gfx.print("TEST");
}