Skip to content

Commit 7d5237a

Browse files
ZhouKeszk78
authored
add lcd touch for lichuang_dev (#531)
* add lcd touch for lichuang_dev * Update lichuang_dev_board.cc --------- Co-authored-by: zk <[email protected]> Co-authored-by: Xiaoxia <[email protected]>
1 parent 738e170 commit 7d5237a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

main/boards/lichuang-dev/lichuang_dev_board.cc

+40
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
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();

main/idf_component.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
espressif/esp-sr: "^2.0.5"
1818
espressif/button: "^3.3.1"
1919
espressif/knob: "^1.0.0"
20+
espressif/esp_lcd_touch_ft5x06: "~1.0.6"
2021
lvgl/lvgl: "~9.2.2"
2122
esp_lvgl_port: "~2.4.4"
2223
espressif/esp_io_expander_tca95xx_16bit: "^2.0.0"

0 commit comments

Comments
 (0)