fix(lcd): build errors with deprecated lcd types in cpp

Closes https://github.com/espressif/esp-idf/issues/14029
This commit is contained in:
morris 2024-06-20 18:09:59 +08:00
parent 0877ec2a48
commit 38ebd9c079
5 changed files with 51 additions and 21 deletions

View File

@ -19,8 +19,8 @@ extern "C" {
typedef struct { typedef struct {
int reset_gpio_num; /*!< GPIO used to reset the LCD panel, set to -1 if it's not used */ int reset_gpio_num; /*!< GPIO used to reset the LCD panel, set to -1 if it's not used */
union { union {
lcd_rgb_element_order_t color_space; /*!< @deprecated Set RGB color space, please use rgb_ele_order instead */ esp_lcd_color_space_t color_space; /*!< @deprecated Set RGB color space, please use rgb_ele_order instead */
lcd_rgb_element_order_t rgb_endian; /*!< @deprecated Set RGB data endian, 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_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 */ lcd_rgb_data_endian_t data_endian; /*!< Set the data endian for color data larger than 1 byte */

View File

@ -16,20 +16,15 @@ typedef struct esp_lcd_panel_io_t *esp_lcd_panel_io_handle_t; /*!< Type of LCD p
typedef struct esp_lcd_panel_t *esp_lcd_panel_handle_t; /*!< Type of LCD panel handle */ typedef struct esp_lcd_panel_t *esp_lcd_panel_handle_t; /*!< Type of LCD panel handle */
/** @cond */ /** @cond */
/** /// for backward compatible
* @brief LCD color space type definition (WRONG!) typedef lcd_rgb_element_order_t lcd_color_rgb_endian_t;
* @deprecated RGB and BGR should belong to the same color space, but this enum take them both as two different color spaces. #define LCD_RGB_ENDIAN_RGB (lcd_color_rgb_endian_t)LCD_RGB_ELEMENT_ORDER_RGB
* If you want to use a enum to describe a color space, please use lcd_color_space_t instead. #define LCD_RGB_ENDIAN_BGR (lcd_color_rgb_endian_t)LCD_RGB_ELEMENT_ORDER_BGR
*/
typedef enum {
ESP_LCD_COLOR_SPACE_RGB, /*!< Color space: RGB */
ESP_LCD_COLOR_SPACE_BGR, /*!< Color space: BGR */
ESP_LCD_COLOR_SPACE_MONOCHROME, /*!< Color space: monochrome */
} esp_lcd_color_space_t __attribute__((deprecated));
// Ensure binary compatibility with lcd_color_rgb_endian_t typedef lcd_rgb_element_order_t esp_lcd_color_space_t;
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"); #define ESP_LCD_COLOR_SPACE_RGB (esp_lcd_color_space_t)LCD_RGB_ELEMENT_ORDER_RGB
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"); #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 */ /** @endcond */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -28,11 +28,6 @@ typedef enum {
LCD_RGB_ELEMENT_ORDER_BGR, /*!< RGB element order: BGR */ LCD_RGB_ELEMENT_ORDER_BGR, /*!< RGB element order: BGR */
} lcd_rgb_element_order_t; } lcd_rgb_element_order_t;
/// for backward compatible
typedef lcd_rgb_element_order_t lcd_color_rgb_endian_t;
#define LCD_RGB_ENDIAN_RGB LCD_RGB_ELEMENT_ORDER_RGB
#define LCD_RGB_ENDIAN_BGR LCD_RGB_ELEMENT_ORDER_BGR
/** /**
* @brief RGB data endian * @brief RGB data endian
*/ */

View File

@ -1,8 +1,9 @@
idf_component_register(SRCS cxx_build_test_main.cpp idf_component_register(SRCS cxx_build_test_main.cpp
test_soc_reg_macros.cpp test_soc_reg_macros.cpp
test_esp_hw_support.cpp test_esp_hw_support.cpp
test_lcd.cpp
INCLUDE_DIRS "." INCLUDE_DIRS "."
PRIV_REQUIRES driver PRIV_REQUIRES driver esp_lcd
REQUIRES soc) REQUIRES soc)
set_source_files_properties(test_esp_hw_support.cpp PROPERTIES COMPILE_FLAGS -Wsign-conversion) set_source_files_properties(test_esp_hw_support.cpp PROPERTIES COMPILE_FLAGS -Wsign-conversion)

View File

@ -0,0 +1,39 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include "esp_lcd_panel_vendor.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,
};