Fix the touch initialization issue. (#1497)
Some checks failed
Build Boards / Determine variants to build (push) Has been cancelled
Build Boards / Build ${{ matrix.name }} (push) Has been cancelled

This commit is contained in:
Y1hsiaochunnn 2025-11-28 06:44:59 +08:00 committed by GitHub
parent c87b1eabf4
commit 01a12b325f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,6 +30,10 @@ private:
LcdDisplay *display_; LcdDisplay *display_;
Esp32Camera* camera_ = nullptr; Esp32Camera* camera_ = nullptr;
esp_err_t i2c_device_probe(uint8_t addr) {
return i2c_master_probe(i2c_bus_, addr, 100);
}
void InitializeCodecI2c() { void InitializeCodecI2c() {
// Initialize I2C peripheral // Initialize I2C peripheral
i2c_master_bus_config_t i2c_bus_cfg = { i2c_master_bus_config_t i2c_bus_cfg = {
@ -147,6 +151,19 @@ private:
}; };
esp_lcd_panel_io_handle_t tp_io_handle = NULL; 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_GT911_CONFIG(); esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
if (ESP_OK == i2c_device_probe(ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS)) {
ESP_LOGI(TAG, "Touch panel found at address 0x%02X", ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS);
} else if (ESP_OK == i2c_device_probe(ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP)) {
ESP_LOGI(TAG, "Touch panel found at address 0x%02X", ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP);
tp_io_config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP;
} else {
ESP_LOGE(TAG, "Touch panel not found on I2C bus");
ESP_LOGE(TAG, "Tried addresses: 0x%02X and 0x%02X",
ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS,
ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP);
return;
}
tp_io_config.scl_speed_hz = 400 * 1000; tp_io_config.scl_speed_hz = 400 * 1000;
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_bus_, &tp_io_config, &tp_io_handle)); ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_bus_, &tp_io_config, &tp_io_handle));
ESP_LOGI(TAG, "Initialize touch controller"); ESP_LOGI(TAG, "Initialize touch controller");