12
12
#include < driver/i2c_master.h>
13
13
#include < driver/spi_common.h>
14
14
#include < wifi_station.h>
15
+ #include < esp_lcd_touch_ft5x06.h>
16
+ #include < esp_lvgl_port.h>
17
+ #include < lvgl.h>
18
+
15
19
16
20
#define TAG " LichuangDevBoard"
17
21
@@ -125,6 +129,41 @@ class LichuangDevBoard : public WifiBoard {
125
129
});
126
130
}
127
131
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
+
128
167
// 物联网初始化,添加对 AI 可见设备
129
168
void InitializeIot () {
130
169
auto & thing_manager = iot::ThingManager::GetInstance ();
@@ -137,6 +176,7 @@ class LichuangDevBoard : public WifiBoard {
137
176
InitializeI2c ();
138
177
InitializeSpi ();
139
178
InitializeSt7789Display ();
179
+ InitializeTouch ();
140
180
InitializeButtons ();
141
181
InitializeIot ();
142
182
GetBacklight ()->RestoreBrightness ();
0 commit comments