Hi,
I succeeded in following the ESP32 LVGL course with my 2.8 inch CYD, which was different from the one you advised. Next i wanted to repeat the course with a 3.5 inch (320×480) CYD and ran into some trouble. I managed to get the LCD working by adjusting the user_setup.h for the TFT_eSPI library, but then:
Running the touchscreen test of chapter 1.9 i get the following serial monitor output:
16:55:24.429 -> [Warn] (27.570, +0) indev_pointer_proc: Y is 334 which is greater than ver. res lv_indev.c:723
16:55:24.429 ->
16:55:24.461 -> X = -15 | Y = 516 | Pressure = 4101
16:55:24.493 -> [Warn] (27.600, +30) indev_pointer_proc: X is 516 which is greater than hor. res lv_indev.c:717
16:55:24.493 ->
16:55:24.493 -> [Warn] (27.600, +0) indev_pointer_proc: Y is 334 which is greater than ver. res lv_indev.c:723
In the CYD screen i see
x=-15
y=516
z=4101
Possibly i have to adjust the calibration formula, but this pressure of 4101 is displayed without touching the screen
Do you have any idea how i can solve this?
I dit not change the lv_conf.h file.
Thanks in advance.
Addition:
I changed the pin values in the sketch according to the E32R35T CYD specifications:
//** Touchscreen pins aanpassen
#define XPT2046_IRQ 36 // T_IRQ was 36
#define XPT2046_MOSI 13 // T_DIN was 32
#define XPT2046_MISO 12 // T_OUT was 39
#define XPT2046_CLK 14 // T_CLK was 25
#define XPT2046_CS 33 // T_CS was 33
and the height/width:
#define SCREEN_WIDTH 320 //** was 240
#define SCREEN_HEIGHT 480 //** was 320
The rest was not changed.
I would appreciate some reaction
Hi.
I’m sorry for taking so long to get back to you.
For some reason, your question didn’t show up in my area until today…
Usually that error may be because some pin is not declared correctly.
But, it may also be that you need to change this (swap width with height):
#define SCREEN_WIDTH 320 //** was 240
#define SCREEN_HEIGHT 480 //** was 320
There may be some definitions in the User_setup that you might need to change for that screen.
Or you may need to change the rotation of the touchscreen so that it isn’t out of range:
touchscreen.setRotation(2);
You can use a number between 0 and 2.
I hope this helps, and I’m sorry for the delay in my response.
Regards,
Sara
I got it working. Had to use a different screen driver (the one supplied by the manufacurer) adjust both setup files (lvgl and TFT) and the pins in the sketches.
Rotation and screen size were ok.
So I am happy.
Regards,
M
Great.
When using different display models, we usually need different configurations.
I’m glad everything is working as expected now.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara
Hola Sara como estas, yo tambien presento este problema con una pantalla de 320X480, sin embargo solo pasa cuando toco los bordes de la pantalla, al parecer lo que pasa es que la pantalla no esta bien calibrada por eso se desborda cuando se tocan los extremos de la pantalla ( valores no esperados por la libreria) asi que en el modulo siguiente hice la calibracion y funciono bien, porque antes para que la pantalla reconociera el evento del boton tocaba picarle fuera de el, ahora con la calibracion si quedo el evento bien marcado dentro del boton.
Gracias saludos
Great.
I’m glad everything is working as expected after the calibration step.
Regards,
Sara
Hello mmmE,
I have excactly the same problem with the 3.5 ” Display and ST7796-Driver:
In the CYD screen i see:
x=-15
y=516
z=4101
I have already adapted the “User_Setup.h” for ST7796, the pin-config in “1_9_Touchscreen_Test.ino”, but don’t know how to adapt the “lv_conf.h”.
Can you please provide the relevant code-snippet in “lv_conf.h”, to get the 3.5″ display running ??
Thank-you in advance,
Gerald
Hi.
You need to modify the lv_conf.h file to use that driver.
There’s a line that says:
”
// Only define one driver, the other ones must be commented out
”
After that, comment the ILI9341_2_DRIVER and uncomment this line to use your driver
#define ST7796_DRIVER
As I don’t have one of those displays to experiment with, I’m not sure if there is something else that needs to be adjusted.
Regards,
Sara
Hi Sara,
thank-you for your quick response.
I’ve changed the lv_conf.h as follows, but the touch-problem is further pending:
/*Drivers for LCD devices connected via SPI/parallel port*/
#define LV_USE_ST7735 0
#define LV_USE_ST7789 0
#define LV_USE_ST7796 1
#define LV_USE_ILI9341 0
and in User_Setup.h:
// Only define one driver, the other ones must be commented out
//#define ILI9341_DRIVER // Generic driver for common displays
#define ST7796_DRIVER
..
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
..
#define TFT_BL 27 // LED back-light control pin
..
#define SPI_FREQUENCY 80000000
// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY 20000000
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY 2500000
// The ESP32 has 2 free SPI ports i.e. VSPI and HSPI, the VSPI is the default.
// If the VSPI port is in use and pins are not accessible (e.g. TTGO T-Beam)
// then uncomment the following line:
#define USE_HSPI_PORT
But the touch-problem is further pending. When executing the script “1_10_1_Calibration_Sketch.ino”, I see the following output, although I did not touch the screen:
x, y = 18, 4069
x, y = 18, 4069
x, y = 18, 4069
x, y = 18, 4069
x, y = 18, 4069
x, y = 18, 4069
x, y = 18, 4069
x, y = 18, 4069
x, y = 18, 4069
x, y = 18, 4069
Unfiltered values: mean_x = 18.00, mean_y = 4069.00
stdev_x = 0.00, stdev_y = 0.00
Good samples = 0
Filtered values: filt_mean_x = nan, filt_mean_y = nan
x_avg = 18 y_avg = 4069
Could it be possible, that some pins for eTFT (TFT..) and touch (XPT2046..)
have the same assignment (e.g. XPT2046_MOSI 13 <-> TFT_MOSI 13) ??
see here:
1_10_1_Calibration_Sketch.ino:
// Touchscreen pins
#define XPT2046_IRQ 36 // T_IRQ
#define XPT2046_MOSI 13 // T_DIN
#define XPT2046_MISO 12 // T_OUT
#define XPT2046_CLK 14 // T_CLK
#define XPT2046_CS 33 // T_CS
User_Setup.h:
#define TFT_MISO 12
#define TFT_MOSI 13
#define TFT_SCLK 14
#define TFT_CS 15 // Chip select control pin
#define TFT_DC 2 // Data Command control pin
//#define TFT_RST 4 // Reset pin (could connect to RST pin)
#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
#define TOUCH_CS 33 // Chip select pin (T_CS) of touch screen
Thank-you in advance,
Gerald
Hi.
Where did you get those touchscreen values?
Does the product page provide a pinout?
If so, you should also double-check the pins for the TFT and change them accordingly.
That’s probably a problem with the pin assignment.
Regards,
Sara
Hi Sara,
I think the touch problem with a 3.5″ CYD-Display, combined with ESP32-035, is now solved.
The SPI-lines for TFT and XPT2046 are in dual use for the 3.5″ CYD, so the PIN-assignment for MISO, MOSI and SCLK are the same. The problem was the SPIClass(VSPI).
For a 3.5″ CYD-Display use the HSPI class !
Therefore I have defined several display types (to be used in the scetch, in User_Setup.h and in lv_conf.h:
// @GG: CYD-Display-Types, define only one type !!
//#define CYD_2_8_USB1x // 2.8 inch display with ILI9341_2 (1 USB-Port)
//#define CYD_2_8_USB2x // 2.8 inch display with ST7789 (2 USB-Ports)
#define CYD_3_5_USB1x // 3.5 inch display with ST7796 (1 USB-Port)
// Touchscreen pins
#define XPT2046_IRQ 36 // T_IRQ
#if defined (CYD_3_5_USB1x)
#define XPT2046_MOSI 13 // T_DIN
#define XPT2046_MISO 12 // T_OUT
#define XPT2046_CLK 14 // T_CLK
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 480
SPIClass touchscreenSPI = SPIClass(HSPI); // @GG: due to dual use of SPI-lines, touch does not work with VSPI on 3,5″ CYD!
#else
// @ToDo: check SPI dual-use (as for 3.5″ display)
#define XPT2046_MOSI 32 // T_DIN
#define XPT2046_MISO 39 // T_OUT
#define XPT2046_CLK 25 // T_CLK
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
SPIClass touchscreenSPI = SPIClass(VSPI);
#endif
#define XPT2046_CS 33 // T_CS
XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);
So, I think you can close this topic.