102f22f7e99d87989cd95e10370863c3f96ba7e2
- Author
- jpe230 <pablin.123.ra@gmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/.gitmodules b/.gitmodules
2index 48c7035afa444b33d5b2951284743ac326c160f8..7d8dbcb4ed0f7a479d6c4ebba8fdf9207ee62869 100644
3--- a/.gitmodules
4+++ b/.gitmodules
5@@ -21,3 +21,7 @@
6 [submodule "lib/pico-sdk"]
7 path = lib/pico-sdk
8 url = https://github.com/qmk/pico-sdk.git
9+[submodule "lib/lvgl"]
10+ path = lib/lvgl
11+ url = https://github.com/qmk/lvgl.git
12+ branch = release/v8.2
13diff --git a/Makefile b/Makefile
14index 99339192e119795a9c182c7c7dfd2b51294a72a4..1585ae7c2353d24f3f64c210b25210fac93d4e86 100644
15--- a/Makefile
16+++ b/Makefile
17@@ -402,6 +402,7 @@ ifndef SKIP_GIT
18 if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
19 if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
20 if [ ! -e lib/pico-sdk ]; then git submodule sync lib/pico-sdk && git submodule update --depth 50 --init lib/pico-sdk; fi
21+ if [ ! -e lib/lvgl ]; then git submodule sync lib/lvgl && git submodule update --depth 50 --init lib/lvgl; fi
22 git submodule status --recursive 2>/dev/null | \
23 while IFS= read -r x; do \
24 case "$$x" in \
25@@ -432,6 +433,7 @@ git-submodule:
26 [ -e lib/ugfx ] && rm -rf lib/ugfx || true
27 [ -e lib/pico-sdk ] && rm -rf lib/pico-sdk || true
28 [ -e lib/chibios-contrib/ext/mcux-sdk ] && rm -rf lib/chibios-contrib/ext/mcux-sdk || true
29+ [ -e lib/lvgl ] && rm -rf lib/lvgl || true
30 git submodule sync --recursive
31 git submodule update --init --recursive --progress
32
33diff --git a/platforms/chibios/boards/keyboard-config-templates/board.h b/data/templates/config-overrides/chibios/board.h
34rename from platforms/chibios/boards/keyboard-config-templates/board.h
35rename to data/templates/config-overrides/chibios/board.h
36diff --git a/platforms/chibios/boards/keyboard-config-templates/chconf.h b/data/templates/config-overrides/chibios/chconf.h
37rename from platforms/chibios/boards/keyboard-config-templates/chconf.h
38rename to data/templates/config-overrides/chibios/chconf.h
39diff --git a/platforms/chibios/boards/keyboard-config-templates/halconf.h b/data/templates/config-overrides/chibios/halconf.h
40rename from platforms/chibios/boards/keyboard-config-templates/halconf.h
41rename to data/templates/config-overrides/chibios/halconf.h
42diff --git a/platforms/chibios/boards/keyboard-config-templates/mcuconf.h b/data/templates/config-overrides/chibios/mcuconf.h
43rename from platforms/chibios/boards/keyboard-config-templates/mcuconf.h
44rename to data/templates/config-overrides/chibios/mcuconf.h
45diff --git a/data/templates/config-overrides/common/lv_conf.h b/data/templates/config-overrides/common/lv_conf.h
46new file mode 100644
47index 0000000000000000000000000000000000000000..5c003a6a10c55bc0e698de649a794517a51be856
48--- /dev/null
49+++ b/data/templates/config-overrides/common/lv_conf.h
50@@ -0,0 +1,10 @@
51+// Copyright 2022 Nick Brassel (@tzarc)
52+// SPDX-License-Identifier: GPL-2.0-or-later
53+#pragma once
54+
55+// #define LV_DITHER_GRADIENT 1
56+
57+#include_next <lv_conf.h>
58+
59+// #undef LV_COLOR_16_SWAP
60+// #define LV_COLOR_16_SWAP 0
61diff --git a/docs/_summary.md b/docs/_summary.md
62index d388d08391b32af2b3d6a0e9c92987102f87feaf..d2d4bb9b326ab9e39816c535a3bebc5e8aee0151 100644
63--- a/docs/_summary.md
64+++ b/docs/_summary.md
65@@ -100,6 +100,7 @@
66 * Hardware Features
67 * Displays
68 * [Quantum Painter](quantum_painter.md)
69+ * [Quantum Painter LVGL Integration](quantum_painter_lvgl.md)
70 * [HD44780 LCD Driver](feature_hd44780.md)
71 * [ST7565 LCD Driver](feature_st7565.md)
72 * [OLED Driver](feature_oled_driver.md)
73diff --git a/docs/quantum_painter_lvgl.md b/docs/quantum_painter_lvgl.md
74new file mode 100644
75index 0000000000000000000000000000000000000000..3edb37fbcef3c9057c4a1264b6e8deae87239399
76--- /dev/null
77+++ b/docs/quantum_painter_lvgl.md
78@@ -0,0 +1,55 @@
79+# Quantum Painter LVGL Integration :id=lvgl
80+
81+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.
82+
83+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.
84+
85+?> 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.
86+
87+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/)
88+
89+## Enabling LVGL :id=lvgl-enabling
90+To enable LVGL to be built into your firmware, add the following to `rules.mk`:
91+
92+```make
93+QUANTUM_PAINTER_ENABLE = yes
94+QUANTUM_PAINTER_DRIVERS = ......
95+QUANTUM_PAINTER_LVGL_INTEGRATION = yes
96+```
97+To configure the Quantum Painter Display Drivers please read the [Quantum Painter Display Drivers](quantum_painter.md#quantum-painter-drivers) section.
98+
99+## Quantum Painter LVGL API :id=lvgl-api
100+
101+### Quantum Painter LVGL Attach :id=lvgl-api-init
102+
103+```c
104+bool qp_lvgl_attach(painter_device_t device);
105+```
106+
107+The `qp_lvgl_attach` function is used to set up LVGL with the supplied display, and requires an already configured display.
108+
109+```c
110+static painter_device_t display;
111+void keyboard_post_init_kb(void) {
112+ display = qp_make_.......; // Create the display
113+ qp_init(display, QP_ROTATION_0); // Initialise the display
114+
115+ if (qp_lvgl_attach(display)) { // Attach LVGL to the display
116+ ...Your code to draw // Run LVGL specific code to draw
117+ }
118+}
119+```
120+To init. the display please read the [Display Initialisation](quantum_painter.md#quantum-painter-api-init) section.
121+
122+!> 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.
123+### Quantum Painter LVGL Detach :id=lvgl-api-init
124+
125+```c
126+void qp_lvgl_detach()
127+```
128+
129+The `qp_lvgl_detach` function stops the internal LVGL ticks and releases resources related to it.
130+
131+## Enabling/Disabling LVGL features :id=lvgl-configuring
132+
133+You can overwrite LVGL specific features in your `lv_conf.h` file.
134diff --git a/keyboards/handwired/onekey/keymaps/lvgl/config.h b/keyboards/handwired/onekey/keymaps/lvgl/config.h
135new file mode 100644
136index 0000000000000000000000000000000000000000..38bb5d0cf35310c9b1e6b5212b0ff6e6b403675b
137--- /dev/null
138+++ b/keyboards/handwired/onekey/keymaps/lvgl/config.h
139@@ -0,0 +1,15 @@
140+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
141+// SPDX-License-Identifier: GPL-2.0-or-later
142+
143+#pragma once
144+
145+/* SPI pins */
146+#define SPI_DRIVER SPID0
147+#define SPI_SCK_PIN GP18
148+#define SPI_MOSI_PIN GP19
149+#define SPI_MISO_PIN GP20
150+
151+/* LCD Configuration */
152+#define LCD_RST_PIN GP0
153+#define LCD_DC_PIN GP1
154+#define LCD_CS_PIN GP2
155diff --git a/keyboards/handwired/onekey/keymaps/lvgl/halconf.h b/keyboards/handwired/onekey/keymaps/lvgl/halconf.h
156new file mode 100644
157index 0000000000000000000000000000000000000000..27646bb3f5117662ae1876f47eda10a213cf474f
158--- /dev/null
159+++ b/keyboards/handwired/onekey/keymaps/lvgl/halconf.h
160@@ -0,0 +1,12 @@
161+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
162+// SPDX-License-Identifier: GPL-2.0-or-later
163+
164+#pragma once
165+
166+#include_next <halconf.h>
167+
168+#undef HAL_USE_SPI
169+#define HAL_USE_SPI TRUE
170+
171+#undef SPI_USE_WAIT
172+#define SPI_USE_WAIT TRUE
173diff --git a/keyboards/handwired/onekey/keymaps/lvgl/keymap.c b/keyboards/handwired/onekey/keymaps/lvgl/keymap.c
174new file mode 100644
175index 0000000000000000000000000000000000000000..be1ba48cf9bda1e76a40a8dae8feb793e5a24f6d
176--- /dev/null
177+++ b/keyboards/handwired/onekey/keymaps/lvgl/keymap.c
178@@ -0,0 +1,50 @@
179+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
180+// SPDX-License-Identifier: GPL-2.0-or-later
181+
182+#include QMK_KEYBOARD_H
183+#include "qp.h"
184+
185+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
186+ LAYOUT_ortho_1x1(JS_BUTTON0)
187+};
188+
189+painter_device_t lcd;
190+
191+void lv_example_arc_2(void);
192+
193+void keyboard_post_init_user(void) {
194+ lcd = qp_gc9a01_make_spi_device(240, 240, LCD_CS_PIN, LCD_DC_PIN, LCD_RST_PIN, 4, 0);
195+ qp_init(lcd, QP_ROTATION_0);
196+ qp_rect(lcd, 0, 0, 239, 319, 0, 255, 255, true);
197+
198+ if (qp_lvgl_attach(lcd)) {
199+ lv_example_arc_2();
200+ }
201+}
202+
203+static void set_angle(void* obj, int32_t v) {
204+ lv_arc_set_value(obj, v);
205+}
206+
207+/**
208+ * Create an arc which acts as a loader.
209+ */
210+void lv_example_arc_2(void) {
211+ /*Create an Arc*/
212+ lv_obj_t* arc = lv_arc_create(lv_scr_act());
213+ lv_arc_set_rotation(arc, 270);
214+ lv_arc_set_bg_angles(arc, 0, 360);
215+ lv_obj_remove_style(arc, NULL, LV_PART_KNOB); /*Be sure the knob is not displayed*/
216+ lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE); /*To not allow adjusting by click*/
217+ lv_obj_center(arc);
218+
219+ static lv_anim_t a;
220+ lv_anim_init(&a);
221+ lv_anim_set_var(&a, arc);
222+ lv_anim_set_exec_cb(&a, set_angle);
223+ lv_anim_set_time(&a, 1000);
224+ lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); /*Just for the demo*/
225+ lv_anim_set_repeat_delay(&a, 500);
226+ lv_anim_set_values(&a, 0, 100);
227+ lv_anim_start(&a);
228+}
229diff --git a/keyboards/handwired/onekey/keymaps/lvgl/mcuconf.h b/keyboards/handwired/onekey/keymaps/lvgl/mcuconf.h
230new file mode 100644
231index 0000000000000000000000000000000000000000..bff74867ff0486e76d799a51f575cf9a7987deb4
232--- /dev/null
233+++ b/keyboards/handwired/onekey/keymaps/lvgl/mcuconf.h
234@@ -0,0 +1,9 @@
235+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
236+// SPDX-License-Identifier: GPL-2.0-or-later
237+
238+#pragma once
239+
240+#include_next <mcuconf.h>
241+
242+#undef RP_SPI_USE_SPI0
243+#define RP_SPI_USE_SPI0 TRUE
244diff --git a/keyboards/handwired/onekey/keymaps/lvgl/rules.mk b/keyboards/handwired/onekey/keymaps/lvgl/rules.mk
245new file mode 100644
246index 0000000000000000000000000000000000000000..872d12ad6f4ce168849007a4dba7891fdb83c02c
247--- /dev/null
248+++ b/keyboards/handwired/onekey/keymaps/lvgl/rules.mk
249@@ -0,0 +1,3 @@
250+QUANTUM_PAINTER_ENABLE = yes
251+QUANTUM_PAINTER_LVGL_INTEGRATION = yes
252+QUANTUM_PAINTER_DRIVERS = gc9a01_spi
253diff --git a/lib/lvgl b/lib/lvgl
254new file mode 160000
255index 0000000000000000000000000000000000000000..e19410f8f8a256609da72cff549598e0df6fa4cf
256--- /dev/null
257+++ b/lib/lvgl
258@@ -0,0 +1 @@
259+Subproject commit e19410f8f8a256609da72cff549598e0df6fa4cf
260diff --git a/platforms/lv_conf.h b/platforms/lv_conf.h
261new file mode 100644
262index 0000000000000000000000000000000000000000..d02d87bfc76eb7a75f7611f0822db947ab03d319
263--- /dev/null
264+++ b/platforms/lv_conf.h
265@@ -0,0 +1,756 @@
266+/**
267+ * @file lv_conf.h
268+ * Configuration file for v8.2.0
269+ */
270+
271+/*
272+ * Copy this file as `lv_conf.h`
273+ * 1. simply next to the `lvgl` folder
274+ * 2. or any other places and
275+ * - define `LV_CONF_INCLUDE_SIMPLE`
276+ * - add the path as include path
277+ */
278+
279+/* clang-format off */
280+#if 1 /*Set it to "1" to enable content*/
281+
282+#ifndef LV_CONF_H
283+#define LV_CONF_H
284+
285+#include <stdint.h>
286+
287+/*====================
288+ COLOR SETTINGS
289+ *====================*/
290+
291+/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
292+#define LV_COLOR_DEPTH 16
293+
294+/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/
295+#define LV_COLOR_16_SWAP 1
296+
297+/*Enable more complex drawing routines to manage screens transparency.
298+ *Can be used if the UI is above another layer, e.g. an OSD menu or video player.
299+ *Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/
300+#define LV_COLOR_SCREEN_TRANSP 0
301+
302+/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
303+ * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
304+#define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128)
305+
306+/*Images pixels with this color will not be drawn if they are chroma keyed)*/
307+#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/
308+
309+/*=========================
310+ MEMORY SETTINGS
311+ *=========================*/
312+
313+/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
314+#ifndef LV_MEM_CUSTOM
315+#define LV_MEM_CUSTOM 1
316+#endif // LV_MEM_CUSTOM
317+#if LV_MEM_CUSTOM == 0
318+ /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
319+ #define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/
320+
321+ /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
322+ #define LV_MEM_ADR 0 /*0: unused*/
323+ /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
324+ #if LV_MEM_ADR == 0
325+ //#define LV_MEM_POOL_INCLUDE your_alloc_library /* Uncomment if using an external allocator*/
326+ //#define LV_MEM_POOL_ALLOC your_alloc /* Uncomment if using an external allocator*/
327+ #endif
328+
329+#else /*LV_MEM_CUSTOM*/
330+ #define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
331+ #define LV_MEM_CUSTOM_ALLOC malloc
332+ #define LV_MEM_CUSTOM_FREE free
333+ #define LV_MEM_CUSTOM_REALLOC realloc
334+#endif /*LV_MEM_CUSTOM*/
335+
336+/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.
337+ *You will see an error log message if there wasn't enough buffers. */
338+#define LV_MEM_BUF_MAX_NUM 16
339+
340+/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/
341+#define LV_MEMCPY_MEMSET_STD 0
342+
343+/*====================
344+ HAL SETTINGS
345+ *====================*/
346+
347+/*Default display refresh period. LVG will redraw changed areas with this period time*/
348+#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/
349+
350+/*Input device read period in milliseconds*/
351+#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/
352+
353+/*Use a custom tick source that tells the elapsed time in milliseconds.
354+ *It removes the need to manually update the tick with `lv_tick_inc()`)*/
355+#ifndef LV_TICK_CUSTOM
356+#define LV_TICK_CUSTOM 0
357+#endif // LV_TICK_CUSTOM
358+#if LV_TICK_CUSTOM
359+ #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
360+ #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
361+#endif /*LV_TICK_CUSTOM*/
362+
363+/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
364+ *(Not so important, you can adjust it to modify default sizes and spaces)*/
365diff --git a/quantum/main.c b/quantum/main.c
366index 2d5911b708df42f4bfcc330a1602f2f5d116bad7..3b101c522c3709ecbd6c0238de11e4d3b0bbd914 100644
367--- a/quantum/main.c
368+++ b/quantum/main.c
369@@ -60,9 +60,9 @@ int main(void) {
370 protocol_task();
371
372 #ifdef QUANTUM_PAINTER_ENABLE
373- // Run Quantum Painter animations
374- void qp_internal_animation_tick(void);
375- qp_internal_animation_tick();
376+ // Run Quantum Painter task
377+ void qp_internal_task(void);
378+ qp_internal_task();
379 #endif
380
381 #ifdef DEFERRED_EXEC_ENABLE
382diff --git a/quantum/painter/lvgl/qp_lvgl.c b/quantum/painter/lvgl/qp_lvgl.c
383new file mode 100644
384index 0000000000000000000000000000000000000000..41ca3f98c248b19307ef7705c544619931bdaabe
385--- /dev/null
386+++ b/quantum/painter/lvgl/qp_lvgl.c
387@@ -0,0 +1,144 @@
388+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
389+// Copyright 2022 Nick Brassel (@tzarc)
390+// SPDX-License-Identifier: GPL-2.0-or-later
391+
392+#include "qp_lvgl.h"
393+#include "timer.h"
394+#include "deferred_exec.h"
395+#include "lvgl.h"
396+
397+typedef struct lvgl_state_t {
398+ uint8_t fnc_id; // Ideally this should be the pointer of the function to run
399+ uint16_t delay_ms;
400+ deferred_token defer_token;
401+} lvgl_state_t;
402+
403+static deferred_executor_t lvgl_executors[2] = {0}; // For lv_tick_inc and lv_task_handler
404+static lvgl_state_t lvgl_states[2] = {0}; // For lv_tick_inc and lv_task_handler
405+
406+painter_device_t selected_display = NULL;
407+void * color_buffer = NULL;
408+
409+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
410+// Quantum Painter LVGL Integration Internal: qp_lvgl_flush
411+
412+void qp_lvgl_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) {
413+ if (selected_display) {
414+ uint32_t number_pixels = (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1);
415+ qp_viewport(selected_display, area->x1, area->y1, area->x2, area->y2);
416+ qp_pixdata(selected_display, (void *)color_p, number_pixels);
417+ qp_flush(selected_display);
418+ lv_disp_flush_ready(disp);
419+ }
420+}
421+
422+static uint32_t tick_task_callback(uint32_t trigger_time, void *cb_arg) {
423+ lvgl_state_t * state = (lvgl_state_t *)cb_arg;
424+ static uint32_t last_tick = 0;
425+ switch (state->fnc_id) {
426+ case 0: {
427+ uint32_t now = timer_read32();
428+ lv_tick_inc(TIMER_DIFF_32(now, last_tick));
429+ last_tick = now;
430+ } break;
431+ case 1:
432+ lv_task_handler();
433+ break;
434+
435+ default:
436+ break;
437+ }
438+
439+ // The tasks should run indefinitely
440+ return state->delay_ms;
441+}
442+
443+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
444+// Quantum Painter LVGL Integration API: qp_lvgl_attach
445+
446+bool qp_lvgl_attach(painter_device_t device) {
447+ qp_dprintf("qp_lvgl_start: entry\n");
448+ qp_lvgl_detach();
449+
450+ struct painter_driver_t *driver = (struct painter_driver_t *)device;
451+ if (!driver->validate_ok) {
452+ qp_dprintf("qp_lvgl_attach: fail (validation_ok == false)\n");
453+ qp_lvgl_detach();
454+ return false;
455+ }
456+
457+ // Setting up the tasks
458+ lvgl_state_t *lv_tick_inc_state = &lvgl_states[0];
459+ lv_tick_inc_state->fnc_id = 0;
460+ lv_tick_inc_state->delay_ms = 1;
461+ lv_tick_inc_state->defer_token = defer_exec_advanced(lvgl_executors, 2, 1, tick_task_callback, lv_tick_inc_state);
462+
463+ if (lv_tick_inc_state->defer_token == INVALID_DEFERRED_TOKEN) {
464+ qp_dprintf("qp_lvgl_attach: fail (could not set up qp_lvgl executor)\n");
465+ qp_lvgl_detach();
466+ return false;
467+ }
468+
469+ lvgl_state_t *lv_task_handler_state = &lvgl_states[1];
470+ lv_task_handler_state->fnc_id = 1;
471+ lv_task_handler_state->delay_ms = 5;
472+ lv_task_handler_state->defer_token = defer_exec_advanced(lvgl_executors, 2, 5, tick_task_callback, lv_task_handler_state);
473+
474+ if (lv_task_handler_state->defer_token == INVALID_DEFERRED_TOKEN) {
475+ qp_dprintf("qp_lvgl_attach: fail (could not set up qp_lvgl executor)\n");
476+ qp_lvgl_detach();
477+ return false;
478+ }
479+
480+ // Init LVGL
481+ lv_init();
482+
483+ // Set up lvgl display buffer
484+ static lv_disp_draw_buf_t draw_buf;
485+ // Allocate a buffer for 1/10 screen size
486+ const size_t count_required = driver->panel_width * driver->panel_height / 10;
487diff --git a/quantum/painter/lvgl/qp_lvgl.h b/quantum/painter/lvgl/qp_lvgl.h
488new file mode 100644
489index 0000000000000000000000000000000000000000..d9ad5e8df1ef1dc1b9463338fcd64f0d932d7a7a
490--- /dev/null
491+++ b/quantum/painter/lvgl/qp_lvgl.h
492@@ -0,0 +1,25 @@
493+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
494+// Copyright 2022 Nick Brassel (@tzarc)
495+// SPDX-License-Identifier: GPL-2.0-or-later
496+
497+#pragma once
498+
499+#include "qp.h"
500+#include "lvgl.h"
501+
502+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
503+// Quantum Painter - LVGL External API
504+
505+/**
506+ * Sets up LVGL with the supplied display.
507+ *
508+ * @param device[in] the handle of the device to control
509+ * @return true if init. of LVGL succeeded
510+ * @return false if init. of LVGL failed
511+ */
512+bool qp_lvgl_attach(painter_device_t device);
513+
514+/**
515+ * Disconnects LVGL from any attached display
516+ */
517+void qp_lvgl_detach(void);
518diff --git a/quantum/painter/lvgl/rules.mk b/quantum/painter/lvgl/rules.mk
519new file mode 100644
520index 0000000000000000000000000000000000000000..50226941b35a93e517ee7d2a97fab7cb5a0953e9
521--- /dev/null
522+++ b/quantum/painter/lvgl/rules.mk
523@@ -0,0 +1,24 @@
524+# LVGL Integration
525+
526+OPT_DEFS += -DQUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE -DLV_CONF_INCLUDE_SIMPLE
527+DEFERRED_EXEC_ENABLE := yes
528+
529+LVGL_DIR_NAME = lvgl
530+LVGL_DIR = $(LIB_DIR)
531+LVGL_PATH = $(LVGL_DIR)/$(LVGL_DIR_NAME)
532+
533+COMMON_VPATH += $(PLATFORM_PATH) \
534+ $(QUANTUM_DIR)/painter/$(LVGL_DIR_NAME) \
535+ $(LVGL_PATH)
536+
537+include $(LVGL_PATH)/src/extra/extra.mk
538+include $(LVGL_PATH)/src/core/lv_core.mk
539+include $(LVGL_PATH)/src/draw/lv_draw.mk
540+include $(LVGL_PATH)/src/draw/sw/lv_draw_sw.mk
541+include $(LVGL_PATH)/src/font/lv_font.mk
542+include $(LVGL_PATH)/src/hal/lv_hal.mk
543+include $(LVGL_PATH)/src/misc/lv_misc.mk
544+include $(LVGL_PATH)/src/widgets/lv_widgets.mk
545+
546+SRC += qp_lvgl.c \
547+ $(CSRCS)
548diff --git a/quantum/painter/qp.h b/quantum/painter/qp.h
549index 69bc43596125379f5652620ea25dd92feee9f951..e5f595d71d5aa08047cdf13e4163e5ed540a63dc 100644
550--- a/quantum/painter/qp.h
551+++ b/quantum/painter/qp.h
552@@ -463,3 +463,10 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
553 #ifdef QUANTUM_PAINTER_SSD1351_ENABLE
554 # include "qp_ssd1351.h"
555 #endif // QUANTUM_PAINTER_SSD1351_ENABLE
556+
557+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
558+// Quantum Painter Extras
559+
560+#ifdef QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE
561+# include "qp_lvgl.h"
562+#endif // QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE
563diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c
564index e9b975f23a6c35029746856a227ed58b1ac85bcd..943cbfef5be85fefb784e03f1d9c3c166e478950 100644
565--- a/quantum/painter/qp_draw_image.c
566+++ b/quantum/painter/qp_draw_image.c
567@@ -399,3 +399,15 @@ void qp_internal_animation_tick(void) {
568 static uint32_t last_anim_exec = 0;
569 deferred_exec_advanced_task(animation_executors, QUANTUM_PAINTER_CONCURRENT_ANIMATIONS, &last_anim_exec);
570 }
571+
572+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
573+// Quantum Painter Core API: qp_internal_task
574+
575+void qp_internal_task(void) {
576+ qp_internal_animation_tick();
577+#ifdef QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE
578+ // Run LVGL ticks
579+ void qp_lvgl_internal_tick(void);
580+ qp_lvgl_internal_tick();
581+#endif
582+}
583diff --git a/quantum/painter/rules.mk b/quantum/painter/rules.mk
584index 5ac374a96ea506a31084ea035e6dd469015bfe13..199e406dd6f48e94fd52625acc85f3fdf23f934c 100644
585--- a/quantum/painter/rules.mk
586+++ b/quantum/painter/rules.mk
587@@ -2,6 +2,8 @@
588 QUANTUM_PAINTER_DRIVERS ?=
589 QUANTUM_PAINTER_ANIMATIONS_ENABLE ?= yes
590
591+QUANTUM_PAINTER_LVGL_INTEGRATION ?= no
592+
593 # The list of permissible drivers that can be listed in QUANTUM_PAINTER_DRIVERS
594 VALID_QUANTUM_PAINTER_DRIVERS := \
595 rgb565_surface \
596@@ -152,3 +154,7 @@ ifeq ($(strip $(QUANTUM_PAINTER_NEEDS_COMMS_SPI)), yes)
597 endif
598 endif
599
600+# Check if LVGL needs to be enabled
601+ifeq ($(strip $(QUANTUM_PAINTER_LVGL_INTEGRATION)), yes)
602+ include $(QUANTUM_DIR)/painter/lvgl/rules.mk
603+endif
604diff --git a/util/size_regression.sh b/util/size_regression.sh
605index 6da2d360bb9324cc6a7cdd2e5164c70f21603c5e..96555c651957db37840b9246b0694b78c9f86409 100755
606--- a/util/size_regression.sh
607+++ b/util/size_regression.sh
608@@ -64,6 +64,7 @@ fixup_submodules() {
609 [ -e lib/ugfx ] && rm -rf lib/ugfx
610 [ -e lib/pico-sdk ] && rm -rf lib/pico-sdk
611 [ -e lib/chibios-contrib/ext/mcux-sdk ] && rm -rf lib/chibios-contrib/ext/mcux-sdk
612+ [ -e lib/lvgl ] && rm -rf lib/lvgl
613 make git-submodule
614 }
615