Skip to content
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

Lvgl rate control #22049

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/quantum_painter_lvgl.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ The `qp_lvgl_detach` function stops the internal LVGL ticks and releases resourc
## Enabling/Disabling LVGL features :id=lvgl-configuring
You can overwrite LVGL specific features in your `lv_conf.h` file.
## Changing the LVGL task frequency
When LVGL is running, your keyboard's responsiveness may decrease, causing missing keystrokes or encoder rotations, especially during the animation of dynamically-generated content. This occurs because LVGL operates as a scheduled task with a default task rate of five milliseconds. While a fast task rate is advantageous when LVGL is responsible for detecting and processing inputs, it can lead to excessive recalculations of displayed content, which may slow down QMK's matrix scanning. If you rely on QMK instead of LVGL for processing inputs, it can be beneficial to increase the time between calls to the LVGL task handler to better match your preferred display update rate. To do this, add this to your `config.h`:
```c
#define QP_LVGL_TASK_PERIOD 40
```
4 changes: 2 additions & 2 deletions quantum/painter/lvgl/qp_lvgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ bool qp_lvgl_attach(painter_device_t device) {

lvgl_state_t *lv_task_handler_state = &lvgl_states[1];
lv_task_handler_state->fnc_id = 1;
lv_task_handler_state->delay_ms = 5;
lv_task_handler_state->defer_token = defer_exec_advanced(lvgl_executors, 2, 5, tick_task_callback, lv_task_handler_state);
lv_task_handler_state->delay_ms = QP_LVGL_TASK_PERIOD;
lv_task_handler_state->defer_token = defer_exec_advanced(lvgl_executors, 2, QP_LVGL_TASK_PERIOD, tick_task_callback, lv_task_handler_state);

if (lv_task_handler_state->defer_token == INVALID_DEFERRED_TOKEN) {
qp_dprintf("qp_lvgl_attach: fail (could not set up qp_lvgl executor)\n");
Expand Down
4 changes: 4 additions & 0 deletions quantum/painter/lvgl/qp_lvgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "qp.h"
#include "lvgl.h"

#ifndef QP_LVGL_TASK_PERIOD
# define QP_LVGL_TASK_PERIOD 5
#endif

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter - LVGL External API

Expand Down