Looking for a working example with esp_lcd_touch_cst816s

greggles
Posts: 5
Joined: Fri Mar 13, 2026 6:37 am

Looking for a working example with esp_lcd_touch_cst816s

Postby greggles » Thu Apr 30, 2026 10:38 am

Trying to convert an existing application to use esp_lvgl_port, esp_lcd_st77916 and esp_lcd_touch_cst816s.

As long as the touch device (CST816) is not enabled, LVGL works fine.

However, if the touch device is enabled the screen is cleared and no LVGL widgets are displayed.

The code to enable the touch device is:

Code: Select all

        esp_lcd_panel_io_handle_t tp_io_handle = NULL;

        esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();

        ESP_ERROR_CHECK( esp_lcd_new_panel_io_i2c( i2c_handle, &tp_io_config, &tp_io_handle ) );

        esp_lcd_touch_config_t tp_cfg = {
            .x_max = LCD_WIDTH,
            .y_max = LCD_HEIGHT,
            .rst_gpio_num = (gpio_num_t)(CHIP_CST816_IO_RST),
            .int_gpio_num = CHIP_CST816_IO_INT,
            .levels = {
                .reset = 0,
                .interrupt = 0,
            },
            .flags = {
                .swap_xy = 0,
                .mirror_x = 0,
                .mirror_y = 0,
            },
            .interrupt_callback = touch_callback,
        };
and this is the line that if used will result in a black display:

Code: Select all

        esp_lcd_touch_new_i2c_cst816s( tp_io_handle, &tp_cfg, &tp_handle );
After the touch device is created "new", the following code is used:

Code: Select all

    lvgl_port_touch_cfg_t touch_cfg = {
        .disp = disp_handle,
        .handle = tp_handle,
    };

    lvgl_port_add_touch( &touch_cfg );
It's the esp_lcd_touch_new_i2c_cst816s that seems to be the root of the issue.

Thoughts?

I cannot find any example application that uses the esp_lcd_touch_cst816s module.

greggles
Posts: 5
Joined: Fri Mar 13, 2026 6:37 am

Re: Looking for a working example with esp_lcd_touch_cst816s

Postby greggles » Thu Apr 30, 2026 12:45 pm

tracing the issue, it seems to be related to the reset of the CST816s.

The chip is connected by an IO expander.

Commenting out the "reset" function of esp_lcd_touch_cst816s, and LVGL works fine.

Who is online

Users browsing this forum: Bytespider, PerplexityBot, Semrush [Bot] and 17 guests