chore(color): reduce busy wait time on LCD refresh#7448
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughThis PR refactors LCD drivers across multiple board and target configurations to use conditional LTDC reload synchronization based on build mode, migrate RM-H750 to fixed display constants, eliminate function pointer indirection, and modernize header include guards. Changes are applied consistently across jumper-h750, rm-h750, horus, pl18, st16, and stm32h7s78-dk. ChangesLCD Driver Synchronization and Infrastructure Refactoring
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| @@ -61,18 +63,17 @@ static void startLcdRefresh(lv_disp_drv_t *disp_drv, uint16_t *buffer, | |||
| LTDC->SRCR = LTDC_SRCR_VBR; | |||
| __HAL_LTDC_ENABLE_IT(&hltdc, LTDC_IT_LI); | |||
|
|
|||
| // wait for reload | |||
| // TODO: replace through some smarter mechanism without busy wait | |||
| #if defined(BOOT) | |||
| // wait for reload to finish - required for bootloader | |||
| while(_frame_addr_reloaded == 0); | |||
| #endif | |||
There was a problem hiding this comment.
gui/colorlcd/lcd.cpp:flushLCD expects the flush to be completed, as it is calling lv_disp_flush_ready
As long as this assumption still holds, I am OK with this PR
There was a problem hiding this comment.
Tested bootloader and firmware on TX16S Mk2 & Mk3, TX15, T15, T15Pro, PA01 and ST16.
All work as expected so I think it's safe.
There was a problem hiding this comment.
Given there is a very real possibility that LVGL may swap buffers and start drawing into a buffer that is still being scanned out until next VBlank since LVGL is told to flush before the new framebuffer is actually latched, deferring this for 2.12.3 and more testing.
3djc
left a comment
There was a problem hiding this comment.
Works nicely, reduces overall MCU load on busy screens, which is always very nice
ce3d8f6 to
6cfc9c6
Compare
|
Noticed this can cause some screen flicker when scrolling screen using touch panel. |
|
Not compatible with code that still refreshes LVGL outside main loop (e.g. flash bootloader). |
|
Damm, too bad, the performance gain was noticeable |
|
Version 2. Moved the call to tell LVGL that it can swap buffers and continue into the LDTC vertical refresh interrupt. This removes the busy wait loop completely in the firmware (still used in bootloader). Note: PA01 does not have a vertical refresh interrupt so still uses a busy wait loop. Only concern is possible risk of calling LVGL 'lv_disp_flush_ready' function in interrupt handler - it is a very simple function though. @3djc, @gagarinlg, @raphaelcoeffic - any thoughts? |
|
I am pretty sure that tis funczion is meant to be called from an interrupt context, when necessary. |

Currently when the LCD display needs updating, the code initiates a hardware display update then enters a busy wait loop until the update is done.
This blocks LVGL until the busy wait loop ends.
Testing on current radios shows this busy wait averages ~9ms whenever the display is refreshed.
Since the display is double buffered the busy wait can be moved to before the display update is triggered - i.e. only wait if the previous frame has not finished.
This reduces the average busy wait to < 1us.
Applies to 2.12 and 3.0. Could be added to 2.11 if desired.
Summary by CodeRabbit
Release Notes
Bug Fixes
Refactor
#pragma once.