From fe47e9401156534a152d20cd9e4bc1ef528a766a Mon Sep 17 00:00:00 2001 From: Igor Udot Date: Wed, 27 Dec 2023 10:56:45 +0800 Subject: [PATCH] feat(esp_qemu_rgb_panel): implement 16bpp QEMU RGB panel --- .../lcd_qemu_rgb_panel/main/lcd_qemu_rgb_panel_main.c | 8 +++----- esp_lcd_qemu_rgb/interface/esp_lcd_qemu_rgb.h | 5 +++++ esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb.c | 3 ++- esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb_struct.h | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/esp_lcd_qemu_rgb/examples/lcd_qemu_rgb_panel/main/lcd_qemu_rgb_panel_main.c b/esp_lcd_qemu_rgb/examples/lcd_qemu_rgb_panel/main/lcd_qemu_rgb_panel_main.c index 6319c2dd43..be28f7d930 100644 --- a/esp_lcd_qemu_rgb/examples/lcd_qemu_rgb_panel/main/lcd_qemu_rgb_panel_main.c +++ b/esp_lcd_qemu_rgb/examples/lcd_qemu_rgb_panel/main/lcd_qemu_rgb_panel_main.c @@ -21,11 +21,8 @@ static const char *TAG = "example"; /** - * Only 32-bit colors are currently supported by QEMU RGB Panel + * 16-bit and 32-bit colors are currently supported by QEMU RGB Panel */ -#if !CONFIG_LV_COLOR_DEPTH_32 -#error "QEMU RGB Panel only support 32-bit colors, please enable LV_COLOR_DEPTH_32" -#endif // The pixel number in horizontal and vertical #define EXAMPLE_LCD_H_RES 800 @@ -120,7 +117,8 @@ void app_main(void) esp_lcd_panel_handle_t panel_handle = NULL; esp_lcd_rgb_qemu_config_t panel_config = { .width = EXAMPLE_LCD_H_RES, - .height = EXAMPLE_LCD_V_RES + .height = EXAMPLE_LCD_V_RES, + .bpp = RGB_QEMU_BPP_32, }; ESP_ERROR_CHECK(esp_lcd_new_rgb_qemu(&panel_config, &panel_handle)); diff --git a/esp_lcd_qemu_rgb/interface/esp_lcd_qemu_rgb.h b/esp_lcd_qemu_rgb/interface/esp_lcd_qemu_rgb.h index 9f1f44ac96..9b9c4ffa9b 100644 --- a/esp_lcd_qemu_rgb/interface/esp_lcd_qemu_rgb.h +++ b/esp_lcd_qemu_rgb/interface/esp_lcd_qemu_rgb.h @@ -13,12 +13,17 @@ extern "C" { #endif +typedef enum { + RGB_QEMU_BPP_32 = 32, + RGB_QEMU_BPP_16 = 16, +} esp_lcd_rgb_qemu_bpp_t; /** * @brief QEMU RGB panel configuration structure */ typedef struct { uint32_t width; /*!< Width of the graphical window in pixels */ uint32_t height; /*!< Height of the graphical window in pixels */ + esp_lcd_rgb_qemu_bpp_t bpp; /*!< BPP - bit per pixel*/ } esp_lcd_rgb_qemu_config_t; /** diff --git a/esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb.c b/esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb.c index 428f34d12c..7d43eb8375 100644 --- a/esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb.c +++ b/esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb.c @@ -58,9 +58,10 @@ esp_err_t esp_lcd_new_rgb_qemu(const esp_lcd_rgb_qemu_config_t *rgb_config, esp_ rgb_panel = calloc(1, sizeof(esp_rgb_qemu_t)); ESP_GOTO_ON_FALSE(rgb_panel, ESP_ERR_NO_MEM, err, TAG, "no mem for rgb qemu panel"); - /* Resize the window */ + /* Resize the window and setup bpp*/ s_rgb_dev->size.height = rgb_config->height; s_rgb_dev->size.width = rgb_config->width; + s_rgb_dev->bpp = rgb_config->bpp; /* If the configured size is bigger than authorized, the hardware will arrange it. * So, read back the configured size */ rgb_panel->height = rgb_config->height; diff --git a/esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb_struct.h b/esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb_struct.h index 24e5f35e34..0389465270 100644 --- a/esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb_struct.h +++ b/esp_lcd_qemu_rgb/src/esp_lcd_qemu_rgb_struct.h @@ -50,6 +50,7 @@ typedef volatile struct rgb_qemu_dev_s { }; uint32_t val; } update_st; + uint32_t bpp; } rgb_qemu_dev_t; #ifdef __cplusplus