Merge branch 'refactor/remove_lcd_deprecated' into 'master'

esp_lcd clean up

Closes IDF-13711, IDF-13712, IDF-13713, IDF-13714, and IDF-13715

See merge request espressif/esp-idf!40848
This commit is contained in:
morris
2025-08-06 10:41:20 +08:00
35 changed files with 259 additions and 340 deletions

View File

@@ -1,29 +1,20 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _DRIVER_I2C_H_
#define _DRIVER_I2C_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <esp_types.h>
#include "esp_err.h"
#include "esp_intr_alloc.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "esp_types.h"
#include "esp_err.h"
#include "esp_intr_alloc.h" // for intr_alloc_flags
#include "soc/soc_caps.h"
#include "hal/i2c_types.h"
#if SOC_I2C_SUPPORT_APB
#define I2C_APB_CLK_FREQ _Pragma ("GCC warning \"'I2C_APB_CLK_FREQ' macro is deprecated\"") (APB_CLK_FREQ) /*!< I2C source clock is APB clock, 80MHz, deprecated */
#ifdef __cplusplus
extern "C" {
#endif
// I2C clk flags for users to use, can be expanded in the future.
@@ -630,5 +621,3 @@ esp_err_t i2c_get_data_mode(i2c_port_t i2c_num, i2c_trans_mode_t *tx_trans_mode,
#ifdef __cplusplus
}
#endif
#endif /*_DRIVER_I2C_H_*/

View File

@@ -9,6 +9,7 @@
#include <stdbool.h>
#include "esp_err.h"
#include "esp_lcd_types.h"
#include "hal/mipi_dsi_types.h"
typedef struct esp_lcd_dsi_bus_t *esp_lcd_dsi_bus_handle_t; /*!< Type of MIPI DSI bus handle */

View File

@@ -68,8 +68,8 @@ struct esp_lcd_i80_bus_t {
portMUX_TYPE spinlock; // spinlock used to protect i80 bus members(hal, device_list, cur_trans)
i2s_hal_context_t hal; // Hal object
size_t bus_width; // Number of data lines
int dc_gpio_num; // GPIO used for DC line
int wr_gpio_num; // GPIO used for WR line
gpio_num_t dc_gpio_num;// GPIO used for DC line
gpio_num_t wr_gpio_num;// GPIO used for WR line
intr_handle_t intr; // LCD peripheral interrupt handle
#if CONFIG_PM_ENABLE
esp_pm_lock_handle_t pm_lock; // lock APB frequency when necessary
@@ -100,7 +100,7 @@ struct lcd_i80_trans_descriptor_t {
struct lcd_panel_io_i80_t {
esp_lcd_panel_io_t base; // Base class of generic lcd panel io
esp_lcd_i80_bus_t *bus; // Which bus the device is attached to
int cs_gpio_num; // GPIO used for CS line
gpio_num_t cs_gpio_num; // GPIO used for CS line
uint32_t pclk_hz; // PCLK clock frequency
size_t clock_prescale; // Prescaler coefficient, determined by user's configured PCLK frequency
QueueHandle_t trans_queue; // Transaction queue, transactions in this queue are pending for scheduler to dispatch

View File

@@ -116,7 +116,7 @@ struct lcd_i80_trans_descriptor_t {
struct lcd_panel_io_i80_t {
esp_lcd_panel_io_t base; // Base class of generic lcd panel io
esp_lcd_i80_bus_t *bus; // Which bus the device is attached to
int cs_gpio_num; // GPIO used for CS line
gpio_num_t cs_gpio_num; // GPIO used for CS line
unsigned int pclk_hz; // PCLK clock frequency
size_t clock_prescale; // Prescaler coefficient, determined by user's configured PCLK frequency
QueueHandle_t trans_queue; // Transaction queue, transactions in this queue are pending for scheduler to dispatch

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -22,17 +22,17 @@ typedef uint32_t esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I
*/
typedef struct {
uint32_t dev_addr; /*!< I2C device address */
esp_lcd_panel_io_color_trans_done_cb_t on_color_trans_done; /*!< Callback invoked when color data transfer has finished */
void *user_ctx; /*!< User private data, passed directly to on_color_trans_done's user_ctx */
uint32_t scl_speed_hz; /*!< I2C LCD SCL frequency (hz) */
size_t control_phase_bytes; /*!< I2C LCD panel will encode control information (e.g. D/C selection) into control phase, in several bytes */
unsigned int dc_bit_offset; /*!< Offset of the D/C selection bit in control phase */
uint8_t dc_bit_offset; /*!< Offset of the D/C selection bit in control phase */
int lcd_cmd_bits; /*!< Bit-width of LCD command */
int lcd_param_bits; /*!< Bit-width of LCD parameter */
esp_lcd_panel_io_color_trans_done_cb_t on_color_trans_done; /*!< Callback invoked when color data transfer has finished */
void *user_ctx; /*!< User private data, passed directly to on_color_trans_done's user_ctx */
struct {
unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */
unsigned int disable_control_phase: 1; /*!< If this flag is enabled, the control phase isn't used */
} flags; /*!< Extra flags to fine-tune the I2C device */
uint32_t scl_speed_hz; /*!< I2C LCD SCL frequency (hz) */
} esp_lcd_panel_io_i2c_config_t;
/**

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -23,17 +23,13 @@ typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD i
* @brief LCD Intel 8080 bus configuration structure
*/
typedef struct {
int dc_gpio_num; /*!< GPIO used for D/C line */
int wr_gpio_num; /*!< GPIO used for WR line */
gpio_num_t dc_gpio_num; /*!< GPIO used for D/C line */
gpio_num_t wr_gpio_num; /*!< GPIO used for WR line */
lcd_clock_source_t clk_src; /*!< Clock source for the I80 LCD peripheral */
int data_gpio_nums[ESP_LCD_I80_BUS_WIDTH_MAX]; /*!< GPIOs used for data lines */
gpio_num_t data_gpio_nums[ESP_LCD_I80_BUS_WIDTH_MAX]; /*!< GPIOs used for data lines */
size_t bus_width; /*!< Number of data lines, 8 or 16 */
size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */
union {
size_t psram_trans_align __attribute__((deprecated)); /*!< DMA transfer alignment for data allocated from PSRAM */
size_t dma_burst_size; /*!< DMA burst size, in bytes */
};
size_t sram_trans_align __attribute__((deprecated)); /*!< DMA transfer alignment for data allocated from SRAM */
} esp_lcd_i80_bus_config_t;
/**
@@ -64,7 +60,7 @@ esp_err_t esp_lcd_del_i80_bus(esp_lcd_i80_bus_handle_t bus);
* @brief Panel IO configuration structure, for intel 8080 interface
*/
typedef struct {
int cs_gpio_num; /*!< GPIO used for CS line, set to -1 will declaim exclusively use of I80 bus */
gpio_num_t cs_gpio_num; /*!< GPIO used for CS line, set to -1 will declaim exclusively use of I80 bus */
uint32_t pclk_hz; /*!< Frequency of pixel clock */
size_t trans_queue_depth; /*!< Transaction queue size, larger queue, higher throughput */
esp_lcd_panel_io_color_trans_done_cb_t on_color_trans_done; /*!< Callback invoked when color data was transferred done */

View File

@@ -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
*/
@@ -22,10 +22,10 @@ extern "C" {
* @brief Parallel Panel IO configuration structure, for intel 8080 interface(8 data-lines) or SPI interface(1 data-lines)
*/
typedef struct {
int dc_gpio_num; /*!< GPIO used for D/C line */
int clk_gpio_num; /*!< GPIO used for CLK line */
int cs_gpio_num; /*!< GPIO used for CS line */
int data_gpio_nums[ESP_PARLIO_LCD_WIDTH_MAX]; /*!< GPIOs used for data lines */
gpio_num_t dc_gpio_num; /*!< GPIO used for D/C line */
gpio_num_t clk_gpio_num; /*!< GPIO used for CLK line */
gpio_num_t cs_gpio_num; /*!< GPIO used for CS line */
gpio_num_t data_gpio_nums[ESP_PARLIO_LCD_WIDTH_MAX]; /*!< GPIOs used for data lines */
size_t data_width; /*!< Number of data lines, 1(SPI) or 8(I80) */
uint32_t pclk_hz; /*!< Frequency of pixel clock */
parlio_clock_source_t clk_src; /*!< Clock source for the Parlio peripheral */

View File

@@ -20,8 +20,8 @@ typedef int esp_lcd_spi_bus_handle_t; /*!< Type of LCD SPI bus handle */
* @brief Panel IO configuration structure, for SPI interface
*/
typedef struct {
int cs_gpio_num; /*!< GPIO used for CS line */
int dc_gpio_num; /*!< GPIO used to select the D/C line, set this to -1 if the D/C line is not used */
gpio_num_t cs_gpio_num; /*!< GPIO used for CS line */
gpio_num_t dc_gpio_num; /*!< GPIO used to select the D/C line, set this to -1 if the D/C line is not used */
int spi_mode; /*!< Traditional SPI mode (0~3) */
unsigned int pclk_hz; /*!< Frequency of pixel clock */
size_t trans_queue_depth; /*!< Size of internal transaction queue */
@@ -35,8 +35,6 @@ typedef struct {
unsigned int dc_high_on_cmd: 1; /*!< If enabled, DC level = 1 indicates command transfer */
unsigned int dc_low_on_data: 1; /*!< If enabled, DC level = 0 indicates color data transfer */
unsigned int dc_low_on_param: 1; /*!< If enabled, DC level = 0 indicates parameter transfer */
unsigned int octal_mode: 1 __attribute__((deprecated("This bitfield is deprecated"))); /*!< Deprecated, driver will detect the bus mode automatically */
unsigned int quad_mode: 1 __attribute__((deprecated("This bitfield is deprecated"))); /*!< Deprecated, driver will detect the bus mode automatically */
unsigned int sio_mode: 1; /*!< Read and write through a single data line (MOSI) */
unsigned int lsb_first: 1; /*!< transmit LSB bit first */
unsigned int cs_high_active: 1; /*!< CS line is high active */

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -18,18 +18,14 @@ extern "C" {
* @brief Configuration structure for panel device
*/
typedef struct {
int reset_gpio_num; /*!< GPIO used to reset the LCD panel, set to -1 if it's not used */
union {
esp_lcd_color_space_t color_space; /*!< @deprecated Set RGB color space, please use rgb_ele_order instead */
lcd_color_rgb_endian_t rgb_endian; /*!< @deprecated Set RGB data endian, please use rgb_ele_order instead */
lcd_rgb_element_order_t rgb_ele_order; /*!< Set RGB element order, RGB or BGR */
};
lcd_rgb_data_endian_t data_endian; /*!< Set the data endian for color data larger than 1 byte */
uint32_t bits_per_pixel; /*!< Color depth, in bpp */
gpio_num_t reset_gpio_num; /*!< GPIO used to reset the LCD panel, set to -1 if it's not used */
void *vendor_config; /*!< vendor specific configuration, optional, left as NULL if not used */
struct {
uint32_t reset_active_high: 1; /*!< Setting this if the panel reset is high level active */
} flags; /*!< LCD panel config flags */
void *vendor_config; /*!< vendor specific configuration, optional, left as NULL if not used */
} esp_lcd_panel_dev_config_t;
#ifdef __cplusplus

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -121,18 +121,6 @@ esp_err_t esp_lcd_panel_invert_color(esp_lcd_panel_handle_t panel, bool invert_c
*/
esp_err_t esp_lcd_panel_disp_on_off(esp_lcd_panel_handle_t panel, bool on_off);
/**
* @brief Turn off the display
*
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
* @param[in] off Whether to turn off the screen
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
*/
esp_err_t esp_lcd_panel_disp_off(esp_lcd_panel_handle_t panel, bool off)
__attribute__((deprecated("use esp_lcd_panel_disp_on_off instead")));
/**
* @brief Enter or exit sleep mode
*

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -8,7 +8,7 @@
#include <stdbool.h>
#include "esp_assert.h"
#include "hal/lcd_types.h"
#include "hal/mipi_dsi_types.h"
#include "hal/gpio_types.h"
#include "hal/color_types.h"
#ifdef __cplusplus
@@ -40,18 +40,6 @@ typedef enum {
LCD_RGB_ELEMENT_ORDER_BGR = COLOR_RGB_ELEMENT_ORDER_BGR, /*!< RGB element order: BGR */
} lcd_rgb_element_order_t;
/** @cond */
/// for backward compatible
typedef lcd_rgb_element_order_t lcd_color_rgb_endian_t;
#define LCD_RGB_ENDIAN_RGB (lcd_color_rgb_endian_t)LCD_RGB_ELEMENT_ORDER_RGB
#define LCD_RGB_ENDIAN_BGR (lcd_color_rgb_endian_t)LCD_RGB_ELEMENT_ORDER_BGR
typedef lcd_rgb_element_order_t esp_lcd_color_space_t;
#define ESP_LCD_COLOR_SPACE_RGB (esp_lcd_color_space_t)LCD_RGB_ELEMENT_ORDER_RGB
#define ESP_LCD_COLOR_SPACE_BGR (esp_lcd_color_space_t)LCD_RGB_ELEMENT_ORDER_BGR
#define ESP_LCD_COLOR_SPACE_MONOCHROME (esp_lcd_color_space_t)2
/** @endcond */
/**
* @brief Type of LCD panel IO event data
*/

View File

@@ -62,8 +62,8 @@ struct lcd_panel_io_parlio_t {
esp_lcd_panel_io_t base; // Base class of generic lcd panel io
parlio_tx_unit_handle_t tx_unit; // Parlio TX unit
size_t data_width; // Number of data lines
int dc_gpio_num; // GPIO used for DC line
int cs_gpio_num; // GPIO used for CS line
gpio_num_t dc_gpio_num; // GPIO used for DC line
gpio_num_t cs_gpio_num; // GPIO used for CS line
int lcd_cmd_bits; // Bit width of LCD command
int lcd_param_bits; // Bit width of LCD parameter
void *user_ctx; // private data used when transfer color data

View File

@@ -123,12 +123,12 @@ struct esp_rgb_panel_t {
uint8_t bb_fb_index; // Current frame buffer index which used by bounce buffer
size_t int_mem_align; // DMA buffer alignment for internal memory
size_t ext_mem_align; // DMA buffer alignment for external memory
int hsync_gpio_num; // GPIO used for HSYNC signal
int vsync_gpio_num; // GPIO used for VSYNC signal
int de_gpio_num; // GPIO used for DE signal, set to -1 if it's not used
int pclk_gpio_num; // GPIO used for PCLK signal, set to -1 if it's not used
int disp_gpio_num; // GPIO used for display control signal, set to -1 if it's not used
int data_gpio_nums[SOC_LCDCAM_RGB_DATA_WIDTH]; // GPIOs used for data lines, we keep these GPIOs for action like "invert_color"
gpio_num_t hsync_gpio_num; // GPIO used for HSYNC signal
gpio_num_t vsync_gpio_num; // GPIO used for VSYNC signal
gpio_num_t de_gpio_num; // GPIO used for DE signal, set to -1 if it's not used
gpio_num_t pclk_gpio_num; // GPIO used for PCLK signal, set to -1 if it's not used
gpio_num_t disp_gpio_num; // GPIO used for display control signal, set to -1 if it's not used
gpio_num_t data_gpio_nums[SOC_LCDCAM_RGB_DATA_WIDTH]; // GPIOs used for data lines, we keep these GPIOs for action like "invert_color"
uint64_t gpio_reserve_mask; // GPIOs reserved by this panel, used to revoke the GPIO reservation when the panel is deleted
uint32_t src_clk_hz; // Peripheral source clock resolution
esp_lcd_rgb_timing_t timings; // RGB timing parameters (e.g. pclk, sync pulse, porch width)
@@ -766,36 +766,36 @@ static esp_err_t lcd_rgb_panel_configure_gpio(esp_rgb_panel_t *rgb_panel, const
if (panel_config->data_gpio_nums[i] >= 0) {
gpio_matrix_output(panel_config->data_gpio_nums[i],
lcd_periph_rgb_signals.panels[panel_id].data_sigs[i], false, false);
gpio_reserve_mask |= (1 << panel_config->data_gpio_nums[i]);
gpio_reserve_mask |= (1ULL << panel_config->data_gpio_nums[i]);
}
}
if (panel_config->hsync_gpio_num >= 0) {
gpio_matrix_output(panel_config->hsync_gpio_num,
lcd_periph_rgb_signals.panels[panel_id].hsync_sig, false, false);
gpio_reserve_mask |= (1 << panel_config->hsync_gpio_num);
gpio_reserve_mask |= (1ULL << panel_config->hsync_gpio_num);
}
if (panel_config->vsync_gpio_num >= 0) {
gpio_matrix_output(panel_config->vsync_gpio_num,
lcd_periph_rgb_signals.panels[panel_id].vsync_sig, false, false);
gpio_reserve_mask |= (1 << panel_config->vsync_gpio_num);
gpio_reserve_mask |= (1ULL << panel_config->vsync_gpio_num);
}
// PCLK may not be necessary in some cases (i.e. VGA output)
if (panel_config->pclk_gpio_num >= 0) {
gpio_matrix_output(panel_config->pclk_gpio_num,
lcd_periph_rgb_signals.panels[panel_id].pclk_sig, false, false);
gpio_reserve_mask |= (1 << panel_config->pclk_gpio_num);
gpio_reserve_mask |= (1ULL << panel_config->pclk_gpio_num);
}
// DE signal might not be necessary for some RGB LCD
if (panel_config->de_gpio_num >= 0) {
gpio_matrix_output(panel_config->de_gpio_num,
lcd_periph_rgb_signals.panels[panel_id].de_sig, false, false);
gpio_reserve_mask |= (1 << panel_config->de_gpio_num);
gpio_reserve_mask |= (1ULL << panel_config->de_gpio_num);
}
// disp enable GPIO is optional, it is a general purpose output GPIO
if (panel_config->disp_gpio_num >= 0) {
gpio_matrix_output(panel_config->disp_gpio_num,
lcd_periph_rgb_signals.panels[panel_id].disp_sig, false, false);
gpio_reserve_mask |= (1 << panel_config->disp_gpio_num);
gpio_reserve_mask |= (1ULL << panel_config->disp_gpio_num);
}
// reserve the GPIOs

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -10,7 +10,6 @@
#include "esp_err.h"
#include "esp_lcd_types.h"
#include "soc/soc_caps.h"
#include "hal/lcd_types.h"
#ifdef __cplusplus
extern "C" {
@@ -117,11 +116,6 @@ typedef esp_lcd_rgb_panel_general_cb_t esp_lcd_rgb_panel_vsync_cb_t;
*/
typedef bool (*esp_lcd_rgb_panel_bounce_buf_fill_cb_t)(esp_lcd_panel_handle_t panel, void *bounce_buf, int pos_px, int len_bytes, void *user_ctx);
/** @cond */
/// for backward compatible
typedef esp_lcd_rgb_panel_frame_buf_complete_cb_t esp_lcd_rgb_panel_bounce_buf_finish_cb_t __attribute__((deprecated("esp_lcd_rgb_panel_bounce_buf_finish_cb_t is deprecated, use esp_lcd_rgb_panel_frame_buf_complete_cb_t instead")));
/** @endcond */
/**
* @brief Group of supported RGB LCD panel callbacks
* @note The callbacks are all running under ISR environment
@@ -133,10 +127,7 @@ typedef struct {
But doesn't mean the draw buffer finishes the refreshing to the screen. */
esp_lcd_rgb_panel_vsync_cb_t on_vsync; /*!< VSYNC event callback */
esp_lcd_rgb_panel_bounce_buf_fill_cb_t on_bounce_empty; /*!< Bounce buffer empty callback. */
union {
esp_lcd_rgb_panel_frame_buf_complete_cb_t on_bounce_frame_finish __attribute__((deprecated)); /*!< Bounce buffer finish callback. */
esp_lcd_rgb_panel_frame_buf_complete_cb_t on_frame_buf_complete; /*!< A whole frame buffer was just sent to the LCD DMA */
};
} esp_lcd_rgb_panel_event_callbacks_t;
/**
@@ -151,17 +142,13 @@ typedef struct {
size_t num_fbs; /*!< Number of screen-sized frame buffers that allocated by the driver. By default (set to either 0 or 1) only one frame buffer will be used. Maximum number of buffers are 3 */
size_t bounce_buffer_size_px; /*!< If it's non-zero, the driver allocates two DRAM bounce buffers for DMA use.
DMA fetching from DRAM bounce buffer is much faster than PSRAM frame buffer. */
size_t sram_trans_align __attribute__((deprecated)); /*!< Alignment of buffers (frame buffer or bounce buffer) that allocated in SRAM */
union {
size_t psram_trans_align __attribute__((deprecated)); /*!< Alignment of buffers (frame buffer) that allocated in PSRAM */
size_t dma_burst_size; /*!< DMA burst size, in bytes */
};
int hsync_gpio_num; /*!< GPIO used for HSYNC signal */
int vsync_gpio_num; /*!< GPIO used for VSYNC signal */
int de_gpio_num; /*!< GPIO used for DE signal, set to -1 if it's not used */
int pclk_gpio_num; /*!< GPIO used for PCLK signal, set to -1 if it's not used */
int disp_gpio_num; /*!< GPIO used for display control signal, set to -1 if it's not used */
int data_gpio_nums[SOC_LCDCAM_RGB_DATA_WIDTH]; /*!< GPIOs used for data lines */
gpio_num_t hsync_gpio_num; /*!< GPIO used for HSYNC signal */
gpio_num_t vsync_gpio_num; /*!< GPIO used for VSYNC signal */
gpio_num_t de_gpio_num; /*!< GPIO used for DE signal, set to -1 if it's not used */
gpio_num_t pclk_gpio_num; /*!< GPIO used for PCLK signal, set to -1 if it's not used */
gpio_num_t disp_gpio_num; /*!< GPIO used for display control signal, set to -1 if it's not used */
gpio_num_t data_gpio_nums[SOC_LCDCAM_RGB_DATA_WIDTH]; /*!< GPIOs used for data lines */
struct {
uint32_t disp_active_low: 1; /*!< If this flag is enabled, a low level of display control signal can turn the screen on; vice versa */
uint32_t refresh_on_demand: 1; /*!< If this flag is enabled, the host only refresh the frame buffer in `esp_lcd_panel_draw_bitmap` and `esp_lcd_rgb_panel_refresh`. */

View File

@@ -47,7 +47,7 @@ typedef struct {
esp_lcd_panel_io_t base; // Base class of generic lcd panel io
spi_device_handle_t spi_dev; // SPI device handle
size_t spi_trans_max_bytes; // Maximum bytes that can be transmitted in one spi transaction
int dc_gpio_num; // D/C line GPIO number
gpio_num_t dc_gpio_num; // D/C line GPIO number
esp_lcd_panel_io_color_trans_done_cb_t on_color_trans_done; // User register's callback, invoked when color data trans done
void *user_ctx; // User's private data, passed directly to callback on_color_trans_done
size_t queue_size; // Size of transaction queue

View File

@@ -43,7 +43,7 @@ static esp_err_t panel_nt35510_sleep(esp_lcd_panel_t *panel, bool sleep);
typedef struct {
esp_lcd_panel_t base;
esp_lcd_panel_io_handle_t io;
int reset_gpio_num;
gpio_num_t reset_gpio_num;
bool reset_level;
int x_gap;
int y_gap;

View File

@@ -72,11 +72,6 @@ esp_err_t esp_lcd_panel_disp_on_off(esp_lcd_panel_handle_t panel, bool on_off)
return panel->disp_on_off(panel, on_off);
}
esp_err_t esp_lcd_panel_disp_off(esp_lcd_panel_handle_t panel, bool off)
{
return esp_lcd_panel_disp_on_off(panel, !off);
}
esp_err_t esp_lcd_panel_disp_sleep(esp_lcd_panel_handle_t panel, bool sleep)
{
ESP_RETURN_ON_FALSE(panel, ESP_ERR_INVALID_ARG, TAG, "invalid panel handle");

View File

@@ -56,7 +56,7 @@ typedef struct {
esp_lcd_panel_t base;
esp_lcd_panel_io_handle_t io;
uint8_t height;
int reset_gpio_num;
gpio_num_t reset_gpio_num;
int x_gap;
int y_gap;
unsigned int bits_per_pixel;

View File

@@ -46,7 +46,7 @@ static esp_err_t panel_st7789_sleep(esp_lcd_panel_t *panel, bool sleep);
typedef struct {
esp_lcd_panel_t base;
esp_lcd_panel_io_handle_t io;
int reset_gpio_num;
gpio_num_t reset_gpio_num;
bool reset_level;
int x_gap;
int y_gap;

View File

@@ -1,5 +1,5 @@
set(srcs "test_app_main.c"
"test_i2c_lcd_panel.c")
"test_i2c_lcd_panel.cpp")
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE

View File

@@ -12,8 +12,8 @@ extern "C" {
#define TEST_LCD_H_RES 128
#define TEST_LCD_V_RES 64
#define TEST_I2C_SDA_GPIO 0
#define TEST_I2C_SCL_GPIO 2
#define TEST_I2C_SDA_GPIO GPIO_NUM_0
#define TEST_I2C_SCL_GPIO GPIO_NUM_2
#define TEST_I2C_HOST_ID 0

View File

@@ -27,13 +27,20 @@ TEST_CASE("lcd_panel_with_i2c_interface_(ssd1306)", "[lcd]")
};
i2c_master_bus_config_t i2c_bus_conf = {
.clk_source = I2C_CLK_SRC_DEFAULT,
.i2c_port = -1, // automatically select a free I2C port
.sda_io_num = TEST_I2C_SDA_GPIO,
.scl_io_num = TEST_I2C_SCL_GPIO,
.i2c_port = -1,
.clk_source = I2C_CLK_SRC_DEFAULT,
.glitch_ignore_cnt = 4,
.intr_priority = 0,
.trans_queue_depth = 0, // no tx queue, transmit using blocking mode
.flags = {
.enable_internal_pullup = true,
.allow_pd = false,
}
};
i2c_master_bus_handle_t bus_handle;
i2c_master_bus_handle_t bus_handle = NULL;
TEST_ESP_OK(i2c_new_master_bus(&i2c_bus_conf, &bus_handle));
esp_lcd_panel_io_handle_t io_handle = NULL;
@@ -44,14 +51,26 @@ TEST_CASE("lcd_panel_with_i2c_interface_(ssd1306)", "[lcd]")
.dc_bit_offset = 6, // According to SSD1306 datasheet
.lcd_cmd_bits = 8, // According to SSD1306 datasheet
.lcd_param_bits = 8, // According to SSD1306 datasheet
.on_color_trans_done = NULL,
.user_ctx = NULL,
.flags = {
.dc_low_on_data = false, // According to SSD1306 datasheet, DC=0 means command, DC=1 means data
.disable_control_phase = false, // Control phase is used
}
};
TEST_ESP_OK(esp_lcd_new_panel_io_i2c(bus_handle, &io_config, &io_handle));
esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_panel_dev_config_t panel_config = {
.bits_per_pixel = 1,
.reset_gpio_num = -1,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR, // SSD1306 is monochrome, so RGB order doesn't matter
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = 1, // SSD1306 is monochrome, so 1 bit per pixel
.reset_gpio_num = GPIO_NUM_NC,
.vendor_config = NULL,
.flags = {
.reset_active_high = false, // SSD1306 reset is active low
}
};
TEST_ESP_OK(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle));
TEST_ESP_OK(esp_lcd_panel_reset(panel_handle));

View File

@@ -80,7 +80,7 @@ Application Example
.. list::
* :example:`peripherals/lcd/tjpgd` shows how to decode a JPEG image and display it on an SPI-interfaced LCD, and rotate the image periodically.
:SOC_GPSPI_SUPPORTED: * :example:`peripherals/lcd/spi_lcd_touch` demonstrates how to use the `esp_lcd` component to add custom panel drivers, specifically GC9A01 or ILI9341, in an ESP-IDF project, and how to enable the STMPE610 touch controller.
:SOC_GPSPI_SUPPORTED: * :example:`peripherals/lcd/spi_lcd_touch` demonstrates how to drive the LCD and touch panel on the same SPI bus, and display a simple GUI using the LVGL library.
:SOC_LCD_I80_SUPPORTED: * :example:`peripherals/lcd/i80_controller` demonstrates how to port the LVGL library onto the `esp_lcd` driver layer to create GUIs.
:SOC_LCD_RGB_SUPPORTED: * :example:`peripherals/lcd/rgb_panel` demonstrates how to install an RGB panel driver, display a scatter chart on the screen based on the LVGL library.
:SOC_I2C_SUPPORTED: * :example:`peripherals/lcd/i2c_oled` demonstrates how to use the SSD1306 panel driver from the `esp_lcd` component to facilitate the porting of LVGL library and display a scrolling text on the OLED screen.

View File

@@ -137,3 +137,14 @@ SDMMC
----------------------------------------------
The legacy Sigma-Delta Modulator driver ``driver/sigmadelta.h`` is deprecated since version 5.0 (see :ref:`deprecate_sdm_legacy_driver`). Starting from version 6.0, the legacy driver is completely removed. The new driver is placed in the :component:`esp_driver_sdm`, and the header file path is ``driver/sdm.h``.
LCD
---
- The GPIO number type in the LCD driver has been changed from ``int`` to the more type-safe ``gpio_num_t``. For example, instead of using ``5`` as the GPIO number, you now need to use ``GPIO_NUM_5``.
- The ``psram_trans_align`` and ``sram_trans_align`` members in the :cpp:type:`esp_lcd_i80_bus_config_t` structure have been replaced by the :cpp:member:`esp_lcd_i80_bus_config_t::dma_burst_size` member, which sets the DMA burst transfer size.
- The ``psram_trans_align`` and ``sram_trans_align`` members in the :cpp:type:`esp_lcd_rgb_panel_config_t` structure have also been replaced by the :cpp:member:`esp_lcd_rgb_panel_config_t::dma_burst_size` member for configuring the DMA burst transfer size.
- The ``octal_mode`` and ``quad_mode`` flags in the :cpp:type:`esp_lcd_panel_io_spi_config_t` structure have been removed. The driver now automatically detects the data line mode of the current SPI bus.
- The ``color_space`` and ``rgb_endian`` configuration options in the :cpp:type:`esp_lcd_panel_dev_config_t` structure have been replaced by the :cpp:member:`esp_lcd_panel_dev_config_t::rgb_ele_order` member, which sets the RGB element order. The corresponding types ``lcd_color_rgb_endian_t`` and ``esp_lcd_color_space_t`` have also been removed; use :cpp:type:`lcd_rgb_element_order_t` instead.
- The ``esp_lcd_panel_disp_off`` function has been removed. Please use the :func:`esp_lcd_panel_disp_on_off` function to control display on/off.
- The ``on_bounce_frame_finish`` member in :cpp:type:`esp_lcd_rgb_panel_event_callbacks_t` has been replaced by :cpp:member:`esp_lcd_rgb_panel_event_callbacks_t::on_frame_buf_complete`, which indicates that a complete frame buffer has been sent to the LCD controller.

View File

@@ -80,7 +80,7 @@ LCD 数据面板操作
.. list::
* :example:`peripherals/lcd/tjpgd` 演示了如何解码 JPEG 图像并在 SPI 接口的 LCD 上显示图像,同时周期性地旋转图像。
:SOC_GPSPI_SUPPORTED: * :example:`peripherals/lcd/spi_lcd_touch` 演示了如何在 ESP-IDF 项目中使用 `esp_lcd` 组件为 LCD 屏幕添加自定义驱动,例如 GC9A01 或 ILI9341以及如何启用 STMPE610 触摸控制器
:SOC_GPSPI_SUPPORTED: * :example:`peripherals/lcd/spi_lcd_touch` 演示了如何在相同的 SPI 总线上驱动 LCD 和触摸面板,并使用 LVGL 库显示简单的图形用户界面
:SOC_LCD_I80_SUPPORTED: * :example:`peripherals/lcd/i80_controller` 演示了如何将 LVGL 库移植到 `esp_lcd` 驱动层,以创建图形用户界面。
:SOC_LCD_RGB_SUPPORTED: * :example:`peripherals/lcd/rgb_panel` 展示了如何安装 RGB 面板驱动程序,并基于 LVGL 库在屏幕上显示散点图。
:SOC_I2C_SUPPORTED: * :example:`peripherals/lcd/i2c_oled` 演示了如何使用 `esp_lcd` 组件中的 SSD1306 面板驱动来简化移植 LVGL 库,并在 OLED 屏幕上显示滚动文本。

View File

@@ -137,3 +137,14 @@ SDMMC
---------------------------------
旧版的 Sigma-Delta 调制器驱动 ``driver/sigmadelta.h`` 在 5.0 的版本中就已经被弃用(请参考 :ref:`deprecate_sdm_legacy_driver`)。从 6.0 版本开始,旧版驱动被完全移除。新驱动位于 :component:`esp_driver_sdm` 组件中,头文件引用路径为 ``driver/sdm.h``
LCD
---
- LCD 驱动中的 GPIO 编号已经从 ``int`` 类型修改为更加类型安全的 ``gpio_num_t`` 类型。比如原来使用 ``5`` 作为 GPIO 编号,现在需要使用 ``GPIO_NUM_5``
- :cpp:type:`esp_lcd_i80_bus_config_t` 结构体中的 ``psram_trans_align````sram_trans_align`` 均已被 :cpp:member:`esp_lcd_i80_bus_config_t::dma_burst_size` 成员取代,用来设置 DMA 的突发传输大小。
- :cpp:type:`esp_lcd_rgb_panel_config_t` 结构体中的 ``psram_trans_align````sram_trans_align`` 均已被 :cpp:member:`esp_lcd_rgb_panel_config_t::dma_burst_size` 成员取代,用来设置 DMA 的突发传输大小。
- :cpp:type:`esp_lcd_panel_io_spi_config_t` 结构体中的 ``octal_mode````quad_mode`` 标志均已删除,驱动已经可以自动探测到当前 SPI 总线的数据线模式。
- :cpp:type:`esp_lcd_panel_dev_config_t` 结构体中的 ``color_space````rgb_endian`` 配置均已被 :cpp:member:`esp_lcd_panel_dev_config_t::rgb_ele_order` 成员取代,用来设置 RGB 元素的排列顺序。对应的类型 ``lcd_color_rgb_endian_t````esp_lcd_color_space_t`` 也已被移除,请使用 :cpp:type:`lcd_rgb_element_order_t` 替代。
- ``esp_lcd_panel_disp_off`` 函数已被移除。请使用 :func:`esp_lcd_panel_disp_on_off` 函数来控制显示内容的开关。
- :cpp:type:`esp_lcd_rgb_panel_event_callbacks_t` 中的 ``on_bounce_frame_finish`` 成员已被 :cpp:member:`esp_lcd_rgb_panel_event_callbacks_t::on_frame_buf_complete` 成员取代,用于指示一个完整的帧缓冲区已被发送给 LCD 控制器。

View File

@@ -91,7 +91,7 @@ static void lcd_display_init(esp_lcd_panel_handle_t *lcd_panel_hdl, esp_lcd_pane
ESP_LOGI(TAG, "New ST7789 panel");
const esp_lcd_panel_dev_config_t panel_dev_cfg = {
.reset_gpio_num = EXAMPLE_LCD_RST,
.color_space = ESP_LCD_COLOR_SPACE_RGB,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.bits_per_pixel = EXAMPLE_RGB565_BITS_PER_PIXEL,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(lcd_io_hdl, &panel_dev_cfg, &panel_handle));

View File

@@ -3,98 +3,155 @@
# SPI LCD and Touch Panel Example
[esp_lcd](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd/spi_lcd.html) provides several panel drivers out-of box, e.g. ST7789, SSD1306, NT35510. However, there're a lot of other panels on the market, it's beyond `esp_lcd` component's responsibility to include them all.
This example demonstrates how to interface an ESP32 development board with an SPI LCD display and optional touch controller using the ESP-IDF framework. The example creates an animated user interface using the LVGL graphics library. The touch controller and the LCD display share the same SPI bus, allowing for efficient communication and resource usage.
`esp_lcd` allows user to add their own panel drivers in the project scope (i.e. panel driver can live outside of esp-idf), so that the upper layer code like LVGL porting code can be reused without any modifications, as long as user-implemented panel driver follows the interface defined in the `esp_lcd` component.
## What This Example Does
This example shows how to use GC9A01 or ILI9341 display driver from Component manager in esp-idf project. These components are using API provided by `esp_lcd` component. This example will draw a fancy dash board with the LVGL library.
This example:
This example uses the [esp_timer](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/esp_timer.html) to generate the ticks needed by LVGL and uses a dedicated task to run the `lv_timer_handler()`. Since the LVGL APIs are not thread-safe, this example uses a mutex which be invoked before the call of `lv_timer_handler()` and released after it. The same mutex needs to be used in other tasks and threads around every LVGL (lv_...) related function call and code. For more porting guides, please refer to [LVGL porting doc](https://docs.lvgl.io/master/porting/index.html).
- Initializes an ST7789 LCD display connected via SPI interface
- Sets up LVGL (Light and Versatile Graphics Library) for creating user interfaces
- Displays an animated arc widget that continuously rotates
- Includes a button that allows you to rotate the screen orientation
- Optionally supports touch input through STMPE610 or XPT2046 touch controllers
## Touch controller STMPE610
## Key Components Used
In this example you can enable touch controller STMPE610 connected via SPI. The SPI connection is shared with LCD screen.
### ESP-IDF Components
- **esp_lcd**: Provides the abstracted LCD panel driver interface and ST7789 device driver
- **esp_timer**: Generates periodic ticks required by LVGL for animations
- **driver/spi_master**: Creates and manages the SPI bus for communication with the LCD and touch controller
### External Components (from Component Registry)
- **LVGL**: Modern graphics library for creating user interfaces
- **esp_lcd_touch_stmpe610**: Touch controller driver for STMPE610
- **esp_lcd_touch_xpt2046**: Touch controller driver for XPT2046
## Technical Implementation
The example implements several important concepts:
- **Thread Safety**: Uses mutex locks to protect LVGL API calls since LVGL is not thread-safe
- **Double Buffering**: Implements efficient display updates using dual display buffers
- **Memory Management**: Uses DMA-capable memory allocation for optimal performance
- **Event Handling**: Demonstrates proper callback registration for display and touch events
## How to use the example
### Hardware Required
### Hardware Requirements
* An ESP development board
* An GC9A01 or ILI9341 LCD panel, with SPI interface (with/without STMPE610 SPI touch)
* An USB cable for power supply and programming
To run this example, you will need:
### Hardware Connection
- **ESP Development Board**: Any compatible board, the supported ESP chips are listed in the table above.
- **ST7789 LCD Display**: 240x320 pixel TFT display with SPI interface
- **USB Cable**: For power supply and programming
- **Jumper Wires**: For connecting the display to your ESP board
- **Touch Controller**: STMPE610 or XPT2046 touch controller (if you want touch functionality)
The connection between ESP Board and the LCD is as follows:
### Hardware Connections
```
ESP Board GC9A01/ILI9341 Panel + TOUCH
┌──────────────────────┐ ┌────────────────────┐
│ GND ├─────────────►│ GND │
│ │ │ │
│ 3V3 ├─────────────►│ VCC │
│ │ │ │
PCLK ├─────────────►│ SCL
MOSI ├─────────────►│ MOSI
MISO |◄─────────────┤ MISO
RST ├─────────────►│ RES
DC ├─────────────►│ DC
LCD CS ├─────────────►│ LCD CS
TOUCH CS ├─────────────►│ TOUCH CS
BK_LIGHT ├─────────────►│ BLK
└──────────────────────┘ └────────────────────┘
Connect your ESP development board to the ST7789 LCD display as shown below. Make sure to power off your board before making any connections.
### Wiring Diagram
```text
ESP Development Board ST7789 LCD Display
+----------------------+ +--------------------+
| GND +------------->| GND |
| | | |
| 3V3 +------------->| VCC |
| | | |
| PCLK +------------->| SCL |
| | | |
| MOSI +------------->| MOSI |
| | | |
| MISO |<-------------+ MISO |
| | | |
| RST +------------->| RES |
| | | |
| DC +------------->| DC |
| | | |
| LCD CS +------------->| LCD CS |
| | | |
| TOUCH CS +------------->| TOUCH CS |
| | | |
| BK_LIGHT +------------->| BLK |
+----------------------+ +--------------------+
```
The GPIO number used by this example can be changed in [lvgl_example_main.c](main/spi_lcd_touch_example_main.c).
Especially, please pay attention to the level used to turn on the LCD backlight, some LCD module needs a low level to turn it on, while others take a high level. You can change the backlight level macro `EXAMPLE_LCD_BK_LIGHT_ON_LEVEL` in [lvgl_example_main.c](main/spi_lcd_touch_example_main.c).
### Pin Configuration Notes
### Build and Flash
- **GPIO Pin Numbers**: The pin assignments shown above are the default values defined in the example code. You can modify these in the [main.c](main/spi_lcd_touch_example_main.c) file if needed.
- **SPI Interface**: This example uses SPI2 by default. The MISO pin (GPIO 21) is optional and only needed if you use the touch controller to read the touch coordinates.
- **Backlight Control**: The backlight pin controls the display brightness. The example uses active-low logic by default (set `EXAMPLE_LCD_BK_LIGHT_ON_LEVEL` to 1 if your display requires active-high).
- **Touch Controller**: If using a touch controller, it shares the same SPI bus but uses a separate chip select pin.
Run `idf.py -p PORT build flash monitor` to build, flash and monitor the project. A fancy animation will show up on the LCD as expected.
## Getting Started
The first time you run `idf.py` for the example will cost extra time as the build system needs to address the component dependencies and downloads the missing components from the ESP Component Registry into `managed_components` folder.
### Configuration Options
(To exit the serial monitor, type ``Ctrl-]``.)
This example provides several configuration options through the ESP-IDF configuration system:
```bash
idf.py menuconfig
```
Navigate to "Example Configuration" to find:
- **Enable LCD touch**: Toggle touch controller support on/off
- **LCD touch controller model**: Choose between STMPE610 and XPT2046
- **Display mirroring options**: Adjust for different touch controller orientations
### Exiting the Monitor
To exit the serial monitor, press `Ctrl+]`.
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
### Example Output
## What to Expect
```bash
...
I (409) cpu_start: Starting scheduler on APP CPU.
I (419) example: Turn off LCD backlight
I (419) gpio: GPIO[2]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (429) example: Initialize SPI bus
I (439) example: Install panel IO
I (439) gpio: GPIO[5]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (449) example: Install GC9A01 panel driver
I (459) gpio: GPIO[3]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (589) gpio: GPIO[0]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (589) example: Initialize touch controller STMPE610
I (589) STMPE610: TouchPad ID: 0x0811
I (589) STMPE610: TouchPad Ver: 0x03
I (599) example: Turn on LCD backlight
I (599) example: Initialize LVGL library
I (609) example: Register display driver to LVGL
I (619) example: Install LVGL tick timer
I (619) example: Starting LVGL task
I (619) example: Display LVGL animation
I (619) example: Display LVGL Meter Widget
...
When the example runs successfully, you should see:
### Visual Output
- **LCD Display**: The screen will show an animated rotating arc (progress bar style)
- **Rotate Button**: A button labeled "ROTATE" in the bottom-left corner
- **Smooth Animation**: The arc continuously rotates, demonstrating LVGL's animation capabilities
### Touch Interaction (if enabled)
- **Screen Rotation**: Tap the "ROTATE" button to cycle through different screen orientations (0°, 90°, 180°, 270°)
- **Touch Feedback**: The display responds immediately to touch input
### Console Output
```text
I (307) main_task: Started on CPU0
I (307) main_task: Calling app_main()
I (307) example: Turn off LCD backlight
I (307) example: Initialize SPI bus
I (317) example: Install panel IO
I (317) example: Install ST7789 panel driver
I (447) example: Turn on LCD backlight
I (447) example: Initialize LVGL library
I (457) example: Install LVGL tick timer
I (457) example: Register io panel event callback for LVGL flush ready notification
I (457) example: Create LVGL task
I (467) example: Starting LVGL task
I (547) example: Display LVGL Meter Widget
I (557) main_task: Returned from app_main()
```
## Learning Resources
### Documentation Links
- [ESP-IDF SPI LCD Documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd/spi_lcd.html)
- [LVGL Documentation](https://docs.lvgl.io/master/)
- [ESP Component Registry](https://components.espressif.com/)
## Troubleshooting
* Why the LCD doesn't light up?
* Check the backlight's turn-on level, and update it in `EXAMPLE_LCD_BK_LIGHT_ON_LEVEL`
For any technical queries, please open an [issue] (https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.

View File

@@ -1,18 +1,5 @@
menu "Example Configuration"
choice EXAMPLE_LCD_CONTROLLER
prompt "LCD controller model"
default EXAMPLE_LCD_CONTROLLER_ILI9341
help
Select LCD controller model
config EXAMPLE_LCD_CONTROLLER_ILI9341
bool "ILI9341"
config EXAMPLE_LCD_CONTROLLER_GC9A01
bool "GC9A01"
endchoice
config EXAMPLE_LCD_TOUCH_ENABLED
bool "Enable LCD touch"
default n

View File

@@ -1,6 +1,4 @@
dependencies:
lvgl/lvgl: 9.2.0
esp_lcd_ili9341: ^1.0
esp_lcd_gc9a01: ^1.0
esp_lcd_touch_stmpe610: ^1.0
atanisoft/esp_lcd_touch_xpt2046: 1.0.5
lvgl/lvgl: 9.3.0
esp_lcd_touch_stmpe610: ^1.0.0
atanisoft/esp_lcd_touch_xpt2046: 1.0.6

View File

@@ -14,18 +14,13 @@
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_st7789.h"
#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "esp_err.h"
#include "esp_log.h"
#include "lvgl.h"
#if CONFIG_EXAMPLE_LCD_CONTROLLER_ILI9341
#include "esp_lcd_ili9341.h"
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_GC9A01
#include "esp_lcd_gc9a01.h"
#endif
#if CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_STMPE610
#include "esp_lcd_touch_stmpe610.h"
#elif CONFIG_EXAMPLE_LCD_TOUCH_CONTROLLER_XPT2046
@@ -41,7 +36,7 @@ static const char *TAG = "example";
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (20 * 1000 * 1000)
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 0
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define EXAMPLE_PIN_NUM_SCLK 18
#define EXAMPLE_PIN_NUM_MOSI 19
@@ -53,13 +48,8 @@ static const char *TAG = "example";
#define EXAMPLE_PIN_NUM_TOUCH_CS 15
// The pixel number in horizontal and vertical
#if CONFIG_EXAMPLE_LCD_CONTROLLER_ILI9341
#define EXAMPLE_LCD_H_RES 240
#define EXAMPLE_LCD_V_RES 320
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_GC9A01
#define EXAMPLE_LCD_H_RES 240
#define EXAMPLE_LCD_V_RES 240
#endif
// Bit number used to represent command and parameter
#define EXAMPLE_LCD_CMD_BITS 8
#define EXAMPLE_LCD_PARAM_BITS 8
@@ -203,7 +193,7 @@ void app_main(void)
.trans_queue_depth = 10,
};
// Attach the LCD to the SPI bus
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_HOST, &io_config, &io_handle));
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi(LCD_HOST, &io_config, &io_handle));
esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_panel_dev_config_t panel_config = {
@@ -211,19 +201,10 @@ void app_main(void)
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
.bits_per_pixel = 16,
};
#if CONFIG_EXAMPLE_LCD_CONTROLLER_ILI9341
ESP_LOGI(TAG, "Install ILI9341 panel driver");
ESP_ERROR_CHECK(esp_lcd_new_panel_ili9341(io_handle, &panel_config, &panel_handle));
#elif CONFIG_EXAMPLE_LCD_CONTROLLER_GC9A01
ESP_LOGI(TAG, "Install GC9A01 panel driver");
ESP_ERROR_CHECK(esp_lcd_new_panel_gc9a01(io_handle, &panel_config, &panel_handle));
#endif
ESP_LOGI(TAG, "Install ST7789 panel driver");
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
#if CONFIG_EXAMPLE_LCD_CONTROLLER_GC9A01
ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle, true));
#endif
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, true, false));
// user can flush pre-defined pattern to the screen before we turn on the screen or backlight

View File

@@ -1,3 +1,4 @@
CONFIG_LV_CONF_SKIP=y
CONFIG_LV_USE_OBSERVER=y
CONFIG_LV_USE_SYSMON=y
CONFIG_LV_USE_PERF_MONITOR=y

View File

@@ -106,9 +106,9 @@ static esp_err_t i2c_master_init(void)
i2c_config_t conf_master = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_SDA_GPIO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.sda_pullup_en = true,
.scl_io_num = I2C_SCL_GPIO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = true,
.master.clk_speed = I2C_CLK_FREQUENCY,
};

View File

@@ -3,10 +3,6 @@ set(srcs cxx_build_test_main.cpp
test_cxx_standard.cpp
test_sdmmc_sdspi_init.cpp)
if(CONFIG_SOC_I2C_SUPPORTED)
list(APPEND srcs test_i2c_lcd.cpp)
endif()
if(CONFIG_SOC_I2S_SUPPORTED)
list(APPEND srcs test_i2s.cpp)
endif()
@@ -17,5 +13,4 @@ endif()
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "."
PRIV_REQUIRES driver esp_lcd esp_driver_i2s
REQUIRES soc)
PRIV_REQUIRES driver esp_driver_i2s)

View File

@@ -1,79 +0,0 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_io.h"
#include "driver/i2c_master.h"
const esp_lcd_panel_dev_config_t panel_config0 = {
.reset_gpio_num = 0,
.color_space = ESP_LCD_COLOR_SPACE_MONOCHROME,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = 16,
.flags = {
.reset_active_high = false,
},
.vendor_config = NULL,
};
const esp_lcd_panel_dev_config_t panel_config1 = {
.reset_gpio_num = 0,
.color_space = ESP_LCD_COLOR_SPACE_BGR,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = 16,
.flags = {
.reset_active_high = false,
},
.vendor_config = NULL,
};
const esp_lcd_panel_dev_config_t panel_config2 = {
.reset_gpio_num = 0,
.rgb_endian = LCD_RGB_ENDIAN_BGR,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = 16,
.flags = {
.reset_active_high = false,
},
.vendor_config = NULL,
};
void test_i2c_lcd_apis(void)
{
i2c_master_bus_config_t i2c_bus_conf = {
.i2c_port = -1,
.sda_io_num = GPIO_NUM_0,
.scl_io_num = GPIO_NUM_2,
.clk_source = I2C_CLK_SRC_DEFAULT,
.glitch_ignore_cnt = 0,
.intr_priority = 1,
.trans_queue_depth = 4,
.flags = {
.enable_internal_pullup = true,
.allow_pd = false,
}
};
i2c_master_bus_handle_t bus_handle;
i2c_new_master_bus(&i2c_bus_conf, &bus_handle);
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_io_i2c_config_t io_config = {
.dev_addr = 0x3c,
.on_color_trans_done = NULL,
.user_ctx = NULL,
.control_phase_bytes = 1,
.dc_bit_offset = 6,
.lcd_cmd_bits = 8,
.lcd_param_bits = 8,
.flags = {
.dc_low_on_data = false,
.disable_control_phase = false,
},
.scl_speed_hz = 10 * 1000,
};
esp_lcd_new_panel_io_i2c(bus_handle, &io_config, &io_handle);
}