1515#include "esp_lcd_panel_vendor.h"
1616#include "esp_lcd_panel_ops.h"
1717#include "esp_lvgl_port.h"
18+ #include "esp_lcd_ili9341.h"
1819
19- #include "esp_lcd_touch_tt21100 .h"
20+ #include "esp_lcd_touch_gt911 .h"
2021
2122#include "unity.h"
2223
4041#define EXAMPLE_LCD_GPIO_RST (GPIO_NUM_48)
4142#define EXAMPLE_LCD_GPIO_DC (GPIO_NUM_4)
4243#define EXAMPLE_LCD_GPIO_CS (GPIO_NUM_5)
43- #define EXAMPLE_LCD_GPIO_BL (GPIO_NUM_45 )
44+ #define EXAMPLE_LCD_GPIO_BL (GPIO_NUM_47 )
4445
4546/* Touch settings */
4647#define EXAMPLE_TOUCH_I2C_NUM (0)
@@ -64,6 +65,26 @@ static lv_display_t *lvgl_disp = NULL;
6465static lv_indev_t * lvgl_touch_indev = NULL ;
6566static i2c_master_bus_handle_t i2c_handle = NULL ;
6667
68+ static const ili9341_lcd_init_cmd_t vendor_specific_init [] = {
69+ {0xC8 , (uint8_t []){0xFF , 0x93 , 0x42 }, 3 , 0 },
70+ {0xC0 , (uint8_t []){0x0E , 0x0E }, 2 , 0 },
71+ {0xC5 , (uint8_t []){0xD0 }, 1 , 0 },
72+ {0xC1 , (uint8_t []){0x02 }, 1 , 0 },
73+ {0xB4 , (uint8_t []){0x02 }, 1 , 0 },
74+ {0xE0 , (uint8_t []){0x00 , 0x03 , 0x08 , 0x06 , 0x13 , 0x09 , 0x39 , 0x39 , 0x48 , 0x02 , 0x0a , 0x08 , 0x17 , 0x17 , 0x0F }, 15 , 0 },
75+ {0xE1 , (uint8_t []){0x00 , 0x28 , 0x29 , 0x01 , 0x0d , 0x03 , 0x3f , 0x33 , 0x52 , 0x04 , 0x0f , 0x0e , 0x37 , 0x38 , 0x0F }, 15 , 0 },
76+
77+ {0xB1 , (uint8_t []){00 , 0x1B }, 2 , 0 },
78+ {0x36 , (uint8_t []){0x08 }, 1 , 0 },
79+ {0x3A , (uint8_t []){0x55 }, 1 , 0 },
80+ {0xB7 , (uint8_t []){0x06 }, 1 , 0 },
81+
82+ {0x11 , (uint8_t []){0 }, 0x80 , 0 },
83+ {0x29 , (uint8_t []){0 }, 0x80 , 0 },
84+
85+ {0 , (uint8_t []){0 }, 0xff , 0 },
86+ };
87+
6788static esp_err_t app_lcd_init (void )
6889{
6990 esp_err_t ret = ESP_OK ;
@@ -100,16 +121,22 @@ static esp_err_t app_lcd_init(void)
100121 ESP_GOTO_ON_ERROR (esp_lcd_new_panel_io_spi ((esp_lcd_spi_bus_handle_t )EXAMPLE_LCD_SPI_NUM , & io_config , & lcd_io ), err , TAG , "New panel IO failed" );
101122
102123 ESP_LOGD (TAG , "Install LCD driver" );
124+ const ili9341_vendor_config_t vendor_config = {
125+ .init_cmds = & vendor_specific_init [0 ],
126+ .init_cmds_size = sizeof (vendor_specific_init ) / sizeof (ili9341_lcd_init_cmd_t ),
127+ };
103128 const esp_lcd_panel_dev_config_t panel_config = {
104129 .reset_gpio_num = EXAMPLE_LCD_GPIO_RST ,
130+ .flags .reset_active_high = 1 ,
105131#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL (6 , 0 , 0 )
106132 .rgb_endian = LCD_RGB_ENDIAN_BGR ,
107133#else
108134 .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR ,
109135#endif
110136 .bits_per_pixel = EXAMPLE_LCD_BITS_PER_PIXEL ,
137+ .vendor_config = (void * ) & vendor_config ,
111138 };
112- ESP_GOTO_ON_ERROR (esp_lcd_new_panel_st7789 (lcd_io , & panel_config , & lcd_panel ), err , TAG , "New panel failed" );
139+ ESP_GOTO_ON_ERROR (esp_lcd_new_panel_ili9341 (lcd_io , & panel_config , & lcd_panel ), err , TAG , "New panel failed" );
113140
114141 esp_lcd_panel_reset (lcd_panel );
115142 esp_lcd_panel_init (lcd_panel );
@@ -168,10 +195,10 @@ static esp_err_t app_touch_init(void)
168195 .mirror_y = 0 ,
169196 },
170197 };
171- esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_TT21100_CONFIG ();
198+ esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG ();
172199 tp_io_config .scl_speed_hz = EXAMPLE_TOUCH_I2C_CLK_HZ ;
173200 ESP_RETURN_ON_ERROR (esp_lcd_new_panel_io_i2c (i2c_handle , & tp_io_config , & tp_io_handle ), TAG , "" );
174- return esp_lcd_touch_new_i2c_tt21100 (tp_io_handle , & tp_cfg , & touch_handle );
201+ return esp_lcd_touch_new_i2c_gt911 (tp_io_handle , & tp_cfg , & touch_handle );
175202}
176203
177204static esp_err_t app_touch_deinit (void )
@@ -185,13 +212,7 @@ static esp_err_t app_touch_deinit(void)
185212static esp_err_t app_lvgl_init (void )
186213{
187214 /* Initialize LVGL */
188- const lvgl_port_cfg_t lvgl_cfg = {
189- .task_priority = 4 , /* LVGL task priority */
190- .task_stack = 4096 , /* LVGL task stack size */
191- .task_affinity = -1 , /* LVGL task pinned to core (-1 is no affinity) */
192- .task_max_sleep_ms = 500 , /* Maximum sleep in LVGL task */
193- .timer_period_ms = 5 /* LVGL timer tick period in ms */
194- };
215+ const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG ();
195216 ESP_RETURN_ON_ERROR (lvgl_port_init (& lvgl_cfg ), TAG , "LVGL port initialization failed" );
196217
197218 /* Add LCD screen */
0 commit comments