2121#include " esp_io_expander_tca9554.h"
2222#include " settings.h"
2323
24+ #include < esp_lcd_touch_ft5x06.h>
25+ #include < esp_lvgl_port.h>
26+ #include < lvgl.h>
27+
2428#define TAG " waveshare_amoled_1_8"
2529
2630LV_FONT_DECLARE (font_puhui_30_4);
@@ -252,6 +256,38 @@ class waveshare_amoled_1_8 : public WifiBoard {
252256 backlight_->RestoreBrightness ();
253257 }
254258
259+ void InitializeTouch ()
260+ {
261+ esp_lcd_touch_handle_t tp;
262+ esp_lcd_touch_config_t tp_cfg = {
263+ .x_max = DISPLAY_WIDTH,
264+ .y_max = DISPLAY_HEIGHT,
265+ .rst_gpio_num = GPIO_NUM_NC,
266+ .int_gpio_num = GPIO_NUM_21,
267+ .levels = {
268+ .reset = 0 ,
269+ .interrupt = 0 ,
270+ },
271+ .flags = {
272+ .swap_xy = 0 ,
273+ .mirror_x = 0 ,
274+ .mirror_y = 0 ,
275+ },
276+ };
277+ esp_lcd_panel_io_handle_t tp_io_handle = NULL ;
278+ esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG ();
279+ tp_io_config.scl_speed_hz = 400 * 1000 ;
280+ ESP_ERROR_CHECK (esp_lcd_new_panel_io_i2c (codec_i2c_bus_, &tp_io_config, &tp_io_handle));
281+ ESP_LOGI (TAG, " Initialize touch controller" );
282+ ESP_ERROR_CHECK (esp_lcd_touch_new_i2c_ft5x06 (tp_io_handle, &tp_cfg, &tp));
283+ const lvgl_port_touch_cfg_t touch_cfg = {
284+ .disp = lv_display_get_default (),
285+ .handle = tp,
286+ };
287+ lvgl_port_add_touch (&touch_cfg);
288+ ESP_LOGI (TAG, " Touch panel initialized successfully" );
289+ }
290+
255291 // 物联网初始化,添加对 AI 可见设备
256292 void InitializeIot () {
257293 auto & thing_manager = iot::ThingManager::GetInstance ();
@@ -270,6 +306,7 @@ class waveshare_amoled_1_8 : public WifiBoard {
270306 InitializeAxp2101 ();
271307 InitializeSpi ();
272308 InitializeSH8601Display ();
309+ InitializeTouch ();
273310 InitializeButtons ();
274311 InitializeIot ();
275312 }
0 commit comments