Skip to content

chore(color): reduce busy wait time on LCD refresh#7448

Open
philmoz wants to merge 1 commit into
mainfrom
philmoz/reduce-busy-wait
Open

chore(color): reduce busy wait time on LCD refresh#7448
philmoz wants to merge 1 commit into
mainfrom
philmoz/reduce-busy-wait

Conversation

@philmoz

@philmoz philmoz commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

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

    • Improved LCD refresh synchronization across multiple hardware targets to ensure proper frame buffer address reload timing.
  • Refactor

    • Replaced configurable display dimensions with fixed constants for improved reliability.
    • Modernized code structure by using #pragma once include guards.
    • Removed unused global variables and function pointers.

@philmoz philmoz added this to the 2.12.2 milestone Jun 10, 2026
@philmoz philmoz requested review from 3djc and gagarinlg June 10, 2026 00:48
@philmoz philmoz added color Related generally to color LCD radios house keeping 🧹 Cleanup of code and house keeping labels Jun 10, 2026
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d712dff4-6718-43ea-978d-cf594ebbec43

📥 Commits

Reviewing files that changed from the base of the PR and between 65f135c and ce3d8f6.

📒 Files selected for processing (11)
  • radio/src/boards/jumper-h750/lcd_driver.cpp
  • radio/src/boards/jumper-h750/lcd_driver.h
  • radio/src/boards/rm-h750/lcd_driver_480.cpp
  • radio/src/boards/rm-h750/lcd_driver_480.h
  • radio/src/boards/rm-h750/lcd_driver_800.cpp
  • radio/src/boards/rm-h750/lcd_driver_800.h
  • radio/src/targets/horus/lcd_driver.cpp
  • radio/src/targets/horus/lcd_st7796s_driver.cpp
  • radio/src/targets/pl18/lcd_driver.cpp
  • radio/src/targets/st16/lcd_driver.cpp
  • radio/src/targets/stm32h7s78-dk/lcd_driver.cpp
💤 Files with no reviewable changes (1)
  • radio/src/boards/rm-h750/lcd_driver_800.h

📝 Walkthrough

Walkthrough

This 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.

Changes

LCD Driver Synchronization and Infrastructure Refactoring

Layer / File(s) Summary
LTDC frame reload synchronization
radio/src/boards/jumper-h750/lcd_driver.cpp, radio/src/boards/rm-h750/lcd_driver_480.cpp, radio/src/boards/rm-h750/lcd_driver_800.cpp, radio/src/targets/horus/lcd_driver.cpp, radio/src/targets/horus/lcd_st7796s_driver.cpp, radio/src/targets/pl18/lcd_driver.cpp, radio/src/targets/st16/lcd_driver.cpp, radio/src/targets/stm32h7s78-dk/lcd_driver.cpp
_frame_addr_reloaded is initialized to 1. Busy-wait behavior is now conditional on BOOT build flag: non-BOOT builds wait for reload completion before programming frame buffer; BOOT builds wait after triggering the LTDC reload via vertical blank.
RM-H750 display geometry constants migration
radio/src/boards/rm-h750/lcd_driver_480.cpp, radio/src/boards/rm-h750/lcd_driver_800.cpp
LTDC timing calculations and layer window/image dimension configuration replace runtime lcd_phys_w/lcd_phys_h variables with compile-time constants LCD_PHYS_W/LCD_PHYS_H throughout both driver variants.
RM-H750 LCD initialization cleanup
radio/src/boards/rm-h750/lcd_driver_480.cpp, radio/src/boards/rm-h750/lcd_driver_800.cpp
Function pointer indirection (lcdInitFunction, lcdOffFunction, lcdOnFunction) is removed; initialization now directly enables the LTDC clock and calls LCD_ST7365_Init() or equivalent. Global dimension variables and unused declarations are eliminated.
Header guards and include modernization
radio/src/boards/jumper-h750/lcd_driver.h, radio/src/boards/rm-h750/lcd_driver_480.h, radio/src/boards/rm-h750/lcd_driver_800.h
Headers switch from traditional #ifndef/#define guards to #pragma once. Function-pointer typedefs and extern declarations are removed. Include ordering is adjusted and macro formatting is aligned.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

backport/2.12

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: reducing busy wait time on LCD refresh, which is the core objective of this pull request.
Description check ✅ Passed The description clearly explains the problem, solution, and impact, though it doesn't follow the template's 'Fixes #' section or formal structure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch philmoz/reduce-busy-wait

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
radio/src/boards/rm-h750/lcd_driver_480.cpp

radio/src/boards/rm-h750/lcd_driver_480.cpp:22:10: fatal error: 'stm32_hal_ll.h' file not found
22 | #include "stm32_hal_ll.h"
| ^~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/ce3d8f68c5af14ad5fb97ea0bcd2e5e815f6902d-63ff3a0c0261e7d6/tmp/clang_command_.tmp.e48d6f.txt
++Contents of '/tmp/coderabbit-infer/ce3d8f68c5af14ad5fb97ea0bcd2e5e815f6902d-63ff3a0c0261e7d6/tmp/clang_command_.tmp.e48d6f.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrela

... [truncated 1113 characters] ...

/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/63ff3a0c0261e7d6/file.o" "-x" "c++"
"radio/src/boards/rm-h750/lcd_driver_480.cpp" "-O0" "-fno-builtin"
"-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

radio/src/boards/jumper-h750/lcd_driver.cpp

radio/src/boards/jumper-h750/lcd_driver.cpp:23:10: fatal error: 'stm32_hal_ll.h' file not found
23 | #include "stm32_hal_ll.h"
| ^~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/ce3d8f68c5af14ad5fb97ea0bcd2e5e815f6902d-7d9439ca5cb91431/tmp/clang_command_.tmp.820978.txt
++Contents of '/tmp/coderabbit-infer/ce3d8f68c5af14ad5fb97ea0bcd2e5e815f6902d-7d9439ca5cb91431/tmp/clang_command_.tmp.820978.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrela

... [truncated 1109 characters] ...

/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/7d9439ca5cb91431/file.o" "-x" "c++"
"radio/src/boards/jumper-h750/lcd_driver.cpp" "-O0" "-fno-builtin"
"-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

radio/src/boards/rm-h750/lcd_driver_800.cpp

radio/src/boards/rm-h750/lcd_driver_800.cpp:22:10: fatal error: 'stm32_hal_ll.h' file not found
22 | #include "stm32_hal_ll.h"
| ^~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/ce3d8f68c5af14ad5fb97ea0bcd2e5e815f6902d-56e5df0be209dede/tmp/clang_command_.tmp.3192d1.txt
++Contents of '/tmp/coderabbit-infer/ce3d8f68c5af14ad5fb97ea0bcd2e5e815f6902d-56e5df0be209dede/tmp/clang_command_.tmp.3192d1.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrela

... [truncated 1113 characters] ...

/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/56e5df0be209dede/file.o" "-x" "c++"
"radio/src/boards/rm-h750/lcd_driver_800.cpp" "-O0" "-fno-builtin"
"-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

  • 5 others

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pfeerick pfeerick added the backport/2.12 To be backported to a 2.12 release also. label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. color Related generally to color LCD radios house keeping 🧹 Cleanup of code and house keeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants