Skip to content

keyboardpartner/TFT-Panel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TFT-Panel

TFT GUI Elements for ESP32 and Other

Project for PlatformIO VSCODE IDE

GUI elements for dual channel DC power supply as example for TFT_eSPI library and touch screen handling with XPT2046 or built-in touch screen of TFT panel. Also suitable for other TFT displays with touch screen like CYD ("Cheap Yellow Display", ESP32-2432S028R)

All elements are scalable and may be placed anywhere. Demo with display 320x240 px. All GUI elements may be disabled/greyed out on command, useful for inactive controls (for example outside of dialog box or menu list). Analog Meter and clock widgets modified for execution speed and scalability.

The example is #define'd for CYD , it provides a built-in web server (AP mode on 192.168.4.1). Board type BOARD_CYD (cheap yellow display, using a ST7789 display driver IC) or BOARD_OA (homemade, with ILI9341 display driver) are defined in platformio.ini, switch environment in PlatformIO accordingly. Hardware defines are located in hwdefs.h, other defines in global_vars.h. Environment will set pin defines for each board.

The CYD uses a touch controller pinout different to TFT_eSPI default, so a separate driver for XPT2046 touch controller is loaded here (see platformio.ini).

Tips for Cheap Yellow Display (CYD)

The ESP32-2432S028R CYD used for evaluation has 2 USB ports (Micro USB and USB-C) and works well with the ST7789_DRIVER. It needed the SPI_READ_FREQUENCY defined in platformio.ini environment section [env:esp32_CYD] reduced from 20000000 to 10000000 to read correct colors from screen area. The SPI write speed SPI_FREQUENCY may be increased up to 50000000 for faster screen updates.

Other or older CYDs (without USB-C) may need the ILI9341_2_DRIVER instead of ILI9341_DRIVER and some #defines set to work properly. See platformio.ini for details. Also, the Gamma values provided in original ILI9341_Init.h from TFT_eSPI package show weak and blurried colors. Disabling the Gamma setup will yield much better color rendition. Replace the ILI9341_Init.h file in .pio/libdeps/ESP32_CYD/TFT_eSPI/TFT_Drivers with the file provided. Please check if your CYD works with the ST7789_DRIVER before replacing the ILI9341_Init.h file!

For various CYD versions, also see ESP32 mit 2,8 Zoll TFT (Cheap Yel­low Display) from Hartmut Waller and CYD Touch Programming from Oliver Kuhlemann (both pages in german).

Other hardware quirks are mentioned here, like modifying the the completely useless LDR (light dependant resistor) circuit or reducing the much too high audio gain. This is a fine example how chinese manufacturers copy & paste even obvious faults and errors. Reducing R15 value to 33k (instead of 1M) will yield even better results. Here is the complete list of modifications:

  • Replace R15 (1M) with 33k resistor (for useful LDR range)
  • bridge R19 (1M) with 1µ capacitor (filters LDR output)
  • replace R7 (0R) with 47k resistor (PWM filter improvement)
  • replace R8 (0R) with 22k resistor (gain reduction)
  • bridge R9 (68k) with 47k resistor (gain reduction)

All parts have SMT size 0603.

Using the SD card on CYD

In order to use the SD card in conjunction with the TFT_eSPI library, a certain amount of care is required. The XTP2046 on CYD uses different SPI pins than those expected by the TFT_eSPI library, so the built-in touch functions of TFT_eSPI cannot be used. For the CYD, the separate XTP2046 library from Paul Stoffregen is loaded. We use the ESP32 VSPI for both SD card and touch controller. This works fine when SPI pins are switched between SD card and touch usage. See hardwareInit() function in global_vars.h for details. Drawback: While the SD card is accessed, no touch input is registered.

Classes Provided

Button, Switch, LED indicator, Analog Meter, Numeric Display, Analog Bargraph horizontal with maximum hold (red line) and optional value set point (triangle) by touch

Scrolling Oscilloscope Chart, Analog Bargraph vertical with maximum hold (red line) and optional value set point (triangle) by touch

Checkbox, Radio Button Group, Tab Control, Numeric Entry with rotary encoder or numeric keypad, Checkbox Group, Slider/Trackbar, Tab Control

Numeric Keypad, Dialog Box, Menu List, Analog Clock

About

ESP32 GUI Elements

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published