From d63827134da2e5e7f3b683347581d3d6808008d6 Mon Sep 17 00:00:00 2001 From: marcus_xu Date: Wed, 6 Dec 2023 10:31:02 +0800 Subject: [PATCH] esp_lvgl_port: put sw_rotate in flags. --- components/esp_lvgl_port/README.md | 20 ++++++++++++------- components/esp_lvgl_port/esp_lvgl_port.c | 2 +- .../esp_lvgl_port/include/esp_lvgl_port.h | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/components/esp_lvgl_port/README.md b/components/esp_lvgl_port/README.md index f8eedca1..49115922 100644 --- a/components/esp_lvgl_port/README.md +++ b/components/esp_lvgl_port/README.md @@ -189,8 +189,10 @@ Rotation mode can be selected in the `lvgl_port_display_cfg_t` structure. ``` c const lvgl_port_display_cfg_t disp_cfg = { ... - .sw_rotate = true / false, // true: software; false: hardware - ... + .flags = { + ... + .sw_rotate = true / false, // true: software; false: hardware + } } ``` Display rotation can be changed at runtime. @@ -204,11 +206,15 @@ Display rotation can be changed at runtime. If the SRAM is insufficient, you can use the PSRAM as a canvas and use a small trans_buffer to carry it, this makes drawing more efficient. ``` c - .buffer_size = DISP_WIDTH*DISP_HEIGHT, // in PSRAM, not DMA-capable - .trans_size = size, // in SRAM, DMA-capable - .flags = { - .buff_spiram = true, - .buff_dma = false, + const lvgl_port_display_cfg_t disp_cfg = { + ... + .buffer_size = DISP_WIDTH * DISP_HEIGHT, // in PSRAM, not DMA-capable + .trans_size = size, // in SRAM, DMA-capable + .flags = { + .buff_spiram = true, + .buff_dma = false, + ... + } } ``` diff --git a/components/esp_lvgl_port/esp_lvgl_port.c b/components/esp_lvgl_port/esp_lvgl_port.c index afeefbec..db3b040a 100644 --- a/components/esp_lvgl_port/esp_lvgl_port.c +++ b/components/esp_lvgl_port/esp_lvgl_port.c @@ -268,7 +268,7 @@ lv_disp_t *lvgl_port_add_disp(const lvgl_port_display_cfg_t *disp_cfg) disp_ctx->disp_drv.hor_res = disp_cfg->hres; disp_ctx->disp_drv.ver_res = disp_cfg->vres; disp_ctx->disp_drv.flush_cb = lvgl_port_flush_callback; - disp_ctx->disp_drv.sw_rotate = disp_cfg->sw_rotate; + disp_ctx->disp_drv.sw_rotate = disp_cfg->flags.sw_rotate; if (disp_ctx->disp_drv.sw_rotate == false) { disp_ctx->disp_drv.drv_update_cb = lvgl_port_update_callback; } diff --git a/components/esp_lvgl_port/include/esp_lvgl_port.h b/components/esp_lvgl_port/include/esp_lvgl_port.h index 52766625..4b05915f 100644 --- a/components/esp_lvgl_port/include/esp_lvgl_port.h +++ b/components/esp_lvgl_port/include/esp_lvgl_port.h @@ -65,12 +65,12 @@ typedef struct { uint32_t hres; /*!< LCD display horizontal resolution */ uint32_t vres; /*!< LCD display vertical resolution */ bool monochrome; /*!< True, if display is monochrome and using 1bit for 1px */ - bool sw_rotate; /*!< Use software rotation (slower) */ lvgl_port_rotation_cfg_t rotation; /*!< Default values of the screen rotation */ struct { unsigned int buff_dma: 1; /*!< Allocated LVGL buffer will be DMA capable */ unsigned int buff_spiram: 1; /*!< Allocated LVGL buffer will be in PSRAM */ + unsigned int sw_rotate: 1; /*!< Use software rotation (slower) */ } flags; } lvgl_port_display_cfg_t;