Skip to content

Commit c19c33a

Browse files
Merge pull request #92 from Y1hsiaochunnn/master
Optimize the touch initialization issue
2 parents a12d06d + 52ebf56 commit c19c33a

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

bsp/esp32_p4_wifi6_touch_lcd_7b/esp32_p4_wifi6_touch_lcd_7b.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ esp_err_t bsp_i2c_init(void)
7979
.sda_io_num = BSP_I2C_SDA,
8080
.scl_io_num = BSP_I2C_SCL,
8181
.i2c_port = BSP_I2C_NUM,
82+
.glitch_ignore_cnt = 7,
83+
.flags.enable_internal_pullup = true,
84+
.trans_queue_depth = 0,
8285
};
8386
BSP_ERROR_CHECK_RETURN_ERR(i2c_new_master_bus(&i2c_bus_conf, &i2c_handle));
8487

@@ -99,6 +102,11 @@ i2c_master_bus_handle_t bsp_i2c_get_handle(void)
99102
return i2c_handle;
100103
}
101104

105+
static esp_err_t bsp_i2c_device_probe(uint8_t addr)
106+
{
107+
return i2c_master_probe(i2c_handle, addr, 100);
108+
}
109+
102110
esp_err_t bsp_sdcard_mount(void)
103111
{
104112
const esp_vfs_fat_sdmmc_mount_config_t mount_config = {
@@ -507,7 +515,20 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t
507515
},
508516
};
509517
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
510-
esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
518+
esp_lcd_panel_io_i2c_config_t tp_io_config;
519+
if (ESP_OK == bsp_i2c_device_probe(ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS)) {
520+
ESP_LOGI(TAG, "Touch 0x5d found");
521+
esp_lcd_panel_io_i2c_config_t config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
522+
memcpy(&tp_io_config, &config, sizeof(config));
523+
} else if (ESP_OK == bsp_i2c_device_probe(ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP)) {
524+
ESP_LOGI(TAG, "Touch 0x14 found");
525+
esp_lcd_panel_io_i2c_config_t config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
526+
config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP;
527+
memcpy(&tp_io_config, &config, sizeof(config));
528+
} else {
529+
ESP_LOGE(TAG, "Touch not found");
530+
return ESP_ERR_NOT_FOUND;
531+
}
511532
tp_io_config.scl_speed_hz = CONFIG_BSP_I2C_CLK_SPEED_HZ;
512533
ESP_RETURN_ON_ERROR(esp_lcd_new_panel_io_i2c(i2c_handle, &tp_io_config, &tp_io_handle), TAG, "");
513534
return esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, ret_touch);

bsp/esp32_p4_wifi6_touch_lcd_7b/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ tags:
1616
targets:
1717
- esp32p4
1818
url: https://www.waveshare.com/esp32-p4-wifi6-touch-lcd-7b.htm
19-
version: 1.0.0
19+
version: 1.0.1

display/lcd/esp_lcd_dsi/test_apps/main/test_esp_lcd_dsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#define TEST_LCD_H_RES (1280)
2525
#define TEST_LCD_V_RES (720)
26-
#define TEST_LCD_BIT_PER_PIXEL (16)
26+
#define TEST_LCD_BIT_PER_PIXEL (24)
2727
#define TEST_PIN_NUM_LCD_RST (-1)
2828
#define TEST_PIN_NUM_BK_LIGHT (-1) // set to -1 if not used
2929
#define TEST_LCD_BK_LIGHT_ON_LEVEL (1)

display/lcd/esp_lcd_hx8394/test_apps/main/test_esp_lcd_hx8394.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#define TEST_LCD_H_RES (720)
2626
#define TEST_LCD_V_RES (1280)
2727
#define TEST_LCD_BIT_PER_PIXEL (24)
28-
#define TEST_PIN_NUM_LCD_RST (-1)
29-
#define TEST_PIN_NUM_BK_LIGHT (-1) // set to -1 if not used
28+
#define TEST_PIN_NUM_LCD_RST (27)
29+
#define TEST_PIN_NUM_BK_LIGHT (26) // set to -1 if not used
3030
#define TEST_LCD_BK_LIGHT_ON_LEVEL (1)
3131
#define TEST_LCD_BK_LIGHT_OFF_LEVEL !TEST_LCD_BK_LIGHT_ON_LEVEL
3232
#define TEST_MIPI_DSI_LANE_NUM (2)

0 commit comments

Comments
 (0)