Skip to content

modules: lvgl: add automatic lv_timer_handler call #93281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2025

Conversation

uLipe
Copy link
Member

@uLipe uLipe commented Jul 17, 2025

inside of its own thread when user enable it on
the LVGL Zephyr options menu, using this option makes the calling of the lv_timer_handler driven by an internal timer and thread. Options like priority and stack size for this thread are exposed making it configurable by the application.

Worth to mention, this option is disbaled by default due the nature of the current samples of the LVGL that invokes lv_timer_handler from the application

@zephyrbot zephyrbot added the area: LVGL Light and Versatile Graphics Library Support label Jul 17, 2025
@zephyrbot zephyrbot requested review from brgl, faxe1008 and pdgendt July 17, 2025 19:03
@uLipe uLipe force-pushed the feature/lvgl_self_timer branch from a6a0929 to f36fd97 Compare July 17, 2025 19:10
Copy link
Contributor

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need a testcase somewhere in tests/samples with this option enabled

Copy link

@AndreCostaaa AndreCostaaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool feature 🚀

Copy link
Contributor

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A cleaner solution IMO is:

  • Have a k_work_q as the "thread"
  • Use a k_work_delayable to be (re)scheduled
  • Call lv_timer_hander in the delayed work handler and re-schedule based on the result

EDIT: Added benefit: the work queue could be user exposed to allow submitting/scheduling more work onto the LVGL thread.

@uLipe uLipe force-pushed the feature/lvgl_self_timer branch from f36fd97 to 8582b98 Compare July 18, 2025 14:23
@uLipe
Copy link
Member Author

uLipe commented Jul 18, 2025

@pdgendt I implemented using the workqueus, I kepi the previous one on the commit history, for easy comparisation

pdgendt
pdgendt previously approved these changes Jul 18, 2025
@pdgendt
Copy link
Contributor

pdgendt commented Jul 18, 2025

@pdgendt I implemented using the workqueus, I kepi the previous one on the commit history, for easy comparisation

Didn't notice this, please squash in that case.

@uLipe
Copy link
Member Author

uLipe commented Jul 18, 2025

@JarmouniA what would be a good way for testing this option? Just duplicate one of the samples but using this option and removing the sleep loop? BTW this can be part of another PR?

inside of its own thread when user enable it on
the LVGL Zephyr options menu, using this option makes
the calling of the lv_timer_handler driven by an internal
timer and thread. Options like priority and stack size
for this thread are exposed making it configurable by the
application.

Signed-off-by: Felipe Neves <[email protected]>

modules: lvgl: put LVGL core into a dedicated workqueue

Replacing the initial approach based on timers and semaphore

Signed-off-by: Felipe Neves <[email protected]>
@uLipe
Copy link
Member Author

uLipe commented Jul 18, 2025

Thank you @pdgendt , I exposed also the workqueue via a function

@uLipe uLipe force-pushed the feature/lvgl_self_timer branch from b34bf4d to ab493d2 Compare July 18, 2025 17:24
pdgendt
pdgendt previously approved these changes Jul 18, 2025
Copy link
Contributor

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff, do you see the same gains you had like using the timer? It probably should as these use the same low level primitives.

@JarmouniA
Copy link
Contributor

@JarmouniA what would be a good way for testing this option? Just duplicate one of the samples but using this option and removing the sleep loop?

If I understand the purpose of this PR correctly, putting

lv_timer_handler();

and
uint32_t sleep_ms = lv_timer_handler();

in between ifndef CONFIG_LV_Z_RUN_LVGL_ON_WORKQUEUE... endif then adding a testcase in sample.yaml with extra_configs: CONFIG_LV_Z_RUN_LVGL_ON_WORKQUEUE=y would work, no?

@uLipe
Copy link
Member Author

uLipe commented Jul 18, 2025

@pdgendt yes they offer the same performance and better timer slippage correction than using the sleep loop approach, but the workqueue is much cleaner

pdgendt
pdgendt previously approved these changes Jul 20, 2025
@uLipe
Copy link
Member Author

uLipe commented Jul 20, 2025

Added the tests case on the demo samples as pointed by @JarmouniA , the missing piece of this PR, please everyone take another look :)

@zephyrbot zephyrbot added the area: Samples Samples label Jul 20, 2025
@zephyrbot zephyrbot requested review from kartben and nashif July 20, 2025 16:20
faxe1008
faxe1008 previously approved these changes Jul 21, 2025
Copy link
Contributor

@faxe1008 faxe1008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreeing with @JarmouniA, one case for building the sample with the new option should be good enough, otherwise LGTM :^)

@uLipe uLipe force-pushed the feature/lvgl_self_timer branch from adb0dfa to 15f72ee Compare July 21, 2025 12:01
@uLipe
Copy link
Member Author

uLipe commented Jul 21, 2025

@JarmouniA @faxe1008 , got it, I left only the case of the demo benchmark then please PTAL again :)

@uLipe uLipe requested review from JarmouniA and faxe1008 July 21, 2025 12:02
@JarmouniA
Copy link
Contributor

@JarmouniA @faxe1008 , got it, I left only the case of the demo benchmark then please PTAL again :)

still seeing all of them

that uses the LVGL internal workqueue option to
drive the LVGL core automatically

Signed-off-by: Felipe Neves <[email protected]>
@uLipe
Copy link
Member Author

uLipe commented Jul 21, 2025

Uhh, It seems I edited from the wrong place, thanks for notice @JarmouniA, just corrected :)

Thank you!

Copy link

@uLipe
Copy link
Member Author

uLipe commented Jul 21, 2025

@kartben any chance on making this on the 4.2? This change will improve significant the timing characteristics of the LVGL core.

@JarmouniA
Copy link
Contributor

@kartben any chance on making this on the 4.2? This change will improve significant the timing characteristics of the LVGL core.

only bug fixes are backported.

@uLipe
Copy link
Member Author

uLipe commented Jul 21, 2025

Nevermind @JarmouniA, @kartben the 4.2 is already out, I was thinking that Zephyr was approaching on feature freeze

@cfriedt cfriedt merged commit a93e6c2 into zephyrproject-rtos:main Jul 22, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LVGL Light and Versatile Graphics Library Support area: Samples Samples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants