Skip to content

Commit 8d8d8cb

Browse files
committed
fix(lcd): build errors with deprecated lcd types in cpp
Closes espressif#14029
1 parent cabf41c commit 8d8d8cb

File tree

4 files changed

+58
-23
lines changed

4 files changed

+58
-23
lines changed

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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
8+
const esp_lcd_panel_dev_config_t panel_config0 = {
9+
.reset_gpio_num = 0,
10+
.color_space = ESP_LCD_COLOR_SPACE_MONOCHROME,
11+
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
12+
.bits_per_pixel = 16,
13+
.flags = {
14+
.reset_active_high = false,
15+
},
16+
.vendor_config = NULL,
17+
};
18+
19+
const esp_lcd_panel_dev_config_t panel_config1 = {
20+
.reset_gpio_num = 0,
21+
.color_space = ESP_LCD_COLOR_SPACE_BGR,
22+
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
23+
.bits_per_pixel = 16,
24+
.flags = {
25+
.reset_active_high = false,
26+
},
27+
.vendor_config = NULL,
28+
};
29+
30+
const esp_lcd_panel_dev_config_t panel_config2 = {
31+
.reset_gpio_num = 0,
32+
.rgb_endian = LCD_RGB_ENDIAN_BGR,
33+
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
34+
.bits_per_pixel = 16,
35+
.flags = {
36+
.reset_active_high = false,
37+
},
38+
.vendor_config = NULL,
39+
};

0 commit comments

Comments
 (0)