diff --git a/components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h b/components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h index db39f1f0..d0b26763 100644 --- a/components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h +++ b/components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h @@ -64,6 +64,8 @@ typedef struct { esp_lcd_touch_interrupt_callback_t interrupt_callback; /*!< User data passed to callback */ void *user_data; + /*!< User data passed to driver */ + void *driver_data; } esp_lcd_touch_config_t; typedef struct { diff --git a/components/lcd_touch/esp_lcd_touch_gt911/README.md b/components/lcd_touch/esp_lcd_touch_gt911/README.md index 7d82bc01..3bdc6c0e 100644 --- a/components/lcd_touch/esp_lcd_touch_gt911/README.md +++ b/components/lcd_touch/esp_lcd_touch_gt911/README.md @@ -25,9 +25,7 @@ Initialization of the touch component. ``` esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); - esp_lcd_touch_io_gt911_config_t tp_gt911_config = { - .dev_addr = io_config.dev_addr, - }; + uint8_t gt911_addr = io_config.dev_addr; esp_lcd_touch_config_t tp_cfg = { .x_max = CONFIG_LCD_HRES, @@ -43,7 +41,7 @@ Initialization of the touch component. .mirror_x = 0, .mirror_y = 0, }, - .user_data = &tp_gt911_config, + .driver_data = >911_addr, }; esp_lcd_touch_handle_t tp; diff --git a/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c b/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c index c8f8d807..b2053fd5 100644 --- a/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c +++ b/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c @@ -87,7 +87,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const /* Save config */ memcpy(&esp_lcd_touch_gt911->config, config, sizeof(esp_lcd_touch_config_t)); - esp_lcd_touch_io_gt911_config_t *gt911_config = (esp_lcd_touch_io_gt911_config_t *)esp_lcd_touch_gt911->config.user_data; + uint8_t *gt911_addr = (uint8_t *)esp_lcd_touch_gt911->config.driver_data; /* Prepare pin for touch controller reset */ if (esp_lcd_touch_gt911->config.rst_gpio_num != GPIO_NUM_NC) { @@ -99,7 +99,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed"); } - if (gt911_config && esp_lcd_touch_gt911->config.rst_gpio_num != GPIO_NUM_NC && esp_lcd_touch_gt911->config.int_gpio_num != GPIO_NUM_NC) { + if (gt911_addr && esp_lcd_touch_gt911->config.rst_gpio_num != GPIO_NUM_NC && esp_lcd_touch_gt911->config.int_gpio_num != GPIO_NUM_NC) { /* Prepare pin for touch controller int */ const gpio_config_t int_gpio_config = { .mode = GPIO_MODE_OUTPUT, @@ -117,13 +117,13 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const /* Select I2C addr, set output high or low */ uint32_t gpio_level; - if (ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP == gt911_config->dev_addr) { + if (ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP == *gt911_addr) { gpio_level = 1; - } else if (ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS == gt911_config->dev_addr) { + } else if (ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS == *gt911_addr) { gpio_level = 0; } else { gpio_level = 0; - ESP_LOGE(TAG, "Addr (0x%X) is invalid", (unsigned int)gt911_config->dev_addr); + ESP_LOGE(TAG, "Addr (0x%X) is invalid", *gt911_addr); } ESP_RETURN_ON_ERROR(gpio_set_level(esp_lcd_touch_gt911->config.int_gpio_num, gpio_level), TAG, "GPIO set level error!"); vTaskDelay(pdMS_TO_TICKS(1)); diff --git a/components/lcd_touch/esp_lcd_touch_gt911/include/esp_lcd_touch_gt911.h b/components/lcd_touch/esp_lcd_touch_gt911/include/esp_lcd_touch_gt911.h index 0e16ae06..9c73fdc5 100644 --- a/components/lcd_touch/esp_lcd_touch_gt911/include/esp_lcd_touch_gt911.h +++ b/components/lcd_touch/esp_lcd_touch_gt911/include/esp_lcd_touch_gt911.h @@ -41,15 +41,6 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const #define ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS (0x5D) #define ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP (0x14) -/** - * @brief GT911 Configuration Type - * - */ -typedef struct { - uint32_t dev_addr; /*!< I2C device address */ - void *user_data; /*!< User data passed to callback */ -} esp_lcd_touch_io_gt911_config_t; - /** * @brief Touch IO configuration structure *