Page 1 of 1

Looking for a ESP32 TouchScreen Library

Posted: Mon Feb 05, 2018 1:10 pm
by ats3788
Hello friends of the ESP32
This is working for the ESP32, but I could not find a Lib to use the Touchscreen.
https://github.com/MartyMacGyver/ESP32_Adafruit_ILI9341
Does someone know a Library working Touchscreen Lib for the ESP32.

Re: Looking for a ESP32 TouchScreen Library

Posted: Tue Feb 06, 2018 3:13 pm
by Cellie
If it is a XPT2046 then this one should work:

https://github.com/PaulStoffregen/XPT2046_Touchscreen

Re: Looking for a ESP32 TouchScreen Library

Posted: Thu Feb 08, 2018 7:01 pm
by ats3788
#include <XPT2046_Touchscreen.h>
#include <SPI.h>

#define CS_PIN 8
// MOSI=11, MISO=12, SCK=13

//XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN 2
//XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling

void setup() {
Serial.begin(38400);
ts.begin();
ts.setRotation(1);
while (!Serial && (millis() <= 1000));
}

void loop() {
if (ts.touched()) {
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
delay(30);
Serial.println();
}
}
Thank you
I can compile this but I don't knew yet, if is working, I write this down later.

Re: Looking for a ESP32 TouchScreen Library

Posted: Fri Feb 09, 2018 5:45 pm
by ats3788
What a pitty it does not work :cry:

Re: Looking for a ESP32 TouchScreen Library

Posted: Fri Feb 09, 2018 7:37 pm
by Duhjoker

Re: Looking for a ESP32 TouchScreen Library

Posted: Wed Jun 27, 2018 10:33 pm
by lesept
I have the same question: how to get the touchscreen work with my ESP32? I read the above link but I don't understand how to connect the touchscreen. Can anyone help me? Thank you

Re: Looking for a ESP32 TouchScreen Library

Posted: Fri Jun 29, 2018 12:21 am
by Deouss
I noticed on some boards there is an empty space with traces going to touchpad pins.
F.ex. this one: 2.4" 240x320 SPI TFT LCD

I wonder if I could just buy a touchscreen IC and just solder it there because seems like it is just missing to reduce the costs.
Anyone tried that maybe?

Re: Looking for a ESP32 TouchScreen Library

Posted: Sat Jun 30, 2018 9:26 am
by lesept
I found a solution that works. I use the TFT_eSPI library for the display and XPT2046_Touchscreenfor the touch.
TFT_eSPI defines the pins in a setup file, here is what I used:

Code: Select all

// For ESP32 Dev board (only tested with ILI9341 display)
// The hardware SPI can be mapped to any pins

#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS    5  // Chip select control pin (15)
#define TFT_DC    2  // Data Command control pin
#define TFT_RST   4  // Reset pin (could connect to RST pin)
and

Code: Select all

#define SPI_FREQUENCY  40000000 // Maximum to use SPIFFS

// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY  2500000

Re: Looking for a ESP32 TouchScreen Library

Posted: Fri May 17, 2019 5:47 pm
by deepakt
Hi,

Has anyone got this working lately? Also, based on the pins, I suppose that the CLK, MISO, MOSI pins would remain common for both LCD and Touch while the CS/SS will be different and independent for LCD and Touch? Would be great if someone can share a correct and tested pinout?

I'm working with a 2.8" LCD with touch screen (ILI9341 chipset) and having a little trouble integrating it, hence call for help.

Regards,
Deepak

Re: Looking for a ESP32 TouchScreen Library

Posted: Sat May 18, 2019 6:57 am
by deepakt
Looks like the TFT_eSPI library is now updated and supports ESP32 as well for use of touch.

https://forum.arduino.cc/index.php?topic=616515.0

https://github.com/Bodmer/TFT_eSPI

Regards,
Deepak