diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 32a2d4a7..4cd2a30f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,11 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks -exclude: '(libraries/ui/)' +exclude: | + (?x)( + .*libraries/ui/.* + | .*.pio/.* + ) repos: - repo: https://github.com/igrr/astyle_py.git rev: v1.0.5 diff --git a/esp_panel_board_custom_conf.h b/esp_panel_board_custom_conf.h index b86014e0..451e039b 100644 --- a/esp_panel_board_custom_conf.h +++ b/esp_panel_board_custom_conf.h @@ -390,13 +390,10 @@ /* For general */ #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST - /* For host */ - #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K - #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) +/* For host */ +# define ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) // SDA pin number #endif /* For panel */ #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. @@ -404,6 +401,7 @@ // - For touchs with multiple addresses, set to 0 or // the address. Like GT911, there are two addresses: // 0x5D(default) and 0x14 +# define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -557,17 +555,15 @@ #define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 /* For host */ #if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST -#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K -#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) +# define ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) // SDA pin number #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST /* For device */ #define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, // the I2C address may be different, and confirmation based on // the actual hardware connection is required +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #endif // ESP_PANEL_BOARD_USE_EXPANDER //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -751,8 +747,8 @@ * 2. Minor version mismatch: May be missing new configurations, recommended to update * 3. Patch version mismatch: No impact on functionality */ -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 #endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM diff --git a/esp_panel_drivers_conf.h b/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/esp_panel_drivers_conf.h +++ b/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/board/board_dynamic_config/esp_panel_drivers_conf.h b/examples/arduino/board/board_dynamic_config/esp_panel_drivers_conf.h index fbe4d5bf..bf0cfd31 100644 --- a/examples/arduino/board/board_dynamic_config/esp_panel_drivers_conf.h +++ b/examples/arduino/board/board_dynamic_config/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/board/board_static_config/esp_panel_board_custom_conf.h b/examples/arduino/board/board_static_config/esp_panel_board_custom_conf.h index b86014e0..451e039b 100644 --- a/examples/arduino/board/board_static_config/esp_panel_board_custom_conf.h +++ b/examples/arduino/board/board_static_config/esp_panel_board_custom_conf.h @@ -390,13 +390,10 @@ /* For general */ #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST - /* For host */ - #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K - #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) +/* For host */ +# define ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) // SDA pin number #endif /* For panel */ #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. @@ -404,6 +401,7 @@ // - For touchs with multiple addresses, set to 0 or // the address. Like GT911, there are two addresses: // 0x5D(default) and 0x14 +# define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -557,17 +555,15 @@ #define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 /* For host */ #if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST -#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K -#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) +# define ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) // SDA pin number #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST /* For device */ #define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, // the I2C address may be different, and confirmation based on // the actual hardware connection is required +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #endif // ESP_PANEL_BOARD_USE_EXPANDER //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -751,8 +747,8 @@ * 2. Minor version mismatch: May be missing new configurations, recommended to update * 3. Patch version mismatch: No impact on functionality */ -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 #endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM diff --git a/examples/arduino/board/board_static_config/esp_panel_drivers_conf.h b/examples/arduino/board/board_static_config/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/board/board_static_config/esp_panel_drivers_conf.h +++ b/examples/arduino/board/board_static_config/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/drivers/lcd/lcd_3wire_spi_rgb/esp_panel_drivers_conf.h b/examples/arduino/drivers/lcd/lcd_3wire_spi_rgb/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/drivers/lcd/lcd_3wire_spi_rgb/esp_panel_drivers_conf.h +++ b/examples/arduino/drivers/lcd/lcd_3wire_spi_rgb/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/drivers/lcd/lcd_mipi_dsi/esp_panel_drivers_conf.h b/examples/arduino/drivers/lcd/lcd_mipi_dsi/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/drivers/lcd/lcd_mipi_dsi/esp_panel_drivers_conf.h +++ b/examples/arduino/drivers/lcd/lcd_mipi_dsi/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/drivers/lcd/lcd_qspi/esp_panel_drivers_conf.h b/examples/arduino/drivers/lcd/lcd_qspi/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/drivers/lcd/lcd_qspi/esp_panel_drivers_conf.h +++ b/examples/arduino/drivers/lcd/lcd_qspi/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/drivers/lcd/lcd_single_rgb/esp_panel_drivers_conf.h b/examples/arduino/drivers/lcd/lcd_single_rgb/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/drivers/lcd/lcd_single_rgb/esp_panel_drivers_conf.h +++ b/examples/arduino/drivers/lcd/lcd_single_rgb/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/drivers/lcd/lcd_spi/esp_panel_drivers_conf.h b/examples/arduino/drivers/lcd/lcd_spi/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/drivers/lcd/lcd_spi/esp_panel_drivers_conf.h +++ b/examples/arduino/drivers/lcd/lcd_spi/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/drivers/touch/touch_i2c/esp_panel_drivers_conf.h b/examples/arduino/drivers/touch/touch_i2c/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/drivers/touch/touch_i2c/esp_panel_drivers_conf.h +++ b/examples/arduino/drivers/touch/touch_i2c/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/drivers/touch/touch_spi/esp_panel_drivers_conf.h b/examples/arduino/drivers/touch/touch_spi/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/drivers/touch/touch_spi/esp_panel_drivers_conf.h +++ b/examples/arduino/drivers/touch/touch_spi/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_board_custom_conf.h b/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_board_custom_conf.h index b86014e0..451e039b 100644 --- a/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_board_custom_conf.h +++ b/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_board_custom_conf.h @@ -390,13 +390,10 @@ /* For general */ #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST - /* For host */ - #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K - #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) +/* For host */ +# define ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) // SDA pin number #endif /* For panel */ #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. @@ -404,6 +401,7 @@ // - For touchs with multiple addresses, set to 0 or // the address. Like GT911, there are two addresses: // 0x5D(default) and 0x14 +# define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -557,17 +555,15 @@ #define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 /* For host */ #if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST -#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K -#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) +# define ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) // SDA pin number #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST /* For device */ #define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, // the I2C address may be different, and confirmation based on // the actual hardware connection is required +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #endif // ESP_PANEL_BOARD_USE_EXPANDER //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -751,8 +747,8 @@ * 2. Minor version mismatch: May be missing new configurations, recommended to update * 3. Patch version mismatch: No impact on functionality */ -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 #endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM diff --git a/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_drivers_conf.h b/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_drivers_conf.h +++ b/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_board_custom_conf.h b/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_board_custom_conf.h index b86014e0..451e039b 100644 --- a/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_board_custom_conf.h +++ b/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_board_custom_conf.h @@ -390,13 +390,10 @@ /* For general */ #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST - /* For host */ - #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K - #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) +/* For host */ +# define ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) // SDA pin number #endif /* For panel */ #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. @@ -404,6 +401,7 @@ // - For touchs with multiple addresses, set to 0 or // the address. Like GT911, there are two addresses: // 0x5D(default) and 0x14 +# define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -557,17 +555,15 @@ #define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 /* For host */ #if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST -#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K -#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) +# define ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) // SDA pin number #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST /* For device */ #define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, // the I2C address may be different, and confirmation based on // the actual hardware connection is required +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #endif // ESP_PANEL_BOARD_USE_EXPANDER //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -751,8 +747,8 @@ * 2. Minor version mismatch: May be missing new configurations, recommended to update * 3. Patch version mismatch: No impact on functionality */ -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 #endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM diff --git a/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_drivers_conf.h b/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_drivers_conf.h +++ b/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_board_custom_conf.h b/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_board_custom_conf.h index b86014e0..451e039b 100644 --- a/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_board_custom_conf.h +++ b/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_board_custom_conf.h @@ -390,13 +390,10 @@ /* For general */ #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST - /* For host */ - #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K - #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) +/* For host */ +# define ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) // SDA pin number #endif /* For panel */ #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. @@ -404,6 +401,7 @@ // - For touchs with multiple addresses, set to 0 or // the address. Like GT911, there are two addresses: // 0x5D(default) and 0x14 +# define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -557,17 +555,15 @@ #define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 /* For host */ #if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST -#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K -#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) +# define ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) // SDA pin number #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST /* For device */ #define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, // the I2C address may be different, and confirmation based on // the actual hardware connection is required +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #endif // ESP_PANEL_BOARD_USE_EXPANDER //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -751,8 +747,8 @@ * 2. Minor version mismatch: May be missing new configurations, recommended to update * 3. Patch version mismatch: No impact on functionality */ -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 #endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM diff --git a/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_drivers_conf.h b/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_drivers_conf.h +++ b/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_board_custom_conf.h b/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_board_custom_conf.h index b86014e0..451e039b 100644 --- a/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_board_custom_conf.h +++ b/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_board_custom_conf.h @@ -390,13 +390,10 @@ /* For general */ #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST - /* For host */ - #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K - #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) +/* For host */ +# define ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) // SDA pin number #endif /* For panel */ #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. @@ -404,6 +401,7 @@ // - For touchs with multiple addresses, set to 0 or // the address. Like GT911, there are two addresses: // 0x5D(default) and 0x14 +# define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -557,17 +555,15 @@ #define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 /* For host */ #if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST -#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K -#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) +# define ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) // SDA pin number #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST /* For device */ #define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, // the I2C address may be different, and confirmation based on // the actual hardware connection is required +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #endif // ESP_PANEL_BOARD_USE_EXPANDER //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -751,8 +747,8 @@ * 2. Minor version mismatch: May be missing new configurations, recommended to update * 3. Patch version mismatch: No impact on functionality */ -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 #endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM diff --git a/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_drivers_conf.h b/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_drivers_conf.h +++ b/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/examples/platformio/lvgl_v8_port/src/esp_panel_board_custom_conf.h b/examples/platformio/lvgl_v8_port/src/esp_panel_board_custom_conf.h index b86014e0..451e039b 100644 --- a/examples/platformio/lvgl_v8_port/src/esp_panel_board_custom_conf.h +++ b/examples/platformio/lvgl_v8_port/src/esp_panel_board_custom_conf.h @@ -390,13 +390,10 @@ /* For general */ #define ESP_PANEL_BOARD_TOUCH_I2C_HOST_ID (0) // Typically set to 0 #if !ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST - /* For host */ - #define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K - #define ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) - #define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) +/* For host */ +# define ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA (8) // SDA pin number #endif /* For panel */ #define ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use the default address. @@ -404,6 +401,7 @@ // - For touchs with multiple addresses, set to 0 or // the address. Like GT911, there are two addresses: // 0x5D(default) and 0x14 +# define ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -557,17 +555,15 @@ #define ESP_PANEL_BOARD_EXPANDER_I2C_HOST_ID (0) // Typically set to 0 /* For host */ #if !ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST -#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) - // Typically set to 400K -#define ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP (1) // 0/1. Typically set to 1 -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) -#define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) +# define ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP (1) // 0/1. Typically set to 1 +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL (18) // SCL pin number +# define ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA (8) // SDA pin number #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST /* For device */ #define ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC, // the I2C address may be different, and confirmation based on // the actual hardware connection is required +#define ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ (400 * 1000) // Typically set to 400K #endif // ESP_PANEL_BOARD_USE_EXPANDER //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -751,8 +747,8 @@ * 2. Minor version mismatch: May be missing new configurations, recommended to update * 3. Patch version mismatch: No impact on functionality */ -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 2 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 #endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM diff --git a/examples/platformio/lvgl_v8_port/src/esp_panel_drivers_conf.h b/examples/platformio/lvgl_v8_port/src/esp_panel_drivers_conf.h index a1cef666..d7d8bd90 100644 --- a/examples/platformio/lvgl_v8_port/src/esp_panel_drivers_conf.h +++ b/examples/platformio/lvgl_v8_port/src/esp_panel_drivers_conf.h @@ -197,6 +197,19 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif // ESP_PANEL_DRIVERS_TOUCH_USE_XPT2046 || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief CST816S specific configurations + */ +#if ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS +/** + * @brief Disable read ID + * + * When enabled, CST816S will not read the ID in the initialization process. This is useful for some cases that the + * failure of reading ID is occurred. + */ +#define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) +#endif // ESP_PANEL_DRIVERS_TOUCH_USE_CST816S || ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// IO Expander Configurations ////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,7 +274,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/idf_component.yml b/idf_component.yml index b3b9e60f..f97c2380 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -4,10 +4,13 @@ url: https://github.com/esp-arduino-libs/ESP32_Display_Panel repository: https://github.com/esp-arduino-libs/ESP32_Display_Panel.git issues: https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues dependencies: - idf: ">=5.1" + idf: ">=5.4" + espressif/esp-lib-utils: version: "0.2.*" public: true - espressif/esp32_io_expander: - version: "1.*" + + ESP32_IO_Expander: + version: "2.*" + override_path: "../ESP32_IO_Expander" public: true diff --git a/src/board/esp_panel_board_default_config.cpp b/src/board/esp_panel_board_default_config.cpp index 9733e64d..b9696889 100644 --- a/src/board/esp_panel_board_default_config.cpp +++ b/src/board/esp_panel_board_default_config.cpp @@ -219,20 +219,18 @@ const BoardConfig ESP_PANEL_BOARD_DEFAULT_CONFIG = { .host = BusI2C::HostPartialConfig{ .sda_io_num = ESP_PANEL_BOARD_TOUCH_I2C_IO_SDA, .scl_io_num = ESP_PANEL_BOARD_TOUCH_I2C_IO_SCL, - .sda_pullup_en = ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP, - .scl_pullup_en = ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP, - .clk_speed = ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ, + .enable_internal_pullup = ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP, }, #endif // ESP_PANEL_BOARD_TOUCH_BUS_SKIP_INIT_HOST // Control Panel #if ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS == 0 - .control_panel = BusI2C::ControlPanelFullConfig - ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(ESP_PANEL_BOARD_TOUCH_CONTROLLER), + .control_panel = BusI2C::ControlPanelFullConfig ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG( + ESP_PANEL_BOARD_TOUCH_CONTROLLER, ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ + ), #else - .control_panel = BusI2C::ControlPanelFullConfig - ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR( - ESP_PANEL_BOARD_TOUCH_CONTROLLER, ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS - ), + .control_panel = BusI2C::ControlPanelFullConfig ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR( + ESP_PANEL_BOARD_TOUCH_CONTROLLER, ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS, ESP_PANEL_BOARD_TOUCH_I2C_CLK_HZ + ), #endif // ESP_PANEL_BOARD_TOUCH_I2C_ADDRESS }, #elif ESP_PANEL_BOARD_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI @@ -326,14 +324,13 @@ const BoardConfig ESP_PANEL_BOARD_DEFAULT_CONFIG = { .host = IO_Expander::HostPartialConfig{ .sda_io_num = ESP_PANEL_BOARD_EXPANDER_I2C_IO_SDA, .scl_io_num = ESP_PANEL_BOARD_EXPANDER_I2C_IO_SCL, - .sda_pullup_en = ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP, - .scl_pullup_en = ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP, - .clk_speed = ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ, + .enable_internal_pullup = ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP, }, #endif // ESP_PANEL_BOARD_EXPANDER_SKIP_INIT_HOST // Device - .device = { + .device = IO_Expander::DevicePartialConfig{ .address = ESP_PANEL_BOARD_EXPANDER_I2C_ADDRESS, + .freq_hz = ESP_PANEL_BOARD_EXPANDER_I2C_CLK_HZ, }, }, }, diff --git a/src/board/esp_panel_board_private.hpp b/src/board/esp_panel_board_private.hpp index a73e20ff..e4ab5b74 100644 --- a/src/board/esp_panel_board_private.hpp +++ b/src/board/esp_panel_board_private.hpp @@ -77,4 +77,20 @@ #endif #endif +/* For backward compatibility */ +#if defined(ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP) && defined(ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP) + #if ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP != ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP + #error "`ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP` and `ESP_PANEL_BOARD_TOUCH_I2C_SCL_PULLUP` must be the same" + #elif !defined(ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP) + #define ESP_PANEL_BOARD_TOUCH_I2C_INTERNAL_PULLUP ESP_PANEL_BOARD_TOUCH_I2C_SDA_PULLUP + #endif +#endif +#if defined(ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP) && defined(ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP) + #if ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP != ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP + #error "`ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP` and `ESP_PANEL_BOARD_EXPANDER_I2C_SCL_PULLUP` must be the same" + #elif !defined(ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP) + #define ESP_PANEL_BOARD_EXPANDER_I2C_INTERNAL_PULLUP ESP_PANEL_BOARD_EXPANDER_I2C_SDA_PULLUP + #endif +#endif + // *INDENT-ON* diff --git a/src/drivers/bus/esp_panel_bus_i2c.cpp b/src/drivers/bus/esp_panel_bus_i2c.cpp index e4fe1504..cc50051f 100644 --- a/src/drivers/bus/esp_panel_bus_i2c.cpp +++ b/src/drivers/bus/esp_panel_bus_i2c.cpp @@ -23,16 +23,15 @@ void BusI2C::Config::convertPartialToFull() printHostConfig(); #endif // ESP_UTILS_LOG_LEVEL_DEBUG auto &config = std::get(host.value()); - host = i2c_config_t{ - .mode = I2C_MODE_MASTER, - .sda_io_num = config.sda_io_num, - .scl_io_num = config.scl_io_num, - .sda_pullup_en = config.sda_pullup_en, - .scl_pullup_en = config.scl_pullup_en, - .master = { - .clk_speed = static_cast(config.clk_speed), + host = HostFullConfig{ + .i2c_port = static_cast(host_id), + .sda_io_num = static_cast(config.sda_io_num), + .scl_io_num = static_cast(config.scl_io_num), + .clk_source = I2C_CLK_SRC_DEFAULT, + .glitch_ignore_cnt = 7, + .flags = { + .enable_internal_pullup = config.enable_internal_pullup, }, - .clk_flags = I2C_SCLK_SRC_FLAG_FOR_NOMAL, }; } @@ -51,40 +50,39 @@ void BusI2C::Config::printHostConfig() const if (isHostConfigValid() && std::holds_alternative(host.value())) { auto &config = std::get(host.value()); ESP_UTILS_LOGI( - "\n\t{Host config}[full]" - "\n\t\t-> [host_id]: %d" - "\n\t\t-> [mode]: %d" - "\n\t\t-> [sda_io_num]: %d" - "\n\t\t-> [scl_io_num]: %d" - "\n\t\t-> [sda_pullup_en]: %d" - "\n\t\t-> [scl_pullup_en]: %d" - "\n\t\t-> [master.clk_speed]: %d" - "\n\t\t-> [clk_flags]: %d" - , static_cast(host_id) - , static_cast(config.mode) + "\n\t{Host config}[full]\n" + "\t\t-> [i2c_port]: %d\n" + "\t\t-> [sda_io_num]: %d\n" + "\t\t-> [scl_io_num]: %d\n" + "\t\t-> [clk_source]: %d\n" + "\t\t-> [glitch_ignore_cnt]: %d\n" + "\t\t-> [intr_priority]: %d\n" + "\t\t-> [trans_queue_depth]: %d\n" + "\t\t-> [flags]:\n" + "\t\t\t-> [enable_internal_pullup]: %d\n" + "\t\t\t-> [allow_pd]: %d\n" + , static_cast(config.i2c_port) , static_cast(config.sda_io_num) , static_cast(config.scl_io_num) - , static_cast(config.sda_pullup_en) - , static_cast(config.scl_pullup_en) - , static_cast(config.master.clk_speed) - , static_cast(config.clk_flags) + , static_cast(config.clk_source) + , static_cast(config.glitch_ignore_cnt) + , static_cast(config.intr_priority) + , static_cast(config.trans_queue_depth) + , static_cast(config.flags.enable_internal_pullup) + , static_cast(config.flags.allow_pd) ); } else { auto &config = std::get(host.value()); ESP_UTILS_LOGI( - "\n\t{Host config}[partial]" - "\n\t\t-> [host_id]: %d" - "\n\t\t-> [sda_io_num]: %d" - "\n\t\t-> [scl_io_num]: %d" - "\n\t\t-> [sda_pullup_en]: %d" - "\n\t\t-> [scl_pullup_en]: %d" - "\n\t\t-> [clk_speed]: %d" + "\n\t{Host config}[partial]\n" + "\t\t-> [id]: %d\n" + "\t\t-> [sda_io_num]: %d\n" + "\t\t-> [scl_io_num]: %d\n" + "\t\t-> [enable_internal_pullup]: %d\n" , static_cast(host_id) , static_cast(config.sda_io_num) , static_cast(config.scl_io_num) - , static_cast(config.sda_pullup_en) - , static_cast(config.scl_pullup_en) - , static_cast(config.clk_speed) + , static_cast(config.enable_internal_pullup) ); } @@ -142,17 +140,16 @@ bool BusI2C::configI2C_HostSkipInit() return true; } -bool BusI2C::configI2C_PullupEnable(bool sda_pullup_en, bool scl_pullup_en) +bool BusI2C::configI2C_PullupEnable(bool enable) { ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS(); ESP_UTILS_CHECK_FALSE_RETURN(!isOverState(State::INIT), false, "Should be called before `init()`"); ESP_UTILS_CHECK_FALSE_RETURN(!isHostSkipInit(), false, "Host is skipped initialization"); - ESP_UTILS_LOGD("Param: sda_pullup_en(%d), scl_pullup_en(%d)", sda_pullup_en, scl_pullup_en); + ESP_UTILS_LOGD("Param: enable(%d)", enable); auto &host_config = getHostFullConfig(); - host_config.sda_pullup_en = sda_pullup_en ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE; - host_config.scl_pullup_en = scl_pullup_en ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE; + host_config.flags.enable_internal_pullup = enable; ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS(); @@ -167,7 +164,7 @@ bool BusI2C::configI2C_FreqHz(uint32_t hz) ESP_UTILS_CHECK_FALSE_RETURN(!isHostSkipInit(), false, "Host is skipped initialization"); ESP_UTILS_LOGD("Param: hz(%d)", static_cast(hz)); - getHostFullConfig().master.clk_speed = hz; + getControlPanelFullConfig().scl_speed_hz = hz; ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS(); @@ -307,19 +304,12 @@ bool BusI2C::begin() } // Create the control panel -#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0) ESP_UTILS_CHECK_ERROR_RETURN( esp_lcd_new_panel_io_i2c( - reinterpret_cast(host_id), &getControlPanelFullConfig(), &control_panel - ), false, "create control panel failed" - ); -#else - ESP_UTILS_CHECK_ERROR_RETURN( - esp_lcd_new_panel_io_i2c_v1( - static_cast(host_id), &getControlPanelFullConfig(), &control_panel + reinterpret_cast(_host->getNativeHandle()), &getControlPanelFullConfig(), + &control_panel ), false, "create control panel failed" ); -#endif // ESP_IDF_VERSION ESP_UTILS_LOGD("Create control panel @%p", control_panel); setState(State::BEGIN); diff --git a/src/drivers/bus/esp_panel_bus_i2c.hpp b/src/drivers/bus/esp_panel_bus_i2c.hpp index 3069fb54..82b6ed58 100644 --- a/src/drivers/bus/esp_panel_bus_i2c.hpp +++ b/src/drivers/bus/esp_panel_bus_i2c.hpp @@ -9,8 +9,9 @@ #include #include #include -#include "driver/i2c.h" +#include "driver/i2c_master.h" #include "esp_panel_types.h" +#include "esp_lcd_io_i2c.h" #include "utils/esp_panel_utils_cxx.hpp" #include "esp_panel_bus_conf_internal.h" #include "esp_panel_bus.hpp" @@ -34,22 +35,19 @@ class BusI2C: public Bus { .type = ESP_PANEL_BUS_TYPE_I2C, .name = "I2C", }; - static constexpr int I2C_HOST_ID_DEFAULT = static_cast(I2C_NUM_0); - static constexpr int I2C_CLK_SPEED_DEFAULT = 400 * 1000; - + static constexpr int I2C_HOST_ID_DEFAULT = static_cast(I2C_NUM_0); + static constexpr int I2C_CLK_SPEED_DEFAULT = 400 * 1000; + static constexpr bool I2C_ENABLE_INTERNAL_PULLUP_DEFAULT = true; struct HostPartialConfig { - int sda_io_num = -1; ///< GPIO number for SDA signal - int scl_io_num = -1; ///< GPIO number for SCL signal - bool sda_pullup_en = GPIO_PULLUP_ENABLE; ///< Enable internal pullup for SDA - bool scl_pullup_en = GPIO_PULLUP_ENABLE; ///< Enable internal pullup for SCL - int clk_speed = I2C_CLK_SPEED_DEFAULT; ///< I2C clock frequency in Hz + int sda_io_num = -1; /*!< GPIO number of I2C SDA signal */ + int scl_io_num = -1; /*!< GPIO number of I2C SCL signal */ + bool enable_internal_pullup = I2C_ENABLE_INTERNAL_PULLUP_DEFAULT; /*!< Enable internal pullups */ }; - using HostFullConfig = i2c_config_t; + using HostFullConfig = i2c_master_bus_config_t; + using HostConfig = std::variant; using ControlPanelFullConfig = esp_lcd_panel_io_i2c_config_t; - - using HostConfig = std::variant; using ControlPanelConfig = ControlPanelFullConfig; /** @@ -151,15 +149,24 @@ class BusI2C: public Bus { */ bool configI2C_HostSkipInit(); + // /** + // * @brief Configure I2C internal pullup + // * + // * @param[in] sda_pullup_en Enable internal pullup for SDA + // * @param[in] scl_pullup_en Enable internal pullup for SCL + // * @return `true` if configuration succeeds, `false` otherwise + // * @note This function should be called before `init()` + // */ + // bool configI2C_PullupEnable(bool sda_pullup_en, bool scl_pullup_en); + /** * @brief Configure I2C internal pullup * - * @param[in] sda_pullup_en Enable internal pullup for SDA - * @param[in] scl_pullup_en Enable internal pullup for SCL + * @param[in] enable Enable internal pullup * @return `true` if configuration succeeds, `false` otherwise * @note This function should be called before `init()` */ - bool configI2C_PullupEnable(bool sda_pullup_en, bool scl_pullup_en); + bool configI2C_PullupEnable(bool enable); /** * @brief Configure I2C clock frequency @@ -273,7 +280,7 @@ class BusI2C: public Bus { [[deprecated("Use `configI2C_PullupEnable()` instead")]] void configI2cPullupEnable(bool sda_pullup_en, bool scl_pullup_en) { - configI2C_PullupEnable(sda_pullup_en, scl_pullup_en); + configI2C_PullupEnable(sda_pullup_en); } /** diff --git a/src/drivers/host/esp_panel_host.hpp b/src/drivers/host/esp_panel_host.hpp index afba8e2d..1ad805d7 100644 --- a/src/drivers/host/esp_panel_host.hpp +++ b/src/drivers/host/esp_panel_host.hpp @@ -27,7 +27,9 @@ class Host { /** * @brief Host handle type definition */ - using HostHandle = void *; + using NativeHandle = void *; + + using HostHandle [[deprecated("Deprecated, use `NativeHandle` instead")]] = NativeHandle; /** * @brief Driver state enumeration @@ -38,39 +40,12 @@ class Host { }; /** - * @brief Get the number of instances - * - * @return Number of instances - */ - static int getInstanceCount() - { - return _instances.size(); - } - - /** - * @brief Get a instance of the host - * - * @param[in] id Host ID - * @param[in] config Host configuration - * @return Shared pointer to the derived class instance, nullptr if failed - */ - static std::shared_ptr getInstance(int id, const Config &config); - - /** - * @brief Get a instance of the host - * - * @param[in] id Host ID - * @return Shared pointer to the derived class instance, nullptr if failed + * @brief Delete copy constructor and assignment operator */ - static std::shared_ptr getInstance(int id); - - /** - * @brief Try to release the instance - * - * @param[in] id Host ID - * @return `true` if successful, `false` otherwise - */ - static bool tryReleaseInstance(int id); + Host(const Host &) = delete; + Host &operator=(const Host &) = delete; + Host(Host &&) = delete; + Host &operator=(Host &&) = delete; /** * @brief Virtual destructor @@ -91,17 +66,17 @@ class Host { */ int getID() const { - return _id; + return id_; } /** - * @brief Get the handle of the host + * @brief Get the native handle of the host * * @return Host handle */ - HostHandle getHandle() const + NativeHandle getNativeHandle() const { - return host_handle; + return handle_; } /** @@ -112,9 +87,44 @@ class Host { */ bool isOverState(State state) { - return (_state >= state); + return (state_ >= state); } + /** + * @brief Get the number of instances + * + * @return Number of instances + */ + static int getInstanceCount() + { + return instances_.size(); + } + + /** + * @brief Get a instance of the host + * + * @param[in] id Host ID + * @param[in] config Host configuration + * @return Shared pointer to the derived class instance, nullptr if failed + */ + static std::shared_ptr getInstance(int id, const Config &config); + + /** + * @brief Get a instance of the host + * + * @param[in] id Host ID + * @return Shared pointer to the derived class instance, nullptr if failed + */ + static std::shared_ptr getInstance(int id); + + /** + * @brief Try to release the instance + * + * @param[in] id Host ID + * @return `true` if successful, `false` otherwise + */ + static bool tryReleaseInstance(int id); + protected: /** * @brief Protected constructor for derived classes @@ -122,7 +132,7 @@ class Host { * @param[in] id Host ID * @param[in] config Host configuration */ - Host(int id, const Config &config): config(config), _id(id) {} + Host(int id, const Config &config): config_(config), id_(id) {} /** * @brief Set driver state @@ -131,11 +141,11 @@ class Host { */ void setState(State state) { - _state = state; + state_ = state; } - Config config = {}; /*!< Host configuration */ - HostHandle host_handle = nullptr; /*!< Host handle */ + Config config_ = {}; /*!< Host configuration */ + NativeHandle handle_ = nullptr; /*!< Host native handle */ private: /** @@ -146,9 +156,10 @@ class Host { */ virtual bool calibrateConfig(const Config &config) = 0; - int _id = -1; /*!< Host ID */ - State _state = State::DEINIT; /*!< Current driver state */ - inline static std::array, N> _instances; /*!< Array of host instances */ + int id_ = -1; /*!< Host ID */ + State state_ = State::DEINIT; /*!< Current driver state */ + + inline static std::array, N> instances_; /*!< Array of host instances */ }; template @@ -157,10 +168,10 @@ bool Host::tryReleaseInstance(int id) ESP_UTILS_LOG_TRACE_ENTER(); ESP_UTILS_LOGD("Param: id(%d)", id); - ESP_UTILS_CHECK_FALSE_RETURN((size_t)id < _instances.size(), false, "Invalid ID"); + ESP_UTILS_CHECK_FALSE_RETURN((size_t)id < instances_.size(), false, "Invalid ID"); - if ((_instances[id] != nullptr) && (_instances[id].use_count() == 1)) { - _instances[id] = nullptr; + if ((instances_[id] != nullptr) && (instances_[id].use_count() == 1)) { + instances_[id] = nullptr; ESP_UTILS_LOGD("Release host(%d)", id); } @@ -175,26 +186,26 @@ std::shared_ptr Host::getInstance(int id, const Con ESP_UTILS_LOG_TRACE_ENTER(); ESP_UTILS_LOGD("Param: id(%d), config(@%p)", id, &config); - ESP_UTILS_CHECK_FALSE_RETURN((size_t)id < _instances.size(), nullptr, "Invalid host ID"); + ESP_UTILS_CHECK_FALSE_RETURN((size_t)id < instances_.size(), nullptr, "Invalid host ID"); - if (_instances[id] == nullptr) { + if (instances_[id] == nullptr) { ESP_UTILS_CHECK_EXCEPTION_RETURN( - (_instances[id] = utils::make_shared(id, config)), nullptr, "Create instance failed" + (instances_[id] = utils::make_shared(id, config)), nullptr, "Create instance failed" ); - ESP_UTILS_LOGD("No instance exist, create new one(@%p)", _instances[id].get()); + ESP_UTILS_LOGD("No instance exist, create new one(@%p)", instances_[id].get()); } else { - ESP_UTILS_LOGD("Instance exist(@%p)", _instances[id].get()); + ESP_UTILS_LOGD("Instance exist(@%p)", instances_[id].get()); Config new_config = config; ESP_UTILS_CHECK_FALSE_RETURN( - _instances[id]->calibrateConfig(new_config), nullptr, + instances_[id]->calibrateConfig(new_config), nullptr, "Calibrate configuration failed, attempt to configure host with a incompatible configuration" ); } ESP_UTILS_LOG_TRACE_EXIT(); - return _instances[id]; + return instances_[id]; } template @@ -203,11 +214,11 @@ std::shared_ptr Host::getInstance(int id) ESP_UTILS_LOG_TRACE_ENTER(); ESP_UTILS_LOGD("Param: id(%d)", id); - ESP_UTILS_CHECK_FALSE_RETURN((size_t)id < _instances.size(), nullptr, "Invalid host ID"); + ESP_UTILS_CHECK_FALSE_RETURN((size_t)id < instances_.size(), nullptr, "Invalid host ID"); ESP_UTILS_LOG_TRACE_EXIT(); - return _instances[id]; + return instances_[id]; } } // namespace esp_panel::drivers diff --git a/src/drivers/host/esp_panel_host_i2c.cpp b/src/drivers/host/esp_panel_host_i2c.cpp index 5f244246..7f000615 100644 --- a/src/drivers/host/esp_panel_host_i2c.cpp +++ b/src/drivers/host/esp_panel_host_i2c.cpp @@ -14,11 +14,10 @@ HostI2C::~HostI2C() ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS(); if (isOverState(State::BEGIN)) { - int id = getID(); ESP_UTILS_CHECK_ERROR_EXIT( - i2c_driver_delete(static_cast(id)), "Delete I2C host(%d) failed", id + i2c_del_master_bus(static_cast(handle_)), "I2C driver delete failed" ); - ESP_UTILS_LOGD("Delete I2C host(%d)", id); + ESP_UTILS_LOGD("Delete I2C host(%d)", getID()); setState(State::DEINIT); } @@ -35,14 +34,11 @@ bool HostI2C::begin() } { - int id = getID(); ESP_UTILS_CHECK_ERROR_RETURN( - i2c_param_config(static_cast(id), &config), false, "I2C param config failed" + i2c_new_master_bus(&config_, reinterpret_cast(&handle_)), false, + "I2C new master bus failed" ); - ESP_UTILS_CHECK_ERROR_RETURN( - i2c_driver_install(static_cast(id), config.mode, 0, 0, 0), false, "I2C driver install failed" - ); - ESP_UTILS_LOGD("Initialize I2C host(%d)", id); + ESP_UTILS_LOGD("Initialize I2C host(%d)", getID()); } setState(State::BEGIN); @@ -53,18 +49,52 @@ bool HostI2C::begin() return true; } -bool HostI2C::calibrateConfig(const i2c_config_t &config) +bool HostI2C::calibrateConfig(const i2c_master_bus_config_t &config) { - if (memcmp(&config, &this->config, sizeof(i2c_config_t))) { + if (memcmp(&config, &this->config_, sizeof(i2c_master_bus_config_t))) { ESP_UTILS_LOGI( - "Original config: mode(%d), sda_io_num(%d), scl_io_num(%d), sda_pullup_en(%d), scl_pullup_en(%d)," - "clk_speed(%d)", this->config.mode, this->config.sda_io_num, this->config.scl_io_num, - this->config.sda_pullup_en, this->config.scl_pullup_en, static_cast(this->config.master.clk_speed) + "\n{Original config}\n" + "\t- [i2c_port]: %d\n" + "\t- [sda_io_num]: %d\n" + "\t- [scl_io_num]: %d\n" + "\t- [clk_source]: %d\n" + "\t- [glitch_ignore_cnt]: %d\n" + "\t- [intr_priority]: %d\n" + "\t- [trans_queue_depth]: %d\n" + "\t- {flags}\n" + "\t\t- [enable_internal_pullup]: %d\n" + "\t\t- [allow_pd]: %d\n" + , static_cast(this->config_.i2c_port) + , static_cast(this->config_.sda_io_num) + , static_cast(this->config_.scl_io_num) + , static_cast(this->config_.clk_source) + , static_cast(this->config_.glitch_ignore_cnt) + , static_cast(this->config_.intr_priority) + , static_cast(this->config_.trans_queue_depth) + , static_cast(this->config_.flags.enable_internal_pullup) + , static_cast(this->config_.flags.allow_pd) ); ESP_UTILS_LOGI( - "New config: mode(%d), sda_io_num(%d), scl_io_num(%d), sda_pullup_en(%d), scl_pullup_en(%d), clk_speed(%d)", - config.mode, config.sda_io_num, config.scl_io_num, config.sda_pullup_en, config.scl_pullup_en, - static_cast(config.master.clk_speed) + "\n{New config}\n" + "\t- [i2c_port]: %d\n" + "\t- [sda_io_num]: %d\n" + "\t- [scl_io_num]: %d\n" + "\t- [clk_source]: %d\n" + "\t- [glitch_ignore_cnt]: %d\n" + "\t- [intr_priority]: %d\n" + "\t- [trans_queue_depth]: %d\n" + "\t- {flags}\n" + "\t\t- [enable_internal_pullup]: %d\n" + "\t\t- [allow_pd]: %d\n" + , static_cast(config.i2c_port) + , static_cast(config.sda_io_num) + , static_cast(config.scl_io_num) + , static_cast(config.clk_source) + , static_cast(config.glitch_ignore_cnt) + , static_cast(config.intr_priority) + , static_cast(config.trans_queue_depth) + , static_cast(config.flags.enable_internal_pullup) + , static_cast(config.flags.allow_pd) ); ESP_UTILS_CHECK_FALSE_RETURN(false, false, "Config mismatch"); } diff --git a/src/drivers/host/esp_panel_host_i2c.hpp b/src/drivers/host/esp_panel_host_i2c.hpp index 79984ada..8910bbc4 100644 --- a/src/drivers/host/esp_panel_host_i2c.hpp +++ b/src/drivers/host/esp_panel_host_i2c.hpp @@ -6,7 +6,7 @@ #pragma once -#include "driver/i2c.h" +#include "driver/i2c_master.h" #include "esp_panel_host.hpp" namespace esp_panel::drivers { @@ -14,7 +14,7 @@ namespace esp_panel::drivers { /** * @brief I2C bus host class */ -class HostI2C : public Host(I2C_NUM_MAX)> { +class HostI2C : public Host(I2C_NUM_MAX)> { public: /* Add friend class to allow them to access the private member */ template @@ -41,8 +41,8 @@ class HostI2C : public Host(I2C_NUM_MAX) * @param[in] id Host ID * @param[in] config Host configuration */ - HostI2C(int id, const i2c_config_t &config): - Host(I2C_NUM_MAX)>(id, config) {} + HostI2C(int id, const i2c_master_bus_config_t &config): + Host(I2C_NUM_MAX)>(id, config) {} /** * @brief Calibrate configuration when host already exists @@ -50,7 +50,7 @@ class HostI2C : public Host(I2C_NUM_MAX) * @param[in] config New configuration * @return `true` if successful, `false` otherwise */ - bool calibrateConfig(const i2c_config_t &config) override; + bool calibrateConfig(const i2c_master_bus_config_t &config) override; }; } // namespace esp_panel::drivers diff --git a/src/drivers/host/esp_panel_host_spi.cpp b/src/drivers/host/esp_panel_host_spi.cpp index 262de305..8ac04a1c 100644 --- a/src/drivers/host/esp_panel_host_spi.cpp +++ b/src/drivers/host/esp_panel_host_spi.cpp @@ -37,7 +37,7 @@ bool HostSPI::begin() { int id = getID(); ESP_UTILS_CHECK_ERROR_RETURN( - spi_bus_initialize(static_cast(id), &config, SPI_DMA_CH_AUTO), false, + spi_bus_initialize(static_cast(id), &config_, SPI_DMA_CH_AUTO), false, "SPI host(%d) initialize failed", id ); ESP_UTILS_LOGD("Initialize SPI host(%d)", id); @@ -57,30 +57,47 @@ bool HostSPI::calibrateConfig(const spi_bus_config_t &config) // Keep the compatibility between SPI and QSPI if (temp_config.miso_io_num < 0) { - temp_config.miso_io_num = this->config.miso_io_num; - } else if (this->config.miso_io_num < 0) { - this->config.miso_io_num = temp_config.miso_io_num; + temp_config.miso_io_num = this->config_.miso_io_num; + } else if (this->config_.miso_io_num < 0) { + this->config_.miso_io_num = temp_config.miso_io_num; } if (temp_config.quadwp_io_num < 0) { - temp_config.quadwp_io_num = this->config.quadwp_io_num; - } else if (this->config.quadwp_io_num < 0) { - this->config.quadwp_io_num = temp_config.quadwp_io_num; + temp_config.quadwp_io_num = this->config_.quadwp_io_num; + } else if (this->config_.quadwp_io_num < 0) { + this->config_.quadwp_io_num = temp_config.quadwp_io_num; } if (temp_config.quadhd_io_num < 0) { - temp_config.quadhd_io_num = this->config.quadhd_io_num; - } else if (this->config.quadhd_io_num < 0) { - this->config.quadhd_io_num = temp_config.quadhd_io_num; + temp_config.quadhd_io_num = this->config_.quadhd_io_num; + } else if (this->config_.quadhd_io_num < 0) { + this->config_.quadhd_io_num = temp_config.quadhd_io_num; } - if (memcmp(&config, &this->config, sizeof(spi_bus_config_t))) { + if (memcmp(&config, &this->config_, sizeof(spi_bus_config_t))) { ESP_UTILS_LOGI( - "Original config: mosi_io_num(%d), miso_io_num(%d), sclk_io_num(%d), quadwp_io_num(%d), quadhd_io_num(%d)", - this->config.mosi_io_num, this->config.miso_io_num, this->config.sclk_io_num, - this->config.quadwp_io_num, this->config.quadhd_io_num + "\n{Original config}\n" + "\t- mosi_io_num: %d\n" + "\t- miso_io_num: %d\n" + "\t- sclk_io_num: %d\n" + "\t- quadwp_io_num: %d\n" + "\t- quadhd_io_num: %d\n" + , this->config_.mosi_io_num + , this->config_.miso_io_num + , this->config_.sclk_io_num + , this->config_.quadwp_io_num + , this->config_.quadhd_io_num ); ESP_UTILS_LOGI( - "New config: mosi_io_num(%d), miso_io_num(%d), sclk_io_num(%d), quadwp_io_num(%d), quadhd_io_num(%d)", - config.mosi_io_num, config.miso_io_num, config.sclk_io_num, config.quadwp_io_num, config.quadhd_io_num + "\n{New config}\n" + "\t- mosi_io_num: %d\n" + "\t- miso_io_num: %d\n" + "\t- sclk_io_num: %d\n" + "\t- quadwp_io_num: %d\n" + "\t- quadhd_io_num: %d\n" + , temp_config.mosi_io_num + , temp_config.miso_io_num + , temp_config.sclk_io_num + , temp_config.quadwp_io_num + , temp_config.quadhd_io_num ); ESP_UTILS_CHECK_FALSE_RETURN(false, false, "Config mismatch"); } diff --git a/src/drivers/io_expander/esp_panel_io_expander.hpp b/src/drivers/io_expander/esp_panel_io_expander.hpp index 140c60d9..7fece3e5 100644 --- a/src/drivers/io_expander/esp_panel_io_expander.hpp +++ b/src/drivers/io_expander/esp_panel_io_expander.hpp @@ -5,7 +5,7 @@ */ #pragma once -#include "chip/esp_expander_base.hpp" +#include "esp_expander_base.hpp" #include "esp_panel_io_expander_conf_internal.h" namespace esp_panel::drivers { @@ -27,6 +27,7 @@ class IO_Expander { */ using Config = esp_expander::Base::Config; using HostPartialConfig = esp_expander::Base::HostPartialConfig; + using DevicePartialConfig = esp_expander::Base::DevicePartialConfig; /** * @brief Construct a new IO expander device diff --git a/src/drivers/io_expander/esp_panel_io_expander_adapter.hpp b/src/drivers/io_expander/esp_panel_io_expander_adapter.hpp index 521ffda8..97631717 100644 --- a/src/drivers/io_expander/esp_panel_io_expander_adapter.hpp +++ b/src/drivers/io_expander/esp_panel_io_expander_adapter.hpp @@ -104,10 +104,10 @@ bool IO_ExpanderAdapter::init() // Skip host initialization first and do it later T::configHostSkipInit(true); - ESP_UTILS_CHECK_FALSE_RETURN(T::init(), false, "Init base failed"); - // Since the host full configuration is converted from the partial configuration, we need to call `init` to // get the full configuration + ESP_UTILS_CHECK_FALSE_RETURN(T::init(), false, "Init base failed"); + if (!this->IO_Expander::isSkipInitHost()) { ESP_UTILS_CHECK_FALSE_RETURN( std::holds_alternative(this->getConfig().host.value()), @@ -156,6 +156,8 @@ bool IO_ExpanderAdapter::del() { ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS(); + ESP_UTILS_CHECK_FALSE_RETURN(T::del(), false, "Delete base failed"); + if (_host != nullptr) { _host = nullptr; int host_id = this->getConfig().host_id; @@ -164,8 +166,6 @@ bool IO_ExpanderAdapter::del() ); } - ESP_UTILS_CHECK_FALSE_RETURN(T::del(), false, "Delete base failed"); - ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS(); return true; diff --git a/src/drivers/touch/esp_panel_touch.hpp b/src/drivers/touch/esp_panel_touch.hpp index 4c5bcd2e..1f3894c7 100644 --- a/src/drivers/touch/esp_panel_touch.hpp +++ b/src/drivers/touch/esp_panel_touch.hpp @@ -740,12 +740,13 @@ using ESP_PanelTouch [[deprecated("Use `esp_panel::drivers::Touch` instead")]] = * @brief This macro is used to generate the I2C control panel configuration according to the touch panel name. * * @param[in] name Touch panel name + * @param[in] freq_hz I2C clock frequency in Hz * * Taking GT911 as an example, the following is the actual code after macro expansion: - * ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(GT911) => ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG() + * ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(GT911, 400000) => ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(400000) */ -#define _ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(name) ESP_LCD_TOUCH_IO_I2C_ ## name ## _CONFIG() -#define ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(name) _ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(name) +#define _ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_NG(name, freq_hz) ESP_LCD_TOUCH_IO_I2C_ ## name ## _CONFIG(freq_hz) +#define ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_NG(name, freq_hz) _ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_NG(name, freq_hz) /** * @brief This macro is used to generate the I2C control panel configuration according to the touch panel name and @@ -753,14 +754,26 @@ using ESP_PanelTouch [[deprecated("Use `esp_panel::drivers::Touch` instead")]] = * * @param[in] name Touch panel name * @param[in] addr I2C address of the touch panel + * @param[in] freq_hz I2C clock frequency in Hz * * Taking GT911 as an example, the following is the actual code after macro expansion: - * ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR(GT911, 0x14) => ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG_WITH_ADDR(0x14) + * ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR(GT911, 0x14, 400000) => ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG_WITH_ADDR(0x14, 400000) + */ +#define _ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR_NG(name, addr, freq_hz) \ + ESP_LCD_TOUCH_IO_I2C_ ## name ## _CONFIG_WITH_ADDR(addr, freq_hz) +#define ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR_NG(name, addr, freq_hz) \ + _ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR_NG(name, addr, freq_hz) + +/** + * @brief This macro is deprecated, use `ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_NG()` instead + */ +#define ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(name) ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_NG(name, 400000) + +/** + * @brief This macro is deprecated, use `ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR_NG()` instead */ -#define _ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR(name, addr) \ - ESP_LCD_TOUCH_IO_I2C_ ## name ## _CONFIG_WITH_ADDR(addr) #define ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR(name, addr) \ - _ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR(name, addr) + ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG_WITH_ADDR_NG(name, addr, 400000) /** * @brief This macro is used to generate the SPI control panel configuration according to the touch panel name. diff --git a/src/drivers/touch/esp_panel_touch_conf_internal.h b/src/drivers/touch/esp_panel_touch_conf_internal.h index 28659aaf..9c37c106 100644 --- a/src/drivers/touch/esp_panel_touch_conf_internal.h +++ b/src/drivers/touch/esp_panel_touch_conf_internal.h @@ -197,6 +197,14 @@ #define ESP_PANEL_DRIVERS_TOUCH_XPT2046_ENABLE_LOCKING (0) #endif #endif + + #ifndef ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID + #ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID + #define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID CONFIG_ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID + #else + #define ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID (0) + #endif + #endif #endif /** diff --git a/src/drivers/touch/port/esp_lcd_touch_axs15231b.h b/src/drivers/touch/port/esp_lcd_touch_axs15231b.h index 347d8713..21b8dd97 100644 --- a/src/drivers/touch/port/esp_lcd_touch_axs15231b.h +++ b/src/drivers/touch/port/esp_lcd_touch_axs15231b.h @@ -43,7 +43,7 @@ esp_err_t esp_lcd_touch_new_i2c_axs15231b(const esp_lcd_panel_io_handle_t io, co * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_AXS15231B_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_AXS15231B_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_AXS15231B_ADDRESS, \ .control_phase_bytes = 1, \ @@ -52,7 +52,8 @@ esp_err_t esp_lcd_touch_new_i2c_axs15231b(const esp_lcd_panel_io_handle_t io, co .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_chsc6540.c b/src/drivers/touch/port/esp_lcd_touch_chsc6540.c index f6fe160d..de99cb76 100644 --- a/src/drivers/touch/port/esp_lcd_touch_chsc6540.c +++ b/src/drivers/touch/port/esp_lcd_touch_chsc6540.c @@ -13,7 +13,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" -#include "driver/i2c.h" #include "esp_system.h" #include "esp_err.h" #include "esp_log.h" diff --git a/src/drivers/touch/port/esp_lcd_touch_chsc6540.h b/src/drivers/touch/port/esp_lcd_touch_chsc6540.h index 513a6c19..9e41d07a 100644 --- a/src/drivers/touch/port/esp_lcd_touch_chsc6540.h +++ b/src/drivers/touch/port/esp_lcd_touch_chsc6540.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -43,7 +43,7 @@ esp_err_t esp_lcd_touch_new_i2c_chsc6540(const esp_lcd_panel_io_handle_t io, con * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_CHSC6540_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_CHSC6540_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_CHSC6540_ADDRESS, \ .control_phase_bytes = 1, \ @@ -52,7 +52,8 @@ esp_err_t esp_lcd_touch_new_i2c_chsc6540(const esp_lcd_panel_io_handle_t io, con .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_cst816s.c b/src/drivers/touch/port/esp_lcd_touch_cst816s.c index 11b4335b..3876f4c6 100644 --- a/src/drivers/touch/port/esp_lcd_touch_cst816s.c +++ b/src/drivers/touch/port/esp_lcd_touch_cst816s.c @@ -24,6 +24,10 @@ #include "esp_utils_helpers.h" #include "esp_lcd_touch_cst816s.h" +#if ESP_PANEL_DRIVERS_TOUCH_CST816S_DISABLE_READ_ID +# define CONFIG_ESP_LCD_TOUCH_CST816S_DISABLE_READ_ID 1 +#endif + #define POINT_NUM_MAX (1) #define DATA_START_REG (0x02) @@ -38,7 +42,9 @@ static esp_err_t del(esp_lcd_touch_handle_t tp); static esp_err_t i2c_read_bytes(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len); static esp_err_t reset(esp_lcd_touch_handle_t tp); +#ifndef CONFIG_ESP_LCD_TOUCH_CST816S_DISABLE_READ_ID static esp_err_t read_id(esp_lcd_touch_handle_t tp); +#endif esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *tp) { @@ -89,7 +95,11 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons /* Reset controller */ ESP_GOTO_ON_ERROR(reset(cst816s), err, TAG, "Reset failed"); /* Read product id */ - ESP_GOTO_ON_ERROR(read_id(cst816s), err, TAG, "Read version failed"); +#ifdef CONFIG_ESP_LCD_TOUCH_CST816S_DISABLE_READ_ID + ESP_LOGI(TAG, "Read ID disabled"); +#else + ESP_GOTO_ON_ERROR(read_id(cst816s), err, TAG, "Read ID failed"); +#endif *tp = cst816s; return ESP_OK; @@ -179,6 +189,7 @@ static esp_err_t reset(esp_lcd_touch_handle_t tp) return ESP_OK; } +#ifndef CONFIG_ESP_LCD_TOUCH_CST816S_DISABLE_READ_ID static esp_err_t read_id(esp_lcd_touch_handle_t tp) { uint8_t id; @@ -186,6 +197,7 @@ static esp_err_t read_id(esp_lcd_touch_handle_t tp) ESP_LOGI(TAG, "IC id: %d", id); return ESP_OK; } +#endif static esp_err_t i2c_read_bytes(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len) { diff --git a/src/drivers/touch/port/esp_lcd_touch_cst816s.h b/src/drivers/touch/port/esp_lcd_touch_cst816s.h index 98cba221..a5eccf6d 100644 --- a/src/drivers/touch/port/esp_lcd_touch_cst816s.h +++ b/src/drivers/touch/port/esp_lcd_touch_cst816s.h @@ -18,8 +18,8 @@ extern "C" { #endif #define ESP_LCD_TOUCH_CST816S_VER_MAJOR (1) -#define ESP_LCD_TOUCH_CST816S_VER_MINOR (0) -#define ESP_LCD_TOUCH_CST816S_VER_PATCH (3) +#define ESP_LCD_TOUCH_CST816S_VER_MINOR (1) +#define ESP_LCD_TOUCH_CST816S_VER_PATCH (0) /** * @brief Create a new CST816S touch driver @@ -44,16 +44,21 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG() \ - { \ +#define ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG(freq_hz) \ + { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS, \ - .control_phase_bytes = 1, \ - .dc_bit_offset = 0, \ - .lcd_cmd_bits = 8, \ - .flags = \ - { \ - .disable_control_phase = 1, \ - } \ + .on_color_trans_done = 0, \ + .user_ctx = 0, \ + .control_phase_bytes = 1, \ + .dc_bit_offset = 0, \ + .lcd_cmd_bits = 8, \ + .lcd_param_bits = 0, \ + .flags = \ + { \ + .dc_low_on_data = 0, \ + .disable_control_phase = 1, \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_cst820.h b/src/drivers/touch/port/esp_lcd_touch_cst820.h index cbde1d9a..d864ea23 100644 --- a/src/drivers/touch/port/esp_lcd_touch_cst820.h +++ b/src/drivers/touch/port/esp_lcd_touch_cst820.h @@ -45,7 +45,7 @@ esp_err_t esp_lcd_touch_new_i2c_cst820(const esp_lcd_panel_io_handle_t io, const * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_CST820_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_CST820_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_CST820_ADDRESS, \ .control_phase_bytes = 1, \ @@ -54,7 +54,8 @@ esp_err_t esp_lcd_touch_new_i2c_cst820(const esp_lcd_panel_io_handle_t io, const .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_ft5x06.h b/src/drivers/touch/port/esp_lcd_touch_ft5x06.h index 6afe519e..ac2a3bf0 100644 --- a/src/drivers/touch/port/esp_lcd_touch_ft5x06.h +++ b/src/drivers/touch/port/esp_lcd_touch_ft5x06.h @@ -19,7 +19,7 @@ extern "C" { #define ESP_LCD_TOUCH_FT5x06_VER_MAJOR (1) #define ESP_LCD_TOUCH_FT5x06_VER_MINOR (0) -#define ESP_LCD_TOUCH_FT5x06_VER_PATCH (6) +#define ESP_LCD_TOUCH_FT5x06_VER_PATCH (7) /** * @brief Create a new FT5x06 touch driver @@ -45,7 +45,7 @@ esp_err_t esp_lcd_touch_new_i2c_ft5x06(const esp_lcd_panel_io_handle_t io, const * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_FT5x06_ADDRESS, \ .control_phase_bytes = 1, \ @@ -54,7 +54,8 @@ esp_err_t esp_lcd_touch_new_i2c_ft5x06(const esp_lcd_panel_io_handle_t io, const .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } diff --git a/src/drivers/touch/port/esp_lcd_touch_gt1151.h b/src/drivers/touch/port/esp_lcd_touch_gt1151.h index 2df705c5..cc477704 100644 --- a/src/drivers/touch/port/esp_lcd_touch_gt1151.h +++ b/src/drivers/touch/port/esp_lcd_touch_gt1151.h @@ -44,7 +44,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt1151(const esp_lcd_panel_io_handle_t io, const * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_GT1151_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_GT1151_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_GT1151_ADDRESS, \ .control_phase_bytes = 1, \ @@ -53,7 +53,8 @@ esp_err_t esp_lcd_touch_new_i2c_gt1151(const esp_lcd_panel_io_handle_t io, const .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_gt911.c b/src/drivers/touch/port/esp_lcd_touch_gt911.c index 35f85fd5..107f6ee4 100644 --- a/src/drivers/touch/port/esp_lcd_touch_gt911.c +++ b/src/drivers/touch/port/esp_lcd_touch_gt911.c @@ -141,7 +141,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const vTaskDelay(pdMS_TO_TICKS(50)); } else { - ESP_LOGW(TAG, "Unable to initialize the I2C address"); + ESP_LOGI(TAG, "I2C address initialization procedure skipped - using default GT9xx setup"); /* Reset controller */ ret = touch_gt911_reset(esp_lcd_touch_gt911); ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 reset failed"); @@ -248,19 +248,21 @@ static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp) /* Buttons count */ tp->data.buttons = key_max; for (i = 0; i < key_max; i++) { - tp->data.button[i].status = buf[0] ? 1 : 0; + tp->data.button[i].status = buf[i] ? 1 : 0; } portEXIT_CRITICAL(&tp->data.lock); #endif } else if ((buf[0] & 0x80) == 0x80) { -#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) portENTER_CRITICAL(&tp->data.lock); + /* Invalidate */ + tp->data.points = 0; +#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) for (i = 0; i < CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS; i++) { tp->data.button[i].status = 0; } - portEXIT_CRITICAL(&tp->data.lock); #endif + portEXIT_CRITICAL(&tp->data.lock); /* Count of touched points */ touch_cnt = buf[0] & 0x0f; if (touch_cnt > 5 || touch_cnt == 0) { @@ -317,9 +319,6 @@ static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, u } } - /* Invalidate */ - tp->data.points = 0; - portEXIT_CRITICAL(&tp->data.lock); return (*point_num > 0); diff --git a/src/drivers/touch/port/esp_lcd_touch_gt911.h b/src/drivers/touch/port/esp_lcd_touch_gt911.h index ba9ca735..fce6641e 100644 --- a/src/drivers/touch/port/esp_lcd_touch_gt911.h +++ b/src/drivers/touch/port/esp_lcd_touch_gt911.h @@ -57,7 +57,7 @@ typedef struct { * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS, \ .control_phase_bytes = 1, \ @@ -66,7 +66,8 @@ typedef struct { .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } /** @@ -75,7 +76,7 @@ typedef struct { * @param[in] addr I2C address of the touch panel * */ -#define ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG_WITH_ADDR(addr) \ +#define ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG_WITH_ADDR(addr, freq_hz) \ { \ .dev_addr = addr, \ .control_phase_bytes = 1, \ @@ -84,7 +85,8 @@ typedef struct { .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_spd2010.c b/src/drivers/touch/port/esp_lcd_touch_spd2010.c index 69d69930..0a8f40de 100644 --- a/src/drivers/touch/port/esp_lcd_touch_spd2010.c +++ b/src/drivers/touch/port/esp_lcd_touch_spd2010.c @@ -15,7 +15,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" -#include "driver/i2c.h" #include "esp_system.h" #include "esp_err.h" #include "esp_log.h" diff --git a/src/drivers/touch/port/esp_lcd_touch_spd2010.h b/src/drivers/touch/port/esp_lcd_touch_spd2010.h index 0e021ad1..7f917fb3 100644 --- a/src/drivers/touch/port/esp_lcd_touch_spd2010.h +++ b/src/drivers/touch/port/esp_lcd_touch_spd2010.h @@ -38,7 +38,7 @@ esp_err_t esp_lcd_touch_new_i2c_spd2010(const esp_lcd_panel_io_handle_t io, cons * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_SPD2010_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_SPD2010_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_SPD2010_ADDRESS, \ .control_phase_bytes = 1, \ @@ -47,7 +47,8 @@ esp_err_t esp_lcd_touch_new_i2c_spd2010(const esp_lcd_panel_io_handle_t io, cons .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_st1633.c b/src/drivers/touch/port/esp_lcd_touch_st1633.c index 505e183e..4d5e86a7 100644 --- a/src/drivers/touch/port/esp_lcd_touch_st1633.c +++ b/src/drivers/touch/port/esp_lcd_touch_st1633.c @@ -19,7 +19,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" -#include "driver/i2c.h" #include "esp_lcd_panel_io.h" #include "esp_lcd_touch.h" diff --git a/src/drivers/touch/port/esp_lcd_touch_st1633.h b/src/drivers/touch/port/esp_lcd_touch_st1633.h index bc5f265e..24278f26 100644 --- a/src/drivers/touch/port/esp_lcd_touch_st1633.h +++ b/src/drivers/touch/port/esp_lcd_touch_st1633.h @@ -38,7 +38,7 @@ esp_err_t esp_lcd_touch_new_i2c_st1633(const esp_lcd_panel_io_handle_t io, const * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_ST1633_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_ST1633_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_ST1633_ADDRESS, \ .control_phase_bytes = 1, \ @@ -46,7 +46,8 @@ esp_err_t esp_lcd_touch_new_i2c_st1633(const esp_lcd_panel_io_handle_t io, const .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_st7123.c b/src/drivers/touch/port/esp_lcd_touch_st7123.c index 043fef75..c680be8b 100644 --- a/src/drivers/touch/port/esp_lcd_touch_st7123.c +++ b/src/drivers/touch/port/esp_lcd_touch_st7123.c @@ -19,7 +19,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" -#include "driver/i2c.h" #include "esp_lcd_panel_io.h" #include "esp_lcd_touch.h" diff --git a/src/drivers/touch/port/esp_lcd_touch_st7123.h b/src/drivers/touch/port/esp_lcd_touch_st7123.h index 4e3c77b6..d8b8e54a 100644 --- a/src/drivers/touch/port/esp_lcd_touch_st7123.h +++ b/src/drivers/touch/port/esp_lcd_touch_st7123.h @@ -38,7 +38,7 @@ esp_err_t esp_lcd_touch_new_i2c_st7123(const esp_lcd_panel_io_handle_t io, const * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_ST7123_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_ST7123_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_ST7123_ADDRESS, \ .control_phase_bytes = 1, \ @@ -46,7 +46,8 @@ esp_err_t esp_lcd_touch_new_i2c_st7123(const esp_lcd_panel_io_handle_t io, const .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_stmpe610.h b/src/drivers/touch/port/esp_lcd_touch_stmpe610.h index 7a31a774..1f677a92 100644 --- a/src/drivers/touch/port/esp_lcd_touch_stmpe610.h +++ b/src/drivers/touch/port/esp_lcd_touch_stmpe610.h @@ -19,7 +19,7 @@ extern "C" { #define ESP_LCD_TOUCH_STMPE610_VER_MAJOR (1) #define ESP_LCD_TOUCH_STMPE610_VER_MINOR (0) -#define ESP_LCD_TOUCH_STMPE610_VER_PATCH (6) +#define ESP_LCD_TOUCH_STMPE610_VER_PATCH (7) /** * @brief Create a new STMPE610 touch driver diff --git a/src/drivers/touch/port/esp_lcd_touch_tt21100.c b/src/drivers/touch/port/esp_lcd_touch_tt21100.c index fd348cfb..d754ce61 100644 --- a/src/drivers/touch/port/esp_lcd_touch_tt21100.c +++ b/src/drivers/touch/port/esp_lcd_touch_tt21100.c @@ -211,13 +211,13 @@ static esp_err_t esp_lcd_touch_tt21100_read_data(esp_lcd_touch_handle_t tp) touch_tt21100_i2c_read(tp, data, data_len); ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!"); - portENTER_CRITICAL(&tp->data.lock); - if (data_len == 14) { #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) /* Button event */ p_btn_data = (button_record_struct_t *) data; + portENTER_CRITICAL(&tp->data.lock); + /* Buttons count */ tp->data.buttons = (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS < 4 ? CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS : 4); @@ -225,6 +225,8 @@ static esp_err_t esp_lcd_touch_tt21100_read_data(esp_lcd_touch_handle_t tp) tp->data.button[i].status = p_btn_data->btn_signal[i]; } + portEXIT_CRITICAL(&tp->data.lock); + ESP_LOGD(TAG, "Len : %04Xh. ID : %02Xh. Time : %5u. Val : [%u] - [%04X][%04X][%04X][%04X]", p_btn_data->length, p_btn_data->report_id, p_btn_data->time_stamp, p_btn_data->btn_val, p_btn_data->btn_signal[0], p_btn_data->btn_signal[1], p_btn_data->btn_signal[2], p_btn_data->btn_signal[3]); @@ -236,6 +238,9 @@ static esp_err_t esp_lcd_touch_tt21100_read_data(esp_lcd_touch_handle_t tp) /* Number of touched points */ tp_num = (tp_num > CONFIG_ESP_LCD_TOUCH_MAX_POINTS ? CONFIG_ESP_LCD_TOUCH_MAX_POINTS : tp_num); + + portENTER_CRITICAL(&tp->data.lock); + tp->data.points = tp_num; /* Fill all coordinates */ @@ -245,12 +250,15 @@ static esp_err_t esp_lcd_touch_tt21100_read_data(esp_lcd_touch_handle_t tp) tp->data.coords[i].x = p_touch_data->x; tp->data.coords[i].y = p_touch_data->y; tp->data.coords[i].strength = p_touch_data->pressure; + } + + portEXIT_CRITICAL(&tp->data.lock); + for (i = 0; i < tp_num; i++) { + p_touch_data = &p_report_data->touch_record[i]; ESP_LOGD(TAG, "(%zu) [%3u][%3u]", i, p_touch_data->x, p_touch_data->y); } } - - portEXIT_CRITICAL(&tp->data.lock); } return ESP_OK; diff --git a/src/drivers/touch/port/esp_lcd_touch_tt21100.h b/src/drivers/touch/port/esp_lcd_touch_tt21100.h index e76467c3..6e4d28cb 100644 --- a/src/drivers/touch/port/esp_lcd_touch_tt21100.h +++ b/src/drivers/touch/port/esp_lcd_touch_tt21100.h @@ -19,7 +19,7 @@ extern "C" { #define ESP_LCD_TOUCH_TT21100_VER_MAJOR (1) #define ESP_LCD_TOUCH_TT21100_VER_MINOR (1) -#define ESP_LCD_TOUCH_TT21100_VER_PATCH (0) +#define ESP_LCD_TOUCH_TT21100_VER_PATCH (1) /** * @brief Create a new TT21100 touch driver @@ -45,7 +45,7 @@ esp_err_t esp_lcd_touch_new_i2c_tt21100(const esp_lcd_panel_io_handle_t io, cons * @brief Touch IO configuration structure * */ -#define ESP_LCD_TOUCH_IO_I2C_TT21100_CONFIG() \ +#define ESP_LCD_TOUCH_IO_I2C_TT21100_CONFIG(freq_hz) \ { \ .dev_addr = ESP_LCD_TOUCH_IO_I2C_TT21100_ADDRESS, \ .control_phase_bytes = 1, \ @@ -54,7 +54,8 @@ esp_err_t esp_lcd_touch_new_i2c_tt21100(const esp_lcd_panel_io_handle_t io, cons .flags = \ { \ .disable_control_phase = 1, \ - } \ + }, \ + .scl_speed_hz = freq_hz, \ } #ifdef __cplusplus diff --git a/src/drivers/touch/port/esp_lcd_touch_xpt2046.c b/src/drivers/touch/port/esp_lcd_touch_xpt2046.c index ee3b84e0..81752b96 100644 --- a/src/drivers/touch/port/esp_lcd_touch_xpt2046.c +++ b/src/drivers/touch/port/esp_lcd_touch_xpt2046.c @@ -29,23 +29,27 @@ static const char *TAG = "xpt2046"; #define CONFIG_XPT2046_Z_THRESHOLD (ESP_PANEL_DRIVERS_TOUCH_XPT2046_Z_THRESHOLD) #if ESP_PANEL_DRIVERS_TOUCH_XPT2046_INTERRUPT_MODE -#define CONFIG_XPT2046_INTERRUPT_MODE (ESP_PANEL_DRIVERS_TOUCH_XPT2046_INTERRUPT_MODE) +# define CONFIG_XPT2046_INTERRUPT_MODE (ESP_PANEL_DRIVERS_TOUCH_XPT2046_INTERRUPT_MODE) +#else +# define CONFIG_XPT2046_INTERRUPT_MODE (0) #endif #if ESP_PANEL_DRIVERS_TOUCH_XPT2046_VREF_ON_MODE -#define CONFIG_XPT2046_VREF_ON_MODE (ESP_PANEL_DRIVERS_TOUCH_XPT2046_VREF_ON_MODE) +# define CONFIG_XPT2046_VREF_ON_MODE (ESP_PANEL_DRIVERS_TOUCH_XPT2046_VREF_ON_MODE) +#else +# define CONFIG_XPT2046_VREF_ON_MODE (0) #endif #define CONFIG_XPT2046_CONVERT_ADC_TO_COORDS (ESP_PANEL_DRIVERS_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS) #ifdef CONFIG_XPT2046_INTERRUPT_MODE -#define XPT2046_PD0_BIT (0x00) +# define XPT2046_PD0_BIT (0x00) #else -#define XPT2046_PD0_BIT (0x01) +# define XPT2046_PD0_BIT (0x01) #endif #ifdef CONFIG_XPT2046_VREF_ON_MODE -#define XPT2046_PD1_BIT (0x02) +# define XPT2046_PD1_BIT (0x02) #else -#define XPT2046_PD1_BIT (0x00) +# define XPT2046_PD1_BIT (0x00) #endif #define XPT2046_PD_BITS (XPT2046_PD1_BIT | XPT2046_PD0_BIT) @@ -132,6 +136,13 @@ esp_err_t esp_lcd_touch_new_spi_xpt2046(const esp_lcd_panel_io_handle_t io, if (config->interrupt_callback) { esp_lcd_touch_register_interrupt_callback(handle, config->interrupt_callback); } + +#if CONFIG_XPT2046_INTERRUPT_MODE + // Read a register to enable Low Power mode, which is required for interrupt to work. + uint8_t battery = 0; + ESP_GOTO_ON_ERROR(esp_lcd_panel_io_rx_param(handle->io, BATTERY, &battery, 1), err, TAG, "XPT2046 read error!"); +#endif + } *out_touch = handle; diff --git a/src/drivers/touch/port/esp_lcd_touch_xpt2046.h b/src/drivers/touch/port/esp_lcd_touch_xpt2046.h index e19a6fab..f50d5f3d 100644 --- a/src/drivers/touch/port/esp_lcd_touch_xpt2046.h +++ b/src/drivers/touch/port/esp_lcd_touch_xpt2046.h @@ -16,7 +16,7 @@ extern "C" { #define ESP_LCD_TOUCH_XPT2046_VER_MAJOR (1) #define ESP_LCD_TOUCH_XPT2046_VER_MINOR (0) -#define ESP_LCD_TOUCH_XPT2046_VER_PATCH (5) +#define ESP_LCD_TOUCH_XPT2046_VER_PATCH (6) /** * @brief Recommended clock for SPI read of the XPT2046 diff --git a/src/esp_panel_versions.h b/src/esp_panel_versions.h index fc8b1b36..e17c3367 100644 --- a/src/esp_panel_versions.h +++ b/src/esp_panel_versions.h @@ -12,12 +12,12 @@ /* File `esp_panel_drivers_conf.h` */ #define ESP_PANEL_DRIVERS_CONF_VERSION_MAJOR 1 -#define ESP_PANEL_DRIVERS_CONF_VERSION_MINOR 1 +#define ESP_PANEL_DRIVERS_CONF_VERSION_MINOR 2 #define ESP_PANEL_DRIVERS_CONF_VERSION_PATCH 0 /* File `esp_panel_board_custom_conf.h` */ -#define ESP_PANEL_BOARD_CUSTOM_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_VERSION_MINOR 2 +#define ESP_PANEL_BOARD_CUSTOM_VERSION_MAJOR 2 +#define ESP_PANEL_BOARD_CUSTOM_VERSION_MINOR 0 #define ESP_PANEL_BOARD_CUSTOM_VERSION_PATCH 0 /* File `esp_panel_board_supported_conf.h` */ diff --git a/test_apps/drivers/touch/i2c/main/test_i2c_touch.cpp b/test_apps/drivers/touch/i2c/main/test_i2c_touch.cpp index cbbbf19f..207425cc 100644 --- a/test_apps/drivers/touch/i2c/main/test_i2c_touch.cpp +++ b/test_apps/drivers/touch/i2c/main/test_i2c_touch.cpp @@ -81,9 +81,8 @@ static void run_test(shared_ptr touch, bool use_config) ({ \ ESP_LOGI(TAG, "Create bus with default parameters"); \ auto bus = make_shared(TEST_TOUCH_PIN_NUM_I2C_SCL, TEST_TOUCH_PIN_NUM_I2C_SDA, \ - (BusI2C::ControlPanelFullConfig)ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(name)); \ + (BusI2C::ControlPanelFullConfig)ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(name, TEST_TOUCH_I2C_FREQ_HZ)); \ TEST_ASSERT_NOT_NULL_MESSAGE(bus, "Create bus object failed"); \ - TEST_ASSERT_TRUE_MESSAGE(bus->configI2C_FreqHz(TEST_TOUCH_I2C_FREQ_HZ), "Bus config I2C frequency failed"); \ TEST_ASSERT_TRUE_MESSAGE(bus->begin(), "Bus begin failed"); \ bus; \ }) @@ -126,7 +125,7 @@ decltype(auto) create_touch_impl(Bus *bus, std::nullptr_t) .sda_pullup_en = TEST_TOUCH_PIN_NUM_I2C_SDA_PULLUP, \ .scl_pullup_en = TEST_TOUCH_PIN_NUM_I2C_SCL_PULLUP, \ }, \ - .control_panel = (BusI2C::ControlPanelFullConfig)ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(name), \ + .control_panel = (BusI2C::ControlPanelFullConfig)ESP_PANEL_TOUCH_I2C_CONTROL_PANEL_CONFIG(name, TEST_TOUCH_I2C_FREQ_HZ), \ }; \ bus = CREATE_BUS_WITH_CONFIG(name, bus_config); \ touch = CREATE_TOUCH(name, bus.get(), touch_config); \