You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
3.1 KiB

  1. # Quantum Painter LVGL Integration :id=lvgl
  2. LVGL (Light and Versatile Graphics Library) is an open-source graphics library providing everything you need to create an embedded GUI for your board with easy-to-use graphical elements.
  3. LVGL integrates with [Quantum Painter's](quantum_painter.md) API and drivers to render to the display, the hardware supported by Quantum Painter is also supported by LVGL.
  4. ?> Keep in mind that enabling the LVGL integration has a big impact in firmware size, it is recommeded to use a supported MCU with >256 kB of flash space.
  5. To learn more about LVGL and how to use it please take a look at their [official documentation](https://docs.lvgl.io/8.2/intro/)
  6. ## Enabling LVGL :id=lvgl-enabling
  7. To enable LVGL to be built into your firmware, add the following to `rules.mk`:
  8. ```make
  9. QUANTUM_PAINTER_ENABLE = yes
  10. QUANTUM_PAINTER_DRIVERS = ......
  11. QUANTUM_PAINTER_LVGL_INTEGRATION = yes
  12. ```
  13. To configure the Quantum Painter Display Drivers please read the [Quantum Painter Display Drivers](quantum_painter.md#quantum-painter-drivers) section.
  14. ## Quantum Painter LVGL API :id=lvgl-api
  15. ### Quantum Painter LVGL Attach :id=lvgl-api-init
  16. ```c
  17. bool qp_lvgl_attach(painter_device_t device);
  18. ```
  19. The `qp_lvgl_attach` function is used to set up LVGL with the supplied display, and requires an already configured display.
  20. ```c
  21. static painter_device_t display;
  22. void keyboard_post_init_kb(void) {
  23. display = qp_make_.......; // Create the display
  24. qp_init(display, QP_ROTATION_0); // Initialise the display
  25. if (qp_lvgl_attach(display)) { // Attach LVGL to the display
  26. ...Your code to draw // Run LVGL specific code to draw
  27. }
  28. }
  29. ```
  30. To init. the display please read the [Display Initialisation](quantum_painter.md#quantum-painter-api-init) section.
  31. !> Attaching LVGL to a display means LVGL subsequently "owns" the display. Using standard Quantum Painter drawing operations with the display after LVGL attachment will likely result in display artifacts.
  32. ### Quantum Painter LVGL Detach :id=lvgl-api-init
  33. ```c
  34. void qp_lvgl_detach(void)
  35. ```
  36. The `qp_lvgl_detach` function stops the internal LVGL ticks and releases resources related to it.
  37. ## Enabling/Disabling LVGL features :id=lvgl-configuring
  38. You can overwrite LVGL specific features in your `lv_conf.h` file.
  39. ## Changing the LVGL task frequency
  40. 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`:
  41. ```c
  42. #define QP_LVGL_TASK_PERIOD 40
  43. ```