1212#include < driver/i2c_master.h>
1313#include < driver/spi_common.h>
1414#include < wifi_station.h>
15+ #include < esp_lcd_touch_ft5x06.h>
16+ #include < esp_lvgl_port.h>
17+ #include < lvgl.h>
18+
1519
1620#define TAG " LichuangDevBoard"
1721
@@ -125,6 +129,41 @@ class LichuangDevBoard : public WifiBoard {
125129 });
126130 }
127131
132+ void InitializeTouch ()
133+ {
134+ esp_lcd_touch_handle_t tp;
135+ esp_lcd_touch_config_t tp_cfg = {
136+ .x_max = DISPLAY_WIDTH,
137+ .y_max = DISPLAY_HEIGHT,
138+ .rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset
139+ .int_gpio_num = GPIO_NUM_NC,
140+ .levels = {
141+ .reset = 0 ,
142+ .interrupt = 0 ,
143+ },
144+ .flags = {
145+ .swap_xy = 1 ,
146+ .mirror_x = 1 ,
147+ .mirror_y = 0 ,
148+ },
149+ };
150+ esp_lcd_panel_io_handle_t tp_io_handle = NULL ;
151+ esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG ();
152+ tp_io_config.scl_speed_hz = 400000 ;
153+
154+ esp_lcd_new_panel_io_i2c (i2c_bus_, &tp_io_config, &tp_io_handle);
155+ esp_lcd_touch_new_i2c_ft5x06 (tp_io_handle, &tp_cfg, &tp);
156+ assert (tp);
157+
158+ /* Add touch input (for selected screen) */
159+ const lvgl_port_touch_cfg_t touch_cfg = {
160+ .disp = lv_display_get_default (),
161+ .handle = tp,
162+ };
163+
164+ lvgl_port_add_touch (&touch_cfg);
165+ }
166+
128167 // 物联网初始化,添加对 AI 可见设备
129168 void InitializeIot () {
130169 auto & thing_manager = iot::ThingManager::GetInstance ();
@@ -137,6 +176,7 @@ class LichuangDevBoard : public WifiBoard {
137176 InitializeI2c ();
138177 InitializeSpi ();
139178 InitializeSt7789Display ();
179+ InitializeTouch ();
140180 InitializeButtons ();
141181 InitializeIot ();
142182 GetBacklight ()->RestoreBrightness ();
0 commit comments