Skip to content

Commit 0903bcc

Browse files
committed
Merge branch 'fix/lcd_build_error_in_cpp_v5.3' into 'release/v5.3'
fix(lcd): build errors with deprecated lcd types in cpp (v5.3) See merge request espressif/esp-idf!31676
2 parents ea05ae7 + fe2b23b commit 0903bcc

File tree

5 files changed

+135
-26
lines changed

5 files changed

+135
-26
lines changed

components/esp_lcd/include/esp_lcd_io_i2c.h

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,43 @@ esp_err_t esp_lcd_new_panel_io_i2c_v1(uint32_t bus, const esp_lcd_panel_io_i2c_c
6767
*/
6868
esp_err_t esp_lcd_new_panel_io_i2c_v2(i2c_master_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io);
6969

70+
#ifdef __cplusplus
71+
}
72+
#endif
73+
74+
#ifdef __cplusplus
75+
/**
76+
* @brief Create LCD panel IO handle
77+
*
78+
* @param[in] bus I2C bus ID, indicates which I2C port to use
79+
* @param[in] io_config IO configuration, for I2C interface
80+
* @param[out] ret_io Returned IO handle
81+
* @return
82+
* - ESP_ERR_INVALID_ARG if parameter is invalid
83+
* - ESP_ERR_NO_MEM if out of memory
84+
* - ESP_OK on success
85+
*/
86+
static inline void esp_lcd_new_panel_io_i2c(uint32_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io)
87+
{
88+
esp_lcd_new_panel_io_i2c_v1(bus, io_config, ret_io);
89+
}
90+
91+
/**
92+
* @brief Create LCD panel IO handle
93+
*
94+
* @param[in] bus I2C bus handle, returned from `i2c_new_master_bus`
95+
* @param[in] io_config IO configuration, for I2C interface
96+
* @param[out] ret_io Returned IO handle
97+
* @return
98+
* - ESP_ERR_INVALID_ARG if parameter is invalid
99+
* - ESP_ERR_NO_MEM if out of memory
100+
* - ESP_OK on success
101+
*/
102+
static inline void esp_lcd_new_panel_io_i2c(i2c_master_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io)
103+
{
104+
esp_lcd_new_panel_io_i2c_v2(bus, io_config, ret_io);
105+
}
106+
#else
70107
/**
71108
* @brief Create LCD panel IO handle
72109
*
@@ -80,8 +117,6 @@ esp_err_t esp_lcd_new_panel_io_i2c_v2(i2c_master_bus_handle_t bus, const esp_lcd
80117
*/
81118
#define esp_lcd_new_panel_io_i2c(bus, io_config, ret_io) _Generic((bus), \
82119
i2c_master_bus_handle_t : esp_lcd_new_panel_io_i2c_v2, \
83-
default : esp_lcd_new_panel_io_i2c_v1) (bus, io_config, ret_io) \
120+
default : esp_lcd_new_panel_io_i2c_v1) (bus, io_config, ret_io)
84121

85-
#ifdef __cplusplus
86-
}
87122
#endif

components/esp_lcd/include/esp_lcd_panel_dev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ extern "C" {
2020
typedef struct {
2121
int reset_gpio_num; /*!< GPIO used to reset the LCD panel, set to -1 if it's not used */
2222
union {
23-
lcd_rgb_element_order_t color_space; /*!< @deprecated Set RGB color space, please use rgb_ele_order instead */
24-
lcd_rgb_element_order_t rgb_endian; /*!< @deprecated Set RGB data endian, please use rgb_ele_order instead */
23+
esp_lcd_color_space_t color_space; /*!< @deprecated Set RGB color space, please use rgb_ele_order instead */
24+
lcd_color_rgb_endian_t rgb_endian; /*!< @deprecated Set RGB data endian, please use rgb_ele_order instead */
2525
lcd_rgb_element_order_t rgb_ele_order; /*!< Set RGB element order, RGB or BGR */
2626
};
2727
lcd_rgb_data_endian_t data_endian; /*!< Set the data endian for color data larger than 1 byte */

components/esp_lcd/include/esp_lcd_types.h

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,15 @@ typedef enum {
4141
} lcd_rgb_element_order_t;
4242

4343
/** @cond */
44-
/**
45-
* @brief LCD color space type definition (WRONG!)
46-
* @deprecated RGB and BGR should belong to the same color space, but this enum take them both as two different color spaces.
47-
* If you want to use a enum to describe a color space, please use lcd_color_space_t instead.
48-
*/
49-
typedef enum {
50-
ESP_LCD_COLOR_SPACE_RGB, /*!< Color space: RGB */
51-
ESP_LCD_COLOR_SPACE_BGR, /*!< Color space: BGR */
52-
ESP_LCD_COLOR_SPACE_MONOCHROME, /*!< Color space: monochrome */
53-
} esp_lcd_color_space_t __attribute__((deprecated));
54-
55-
// Ensure binary compatibility with lcd_color_rgb_endian_t
56-
ESP_STATIC_ASSERT((lcd_rgb_element_order_t)ESP_LCD_COLOR_SPACE_RGB == LCD_RGB_ELEMENT_ORDER_RGB, "ESP_LCD_COLOR_SPACE_RGB is not compatible with LCD_RGB_ORDER_RGB");
57-
ESP_STATIC_ASSERT((lcd_rgb_element_order_t)ESP_LCD_COLOR_SPACE_BGR == LCD_RGB_ELEMENT_ORDER_BGR, "ESP_LCD_COLOR_SPACE_BGR is not compatible with LCD_RGB_ORDER_BGR");
58-
5944
/// for backward compatible
6045
typedef lcd_rgb_element_order_t lcd_color_rgb_endian_t;
61-
#define LCD_RGB_ENDIAN_RGB LCD_RGB_ELEMENT_ORDER_RGB
62-
#define LCD_RGB_ENDIAN_BGR LCD_RGB_ELEMENT_ORDER_BGR
46+
#define LCD_RGB_ENDIAN_RGB (lcd_color_rgb_endian_t)LCD_RGB_ELEMENT_ORDER_RGB
47+
#define LCD_RGB_ENDIAN_BGR (lcd_color_rgb_endian_t)LCD_RGB_ELEMENT_ORDER_BGR
48+
49+
typedef lcd_rgb_element_order_t esp_lcd_color_space_t;
50+
#define ESP_LCD_COLOR_SPACE_RGB (esp_lcd_color_space_t)LCD_RGB_ELEMENT_ORDER_RGB
51+
#define ESP_LCD_COLOR_SPACE_BGR (esp_lcd_color_space_t)LCD_RGB_ELEMENT_ORDER_BGR
52+
#define ESP_LCD_COLOR_SPACE_MONOCHROME (esp_lcd_color_space_t)2
6353
/** @endcond */
6454

6555
/**
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
idf_component_register(SRCS cxx_build_test_main.cpp
2-
test_soc_reg_macros.cpp
3-
test_cxx_standard.cpp
1+
set(srcs cxx_build_test_main.cpp
2+
test_soc_reg_macros.cpp
3+
test_cxx_standard.cpp)
4+
5+
if(CONFIG_SOC_I2C_SUPPORTED)
6+
list(APPEND srcs test_i2c_lcd.cpp)
7+
endif()
8+
9+
idf_component_register(SRCS "${srcs}"
410
INCLUDE_DIRS "."
5-
PRIV_REQUIRES driver
11+
PRIV_REQUIRES driver esp_lcd
612
REQUIRES soc)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
6+
#include "esp_lcd_panel_vendor.h"
7+
#include "esp_lcd_panel_io.h"
8+
#include "driver/i2c_master.h"
9+
10+
const esp_lcd_panel_dev_config_t panel_config0 = {
11+
.reset_gpio_num = 0,
12+
.color_space = ESP_LCD_COLOR_SPACE_MONOCHROME,
13+
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
14+
.bits_per_pixel = 16,
15+
.flags = {
16+
.reset_active_high = false,
17+
},
18+
.vendor_config = NULL,
19+
};
20+
21+
const esp_lcd_panel_dev_config_t panel_config1 = {
22+
.reset_gpio_num = 0,
23+
.color_space = ESP_LCD_COLOR_SPACE_BGR,
24+
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
25+
.bits_per_pixel = 16,
26+
.flags = {
27+
.reset_active_high = false,
28+
},
29+
.vendor_config = NULL,
30+
};
31+
32+
const esp_lcd_panel_dev_config_t panel_config2 = {
33+
.reset_gpio_num = 0,
34+
.rgb_endian = LCD_RGB_ENDIAN_BGR,
35+
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
36+
.bits_per_pixel = 16,
37+
.flags = {
38+
.reset_active_high = false,
39+
},
40+
.vendor_config = NULL,
41+
};
42+
43+
void test_i2c_lcd_apis(void)
44+
{
45+
i2c_master_bus_config_t i2c_bus_conf = {
46+
.i2c_port = -1,
47+
.sda_io_num = GPIO_NUM_0,
48+
.scl_io_num = GPIO_NUM_2,
49+
.clk_source = I2C_CLK_SRC_DEFAULT,
50+
.glitch_ignore_cnt = 0,
51+
.intr_priority = 1,
52+
.trans_queue_depth = 4,
53+
.flags = {
54+
.enable_internal_pullup = true,
55+
}
56+
};
57+
58+
i2c_master_bus_handle_t bus_handle;
59+
i2c_new_master_bus(&i2c_bus_conf, &bus_handle);
60+
61+
esp_lcd_panel_io_handle_t io_handle = NULL;
62+
esp_lcd_panel_io_i2c_config_t io_config = {
63+
.dev_addr = 0x3c,
64+
.on_color_trans_done = NULL,
65+
.user_ctx = NULL,
66+
.control_phase_bytes = 1,
67+
.dc_bit_offset = 6,
68+
.lcd_cmd_bits = 8,
69+
.lcd_param_bits = 8,
70+
.flags = {
71+
.dc_low_on_data = false,
72+
.disable_control_phase = false,
73+
},
74+
.scl_speed_hz = 10 * 1000,
75+
};
76+
77+
esp_lcd_new_panel_io_i2c(bus_handle, &io_config, &io_handle);
78+
}

0 commit comments

Comments
 (0)