name: lcd-touch-i2c-migration description: Use when migrating ESP Board Manager board definitions or application code from legacy dev_lcd_touch_i2c / type lcd_touch_i2c to generic dev_lcd_touch with type lcd_touch and sub_type i2c, including YAML field mapping, setup_device.c touch factory updates, and compatibility checks.
LCD Touch I2C Migration
Use this skill to migrate ESP Board Manager configurations from legacy lcd_touch_i2c to generic lcd_touch with sub_type: i2c.
Migration Goals
- Board YAML uses
type: lcd_touchandsub_type: i2c. - I2C address candidates live at device root
peripherals[].i2c_addr. config.io_i2c_config.dev_addrand nestedconfig.io_i2c_config.peripheralsare removed.- APP code uses
dev_lcd_touch_config_t/dev_lcd_touch_handles_t, not legacydev_lcd_touch_i2c_*types. - APP code uses
CONFIG_ESP_BOARD_DEV_LCD_TOUCH_SUPPORTplusCONFIG_ESP_BOARD_DEV_LCD_TOUCH_SUB_I2C_SUPPORTfor migrated I2C touch feature checks. Do not introduce or keep legacyCONFIG_ESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORTchecks in migrated code.
Before Editing
- Inspect the target board files:
board_devices.yamlboard_peripherals.yaml- optional
setup_device.c - application files that include
dev_lcd_touch_i2c.hor usedev_lcd_touch_i2c_*
- Search:
type: lcd_touch_i2cdev_lcd_touch_i2cCONFIG_ESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORTESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORT
- Preserve user edits and unrelated board content.
YAML Mapping
Old:
- name: lcd_touch
type: lcd_touch_i2c
config:
io_i2c_config:
dev_addr: 0x15
peripherals:
- name: i2c_master
touch_config: {}
New:
- name: lcd_touch
type: lcd_touch
sub_type: i2c
config:
io_i2c_config: {}
touch_config: {}
peripherals:
- name: i2c_master
i2c_addr: 0x2a
Rules:
- Change
type: lcd_touch_i2ctotype: lcd_touch. - Add
sub_type: i2c. - Move nested I2C peripheral entries from
config.io_i2c_config.peripheralsto root-level deviceperipherals. - Move
config.io_i2c_config.dev_addrto root-levelperipherals[].i2c_addr. - Remove
dev_addrfromconfig.io_i2c_config. - Keep
chip,dependencies,config.touch_config, and otherconfig.io_i2c_configfields. - If old
dev_addrwas a list, migrate it toi2c_addrlist. - If the old address appears to be 7-bit, convert it to 8-bit left-shifted form. Examples:
0x15 -> 0x2a,0x24 -> 0x48,0x5d -> 0xba. - New
i2c_addrmust be 8-bit left-shifted, even, and no larger than0xfe.
setup_device.c Rules
The factory signature remains:
esp_err_t lcd_touch_factory_entry_t(esp_lcd_panel_io_handle_t io,
const esp_lcd_touch_config_t *touch_dev_config,
esp_lcd_touch_handle_t *ret_touch)
If the board chooses a touch driver based on detected address:
- Include
esp_board_device.h. - Call
esp_board_device_get_i2c_effective_addr("<touch_device_name>", &touch_addr). - Compare against 8-bit left-shifted addresses from YAML.
- Do not read old
dev_lcd_touch_i2c_config_tfields to decide the chip.
Example:
uint16_t touch_addr = 0;
esp_err_t ret = esp_board_device_get_i2c_effective_addr("lcd_touch", &touch_addr);
if (ret != ESP_OK) {
return ret;
}
if (touch_addr == 0xba) {
return esp_lcd_touch_new_i2c_gt911(io, touch_dev_config, ret_touch);
}
Application Compatibility Checks
Legacy code may use this old feature switch:
#if CONFIG_ESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORT
Treat it as a migration target. Replace it in migrated code with the new generic device and sub-type checks:
#if CONFIG_ESP_BOARD_DEV_LCD_TOUCH_SUPPORT && CONFIG_ESP_BOARD_DEV_LCD_TOUCH_SUB_I2C_SUPPORT
Flag and migrate code that:
- Includes
dev_lcd_touch_i2c.hfor a board that now useslcd_touch. - Casts handles to
dev_lcd_touch_i2c_handles_t. - Casts configs to
dev_lcd_touch_i2c_config_t. - Reads old fields such as
i2c_name,i2c_addr, orio_i2c_config.dev_addrthrough a legacy config struct. - Uses
CONFIG_ESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORTorESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORTin migrated application code.
Use:
dev_lcd_touch_handles_t
dev_lcd_touch_config_t
Migration patterns:
- Replace
#include "dev_lcd_touch_i2c.h"with#include "dev_lcd_touch.h"for migrated boards. - Replace
dev_lcd_touch_i2c_handles_t *touch = (dev_lcd_touch_i2c_handles_t *)touch_handle;withdev_lcd_touch_handles_t *touch = (dev_lcd_touch_handles_t *)touch_handle;. - Replace
dev_lcd_touch_i2c_config_t *cfgwithdev_lcd_touch_config_t *cfg. - Map old config fields:
cfg->i2c_name->cfg->sub_cfg.i2c.i2c_namecfg->i2c_addr->cfg->sub_cfg.i2c.i2c_addr- address count ->
cfg->sub_cfg.i2c.i2c_addr_count
- Do not use
cfg->io_i2c_config.dev_addrto identify the active chip; callesp_board_device_get_i2c_effective_addr("<touch_device_name>", &addr)and compare 8-bit addresses. - If code must temporarily support both old and new boards, branch on
CONFIG_ESP_BOARD_DEV_LCD_TOUCH_SUPPORTfirst and keep anyCONFIG_ESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORTfallback isolated for legacy boards only.
Only keep legacy types for boards that intentionally still use type: lcd_touch_i2c.
Validation
After migration:
- Run Board Manager generation for the board:
idf.py bmgr -b <board>- or
python3 gen_bmgr_config_codes.py -b <board>from the test app context.
- Confirm generation has no
lcd_touch_i2cdeprecated parser warning. - Confirm
components/gen_bmgr_codes/board_manager.defaultshas:CONFIG_ESP_BOARD_DEV_LCD_TOUCH_SUPPORT=yCONFIG_ESP_BOARD_DEV_LCD_TOUCH_SUB_I2C_SUPPORT=y
- Confirm migrated application code does not use
CONFIG_ESP_BOARD_DEV_LCD_TOUCH_I2C_SUPPORTor legacydev_lcd_touch_i2c_*types. - Build if an ESP-IDF environment is available.
- Confirm there is no compile warning from legacy
dev_lcd_touch_i2c.hfor migrated boards.
Reporting
Summarize:
- Files changed.
- YAML address conversions performed.
- Any application code that still uses legacy types.
- Generation/build commands run and their result.