diff --git a/main/boards/lichuang-dev/lichuang_dev_board.cc b/main/boards/lichuang-dev/lichuang_dev_board.cc index 2f59c6aa..9da126ff 100644 --- a/main/boards/lichuang-dev/lichuang_dev_board.cc +++ b/main/boards/lichuang-dev/lichuang_dev_board.cc @@ -12,6 +12,10 @@ #include #include #include +#include +#include +#include + #define TAG "LichuangDevBoard" @@ -125,6 +129,41 @@ private: }); } + void InitializeTouch() + { + esp_lcd_touch_handle_t tp; + esp_lcd_touch_config_t tp_cfg = { + .x_max = DISPLAY_WIDTH, + .y_max = DISPLAY_HEIGHT, + .rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset + .int_gpio_num = GPIO_NUM_NC, + .levels = { + .reset = 0, + .interrupt = 0, + }, + .flags = { + .swap_xy = 1, + .mirror_x = 1, + .mirror_y = 0, + }, + }; + esp_lcd_panel_io_handle_t tp_io_handle = NULL; + esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG(); + tp_io_config.scl_speed_hz = 400000; + + esp_lcd_new_panel_io_i2c(i2c_bus_, &tp_io_config, &tp_io_handle); + esp_lcd_touch_new_i2c_ft5x06(tp_io_handle, &tp_cfg, &tp); + assert(tp); + + /* Add touch input (for selected screen) */ + const lvgl_port_touch_cfg_t touch_cfg = { + .disp = lv_display_get_default(), + .handle = tp, + }; + + lvgl_port_add_touch(&touch_cfg); + } + // 物联网初始化,添加对 AI 可见设备 void InitializeIot() { auto& thing_manager = iot::ThingManager::GetInstance(); @@ -137,6 +176,7 @@ public: InitializeI2c(); InitializeSpi(); InitializeSt7789Display(); + InitializeTouch(); InitializeButtons(); InitializeIot(); GetBacklight()->RestoreBrightness(); diff --git a/main/idf_component.yml b/main/idf_component.yml index c9b3bccf..efac5b8e 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -17,6 +17,7 @@ dependencies: espressif/esp-sr: "^2.0.5" espressif/button: "^3.3.1" espressif/knob: "^1.0.0" + espressif/esp_lcd_touch_ft5x06: "~1.0.6" lvgl/lvgl: "~9.2.2" esp_lvgl_port: "~2.4.4" espressif/esp_io_expander_tca95xx_16bit: "^2.0.0"