diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f8251a4..5d6536b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: name: Update BSP README with dependencies section entry: .github/ci/update_readme_dependencies.py language: python - files: 'bsp\/.*\/include\/.*\.h|bsp\/\w*\/idf_component\.yml|bsp\/\w*\/README\.md' # All idf_component.yml, README.md and .h files in bsp directory + files: 'bsp\/.*\/include\/.*\.h|bsp\/.*\/idf_component\.yml|bsp\/.*\/README\.md' # All idf_component.yml, README.md and .h files in bsp directory additional_dependencies: - idf_component_manager==1.4.2 - py-markdown-table diff --git a/bsp/esp-box-3/README.md b/bsp/esp-box-3/README.md index ad3b126a..f185aeca 100644 --- a/bsp/esp-box-3/README.md +++ b/bsp/esp-box-3/README.md @@ -16,15 +16,15 @@ ESP32-S3-BOX-3 also uses a Type-C USB connector that provides 5 V of power input ### Capabilities and dependencies -| Capability | Available | Component |Version| -|-------------|------------------|----------------------------------------------------------------------------------------------------------|-------| -| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341) | ^1 | -| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 | -| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | >=2.5 | -| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1| -|AUDIO_SPEAKER|:heavy_check_mark:| | | -| AUDIO_MIC |:heavy_check_mark:| | | -| SDCARD |:heavy_check_mark:| idf | >=5.3 | -| IMU |:heavy_check_mark:| [espressif/icm42670](https://components.espressif.com/components/espressif/icm42670) | ^2.0.1| +| Capability | Available | Component | Version | +|-------------|------------------|----------------------------------------------------------------------------------------------------------|----------| +| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341) | ^1 | +| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 | +| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| +| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1 | +|AUDIO_SPEAKER|:heavy_check_mark:| | | +| AUDIO_MIC |:heavy_check_mark:| | | +| SDCARD |:heavy_check_mark:| idf | >=5.3 | +| IMU |:heavy_check_mark:| [espressif/icm42670](https://components.espressif.com/components/espressif/icm42670) | ^2.0.1 | diff --git a/bsp/esp-box-3/idf_component.yml b/bsp/esp-box-3/idf_component.yml index 731f1ac5..f0ca8142 100644 --- a/bsp/esp-box-3/idf_component.yml +++ b/bsp/esp-box-3/idf_component.yml @@ -25,7 +25,7 @@ dependencies: public: true button: - version: ">=2.5" + version: ">=2.5,<4.0" public: true icm42670: diff --git a/components/esp_lvgl_port/CHANGELOG.md b/components/esp_lvgl_port/CHANGELOG.md index 7ef30355..5dc555df 100644 --- a/components/esp_lvgl_port/CHANGELOG.md +++ b/components/esp_lvgl_port/CHANGELOG.md @@ -1,9 +1,13 @@ # Changelog -## [Unreleased] +## 2.4.4 + +### Features +- Changed queue to event group in main LVGL task for speed up https://github.com/espressif/esp-bsp/issues/492 ### Fixes - Fixed a crash when esp_lvgl_port was initialized from high priority task https://github.com/espressif/esp-bsp/issues/455 +- Allow to swap bytes when used SW rotation https://github.com/espressif/esp-bsp/issues/497 ## 2.4.3 diff --git a/components/esp_lvgl_port/idf_component.yml b/components/esp_lvgl_port/idf_component.yml index fb7e7619..aed2f92d 100644 --- a/components/esp_lvgl_port/idf_component.yml +++ b/components/esp_lvgl_port/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.4.3" +version: "2.4.4" description: ESP LVGL port url: https://github.com/espressif/esp-bsp/tree/master/components/esp_lvgl_port dependencies: diff --git a/components/esp_lvgl_port/include/esp_lvgl_port.h b/components/esp_lvgl_port/include/esp_lvgl_port.h index 398a5c70..63e0f0b5 100644 --- a/components/esp_lvgl_port/include/esp_lvgl_port.h +++ b/components/esp_lvgl_port/include/esp_lvgl_port.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -31,9 +31,9 @@ extern "C" { * @brief LVGL Port task event type */ typedef enum { - LVGL_PORT_EVENT_DISPLAY = 1, - LVGL_PORT_EVENT_TOUCH = 2, - LVGL_PORT_EVENT_USER = 99, + LVGL_PORT_EVENT_DISPLAY = 0x01, + LVGL_PORT_EVENT_TOUCH = 0x02, + LVGL_PORT_EVENT_USER = 0x80, } lvgl_port_event_type_t; /** @@ -144,7 +144,7 @@ esp_err_t lvgl_port_resume(void); * @note It is called from LVGL events and touch interrupts * * @param event event type - * @param param user param + * @param param parameter is not used, keep for backwards compatibility * @return * - ESP_OK on success * - ESP_ERR_NOT_SUPPORTED if it is not implemented diff --git a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port.c b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port.c index 1aeb872c..24d9d70b 100644 --- a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port.c +++ b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port.c @@ -14,6 +14,7 @@ #include "freertos/portmacro.h" #include "freertos/task.h" #include "freertos/semphr.h" +#include "freertos/event_groups.h" #include "esp_lvgl_port.h" #include "esp_lvgl_port_priv.h" #include "lvgl.h" @@ -30,7 +31,7 @@ typedef struct lvgl_port_ctx_s { TaskHandle_t lvgl_task; SemaphoreHandle_t lvgl_mux; SemaphoreHandle_t timer_mux; - QueueHandle_t lvgl_queue; + EventGroupHandle_t lvgl_events; SemaphoreHandle_t task_init_mux; esp_timer_handle_t tick_timer; bool running; @@ -79,8 +80,8 @@ esp_err_t lvgl_port_init(const lvgl_port_cfg_t *cfg) lvgl_port_ctx.task_init_mux = xSemaphoreCreateMutex(); ESP_GOTO_ON_FALSE(lvgl_port_ctx.task_init_mux, ESP_ERR_NO_MEM, err, TAG, "Create LVGL task sem fail!"); /* Task queue */ - lvgl_port_ctx.lvgl_queue = xQueueCreate(100, sizeof(lvgl_port_event_t)); - ESP_GOTO_ON_FALSE(lvgl_port_ctx.lvgl_queue, ESP_ERR_NO_MEM, err, TAG, "Create LVGL queue fail!"); + lvgl_port_ctx.lvgl_events = xEventGroupCreate(); + ESP_GOTO_ON_FALSE(lvgl_port_ctx.lvgl_events, ESP_ERR_NO_MEM, err, TAG, "Create LVGL Event Group fail!"); BaseType_t res; if (cfg->task_affinity < 0) { @@ -169,23 +170,30 @@ void lvgl_port_unlock(void) esp_err_t lvgl_port_task_wake(lvgl_port_event_type_t event, void *param) { - if (!lvgl_port_ctx.lvgl_queue) { + EventBits_t bits = 0; + if (!lvgl_port_ctx.lvgl_events) { return ESP_ERR_INVALID_STATE; } - lvgl_port_event_t ev = { - .type = event, - .param = param, - }; + /* Get unprocessed bits */ + if (xPortInIsrContext() == pdTRUE) { + bits = xEventGroupGetBitsFromISR(lvgl_port_ctx.lvgl_events); + } else { + bits = xEventGroupGetBits(lvgl_port_ctx.lvgl_events); + } + + /* Set event */ + bits |= event; + /* Save */ if (xPortInIsrContext() == pdTRUE) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; - xQueueSendFromISR(lvgl_port_ctx.lvgl_queue, &ev, &xHigherPriorityTaskWoken); + xEventGroupSetBitsFromISR(lvgl_port_ctx.lvgl_events, bits, &xHigherPriorityTaskWoken); if (xHigherPriorityTaskWoken) { portYIELD_FROM_ISR( ); } } else { - xQueueSend(lvgl_port_ctx.lvgl_queue, &ev, 0); + xEventGroupSetBits(lvgl_port_ctx.lvgl_events, bits); } return ESP_OK; @@ -212,7 +220,7 @@ IRAM_ATTR bool lvgl_port_task_notify(uint32_t value) static void lvgl_port_task(void *arg) { TaskHandle_t task_to_notify = (TaskHandle_t)arg; - lvgl_port_event_t event; + EventBits_t events = 0; uint32_t task_delay_ms = 0; lv_indev_t *indev = NULL; @@ -235,21 +243,17 @@ static void lvgl_port_task(void *arg) while (lvgl_port_ctx.running) { /* Wait for queue or timeout (sleep task) */ TickType_t wait = (pdMS_TO_TICKS(task_delay_ms) >= 1 ? pdMS_TO_TICKS(task_delay_ms) : 1); - xQueueReceive(lvgl_port_ctx.lvgl_queue, &event, wait); + events = xEventGroupWaitBits(lvgl_port_ctx.lvgl_events, 0xFF, pdTRUE, pdFALSE, wait); if (lv_display_get_default() && lvgl_port_lock(0)) { /* Call read input devices */ - if (event.type == LVGL_PORT_EVENT_TOUCH) { + if (events & LVGL_PORT_EVENT_TOUCH) { xSemaphoreTake(lvgl_port_ctx.timer_mux, portMAX_DELAY); - if (event.param != NULL) { - lv_indev_read(event.param); - } else { - indev = lv_indev_get_next(NULL); - while (indev != NULL) { - lv_indev_read(indev); - indev = lv_indev_get_next(indev); - } + indev = lv_indev_get_next(NULL); + while (indev != NULL) { + lv_indev_read(indev); + indev = lv_indev_get_next(indev); } xSemaphoreGive(lvgl_port_ctx.timer_mux); } @@ -287,8 +291,8 @@ static void lvgl_port_task_deinit(void) if (lvgl_port_ctx.task_init_mux) { vSemaphoreDelete(lvgl_port_ctx.task_init_mux); } - if (lvgl_port_ctx.lvgl_queue) { - vQueueDelete(lvgl_port_ctx.lvgl_queue); + if (lvgl_port_ctx.lvgl_events) { + vEventGroupDelete(lvgl_port_ctx.lvgl_events); } memset(&lvgl_port_ctx, 0, sizeof(lvgl_port_ctx)); #if LV_ENABLE_GC || !LV_MEM_CUSTOM diff --git a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c index 921954b9..9e8d6577 100644 --- a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c +++ b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c @@ -567,7 +567,7 @@ static void lvgl_port_flush_callback(lv_display_t *drv, const lv_area_t *area, u int offsety2 = area->y2; /* SW rotation enabled */ - if (disp_ctx->flags.sw_rotate && (disp_ctx->current_rotation > LV_DISPLAY_ROTATION_0 || disp_ctx->flags.swap_bytes)) { + if (disp_ctx->flags.sw_rotate && (disp_ctx->current_rotation > LV_DISPLAY_ROTATION_0)) { /* SW rotation */ if (disp_ctx->draw_buffs[2]) { int32_t ww = lv_area_get_width(area); @@ -589,7 +589,9 @@ static void lvgl_port_flush_callback(lv_display_t *drv, const lv_area_t *area, u offsety1 = area->y1; offsety2 = area->y2; } - } else if (disp_ctx->flags.swap_bytes) { + } + + if (disp_ctx->flags.swap_bytes) { size_t len = lv_area_get_size(area); lv_draw_sw_rgb565_swap(color_map, len); } diff --git a/examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2 b/examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2 index b8e255c5..6c13864b 100644 --- a/examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2 +++ b/examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2 @@ -3,25 +3,35 @@ # CONFIG_IDF_TARGET="esp32" CONFIG_BSP_PMU_AXP2101=y -CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHMODE_QIO=y +CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_SPIRAM=y CONFIG_SPIRAM_SPEED_80M=y -CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y +CONFIG_SPIFFS_PAGE_SIZE=1024 +CONFIG_LV_SPRINTF_CUSTOM=y +CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n +# CONFIG_LV_BUILD_EXAMPLES is not set + +## LVGL8 ## +CONFIG_LV_USE_PERF_MONITOR=y +CONFIG_LV_COLOR_16_SWAP=y +CONFIG_LV_MEM_CUSTOM=y +CONFIG_LV_MEMCPY_MEMSET_STD=y + +## LVGL9 ## +CONFIG_LV_CONF_SKIP=y + +#CLIB default CONFIG_LV_USE_CLIB_MALLOC=y -CONFIG_LV_USE_CLIB_STRING=y CONFIG_LV_USE_CLIB_SPRINTF=y -CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y -CONFIG_LV_FONT_MONTSERRAT_12=y -CONFIG_LV_FONT_MONTSERRAT_16=y +CONFIG_LV_USE_CLIB_STRING=y + +# Performance monitor CONFIG_LV_USE_OBSERVER=y CONFIG_LV_USE_SYSMON=y CONFIG_LV_USE_PERF_MONITOR=y -CONFIG_LV_BUILD_EXAMPLES=n -CONFIG_LV_USE_DEMO_WIDGETS=y -CONFIG_LV_USE_DEMO_STRESS=y -CONFIG_LV_USE_DEMO_MUSIC=y -CONFIG_LV_DEMO_MUSIC_ROUND=y -CONFIG_LV_DEMO_MUSIC_AUTO_PLAY=y + +