Properly swap bytes and draw to display for direct mode in LVGL9 (BSP-700)#609
Open
kevinresol wants to merge 1 commit intoespressif:masterfrom
Open
Properly swap bytes and draw to display for direct mode in LVGL9 (BSP-700)#609kevinresol wants to merge 1 commit intoespressif:masterfrom
kevinresol wants to merge 1 commit intoespressif:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR extends direct mode support in LVGL9 by performing byte swapping only within the dirty area and generalizing full-screen drawing to all display types. Key changes include:
- Introduce
lvgl_port_draw_sw_rgb565_swap_areato swap bytes per dirty region instead of the entire buffer. - Update the flush callback to call the new swap function when in direct mode and adjust drawing logic to always use full-screen bitmap transfers for direct mode and full refresh.
- Add a changelog entry under “Unreleased” for the direct mode enhancements.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c | Added area-based byte swap function and updated flush/draw logic for direct mode. |
| components/esp_lvgl_port/CHANGELOG.md | Recorded “Properly swap bytes and draw to display for direct mode in LVGL9” in Unreleased section. |
Comments suppressed due to low confidence (4)
components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c:761
- The new function
lvgl_port_draw_sw_rgb565_swap_arealacks a doc comment explaining its purpose, parameters, and behavior. Consider adding a brief description to aid future maintainability.
static void lvgl_port_draw_sw_rgb565_swap_area(void *buf, uint32_t screen_width, uint32_t screen_height, const lv_area_t *area) {
components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c:761
- There are no unit tests for
lvgl_port_draw_sw_rgb565_swap_areato verify correct byte swapping across various area sizes and boundary conditions. Adding tests would help catch edge cases.
static void lvgl_port_draw_sw_rgb565_swap_area(void *buf, uint32_t screen_width, uint32_t screen_height, const lv_area_t *area) {
components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c:686
- This unconditionally draws the full screen for any panel when in direct mode or full_refresh, which may overwrite regions on displays that support partial updates. Consider restoring region-based drawing for non-RGB/DSI panels or reintroducing a disp_type check.
if (disp_ctx->flags.direct_mode || disp_ctx->flags.full_refresh) {
components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c:689
- [nitpick] Add a space after
iffor consistency with the project’s coding style, i.e., useif (disp_ctx->disp_type ...for readability.
if(disp_ctx->disp_type == LVGL_PORT_DISP_TYPE_RGB || disp_ctx->disp_type == LVGL_PORT_DISP_TYPE_DSI) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ESP-BSP Pull Request checklist
Change description
For LVGL9 direct mode, currently it is restricted to RGB and DSI displays. But I think it should not be limited to those because it is just a normal fullscreen buffer which will just work fine in any display. However we need to properly handle bytes swapping. In particular, we should only swap bytes in the dirty area instead of the entire buffer.
This PR addresses both issues.
Note: version of component not bumped but added changelog in the "unreleased" section