summaryrefslogtreecommitdiff
path: root/quantum/painter
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/painter')
-rw-r--r--quantum/painter/lvgl/qp_lvgl.c2
-rw-r--r--quantum/painter/qff.h10
-rw-r--r--quantum/painter/qp.c22
-rw-r--r--quantum/painter/qp.h36
-rw-r--r--quantum/painter/qp_comms.c16
-rw-r--r--quantum/painter/qp_draw.h14
-rw-r--r--quantum/painter/qp_draw_circle.c2
-rw-r--r--quantum/painter/qp_draw_codec.c22
-rw-r--r--quantum/painter/qp_draw_core.c20
-rw-r--r--quantum/painter/qp_draw_ellipse.c2
-rw-r--r--quantum/painter/qp_draw_image.c26
-rw-r--r--quantum/painter/qp_draw_text.c56
-rw-r--r--quantum/painter/qp_internal.c96
-rw-r--r--quantum/painter/qp_internal_driver.h29
-rw-r--r--quantum/painter/qp_stream.h4
-rw-r--r--quantum/painter/rules.mk1
16 files changed, 240 insertions, 118 deletions
diff --git a/quantum/painter/lvgl/qp_lvgl.c b/quantum/painter/lvgl/qp_lvgl.c
index c6dd08ef97..660ffb6100 100644
--- a/quantum/painter/lvgl/qp_lvgl.c
+++ b/quantum/painter/lvgl/qp_lvgl.c
@@ -60,7 +60,7 @@ bool qp_lvgl_attach(painter_device_t device) {
qp_dprintf("qp_lvgl_start: entry\n");
qp_lvgl_detach();
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_lvgl_attach: fail (validation_ok == false)\n");
qp_lvgl_detach();
diff --git a/quantum/painter/qff.h b/quantum/painter/qff.h
index 6f1a1fd815..d1d629582f 100644
--- a/quantum/painter/qff.h
+++ b/quantum/painter/qff.h
@@ -21,7 +21,7 @@
#define QFF_FONT_DESCRIPTOR_TYPEID 0x00
-typedef struct __attribute__((packed)) qff_font_descriptor_v1_t {
+typedef struct QP_PACKED qff_font_descriptor_v1_t {
qgf_block_header_v1_t header; // = { .type_id = 0x00, .neg_type_id = (~0x00), .length = 20 }
uint32_t magic : 24; // constant, equal to 0x464651 ("QFF")
uint8_t qff_version; // constant, equal to 0x01
@@ -50,13 +50,13 @@ _Static_assert(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t
#define QFF_GLYPH_OFFSET_BITS 18
#define QFF_GLYPH_OFFSET_MASK (((1 << QFF_GLYPH_OFFSET_BITS) - 1) << QFF_GLYPH_WIDTH_BITS)
-typedef struct __attribute__((packed)) qff_ascii_glyph_v1_t {
+typedef struct QP_PACKED qff_ascii_glyph_v1_t {
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
} qff_ascii_glyph_v1_t;
_Static_assert(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF");
-typedef struct __attribute__((packed)) qff_ascii_glyph_table_v1_t {
+typedef struct QP_PACKED qff_ascii_glyph_table_v1_t {
qgf_block_header_v1_t header; // = { .type_id = 0x01, .neg_type_id = (~0x01), .length = 285 }
qff_ascii_glyph_v1_t glyph[95]; // 95 glyphs, 0x20..0x7E
} qff_ascii_glyph_table_v1_t;
@@ -68,14 +68,14 @@ _Static_assert(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1
#define QFF_UNICODE_GLYPH_DESCRIPTOR_TYPEID 0x02
-typedef struct __attribute__((packed)) qff_unicode_glyph_v1_t {
+typedef struct QP_PACKED qff_unicode_glyph_v1_t {
uint32_t code_point : 24;
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
} qff_unicode_glyph_v1_t;
_Static_assert(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF");
-typedef struct __attribute__((packed)) qff_unicode_glyph_table_v1_t {
+typedef struct QP_PACKED qff_unicode_glyph_table_v1_t {
qgf_block_header_v1_t header; // = { .type_id = 0x02, .neg_type_id = (~0x02), .length = (N * 6) }
qff_unicode_glyph_v1_t glyph[0]; // Extent of '0' signifies that this struct is immediately followed by the glyph data
} qff_unicode_glyph_table_v1_t;
diff --git a/quantum/painter/qp.c b/quantum/painter/qp.c
index de36dee2c1..aea9381b60 100644
--- a/quantum/painter/qp.c
+++ b/quantum/painter/qp.c
@@ -11,15 +11,15 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal driver validation
-static bool validate_driver_vtable(struct painter_driver_t *driver) {
+static bool validate_driver_vtable(painter_driver_t *driver) {
return (driver->driver_vtable && driver->driver_vtable->init && driver->driver_vtable->power && driver->driver_vtable->clear && driver->driver_vtable->viewport && driver->driver_vtable->pixdata && driver->driver_vtable->palette_convert && driver->driver_vtable->append_pixels && driver->driver_vtable->append_pixdata) ? true : false;
}
-static bool validate_comms_vtable(struct painter_driver_t *driver) {
+static bool validate_comms_vtable(painter_driver_t *driver) {
return (driver->comms_vtable && driver->comms_vtable->comms_init && driver->comms_vtable->comms_start && driver->comms_vtable->comms_stop && driver->comms_vtable->comms_send) ? true : false;
}
-static bool validate_driver_integrity(struct painter_driver_t *driver) {
+static bool validate_driver_integrity(painter_driver_t *driver) {
return validate_driver_vtable(driver) && validate_comms_vtable(driver);
}
@@ -28,7 +28,7 @@ static bool validate_driver_integrity(struct painter_driver_t *driver) {
bool qp_init(painter_device_t device, painter_rotation_t rotation) {
qp_dprintf("qp_init: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
driver->validate_ok = false;
if (!validate_driver_integrity(driver)) {
@@ -64,7 +64,7 @@ bool qp_init(painter_device_t device, painter_rotation_t rotation) {
bool qp_power(painter_device_t device, bool power_on) {
qp_dprintf("qp_power: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_power: fail (validation_ok == false)\n");
return false;
@@ -86,7 +86,7 @@ bool qp_power(painter_device_t device, bool power_on) {
bool qp_clear(painter_device_t device) {
qp_dprintf("qp_clear: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_clear: fail (validation_ok == false)\n");
return false;
@@ -108,7 +108,7 @@ bool qp_clear(painter_device_t device) {
bool qp_flush(painter_device_t device) {
qp_dprintf("qp_flush: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_flush: fail (validation_ok == false)\n");
return false;
@@ -130,7 +130,7 @@ bool qp_flush(painter_device_t device) {
void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, painter_rotation_t *rotation, uint16_t *offset_x, uint16_t *offset_y) {
qp_dprintf("qp_geometry: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
switch (driver->rotation) {
default:
@@ -174,7 +174,7 @@ void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height,
void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_t offset_y) {
qp_dprintf("qp_set_viewport_offsets: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
driver->offset_x = offset_x;
driver->offset_y = offset_y;
@@ -187,7 +187,7 @@ void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_
bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
qp_dprintf("qp_viewport: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_viewport: fail (validation_ok == false)\n");
return false;
@@ -210,7 +210,7 @@ bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t
bool qp_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
qp_dprintf("qp_pixdata: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_pixdata: fail (validation_ok == false)\n");
return false;
diff --git a/quantum/painter/qp.h b/quantum/painter/qp.h
index 00f5d7931a..7222d3b413 100644
--- a/quantum/painter/qp.h
+++ b/quantum/painter/qp.h
@@ -1,4 +1,4 @@
-// Copyright 2021 Nick Brassel (@tzarc)
+// Copyright 2021-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -11,6 +11,22 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter global configurables (add to your keyboard's config.h)
+#ifndef QUANTUM_PAINTER_DISPLAY_TIMEOUT
+/**
+ * @def This controls the amount of time (in milliseconds) that all displays will remain on after the last user input.
+ * If set to 0, the display will remain on indefinitely.
+ */
+# define QUANTUM_PAINTER_DISPLAY_TIMEOUT 30000
+#endif // QUANTUM_PAINTER_DISPLAY_TIMEOUT
+
+#ifndef QUANTUM_PAINTER_TASK_THROTTLE
+/**
+ * @def This controls the amount of time (in milliseconds) that the Quantum Painter internal task will wait between
+ * each execution.
+ */
+# define QUANTUM_PAINTER_TASK_THROTTLE 1
+#endif // QUANTUM_PAINTER_TASK_THROTTLE
+
#ifndef QUANTUM_PAINTER_NUM_IMAGES
/**
* @def This controls the maximum number of images that Quantum Painter can load at any one time. Images can be loaded
@@ -53,7 +69,7 @@
* @def This controls the maximum size of the pixel data buffer used for single blocks of transmission. Larger buffers
* means more data is processed at one time, with less frequent transmissions, at the cost of RAM.
*/
-# define QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE 32
+# define QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE 1024
#endif
#ifndef QUANTUM_PAINTER_SUPPORTS_256_PALETTE
@@ -442,34 +458,50 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
#ifdef QUANTUM_PAINTER_RGB565_SURFACE_ENABLE
# include "qp_rgb565_surface.h"
+#else // QUANTUM_PAINTER_RGB565_SURFACE_ENABLE
+# define RGB565_SURFACE_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_RGB565_SURFACE_ENABLE
#ifdef QUANTUM_PAINTER_ILI9163_ENABLE
# include "qp_ili9163.h"
+#else // QUANTUM_PAINTER_ILI9163_ENABLE
+# define ILI9163_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ILI9163_ENABLE
#ifdef QUANTUM_PAINTER_ILI9341_ENABLE
# include "qp_ili9341.h"
+#else // QUANTUM_PAINTER_ILI9341_ENABLE
+# define ILI9341_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ILI9341_ENABLE
#ifdef QUANTUM_PAINTER_ILI9488_ENABLE
# include "qp_ili9488.h"
+#else // QUANTUM_PAINTER_ILI9488_ENABLE
+# define ILI9488_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ILI9488_ENABLE
#ifdef QUANTUM_PAINTER_ST7789_ENABLE
# include "qp_st7789.h"
+#else // QUANTUM_PAINTER_ST7789_ENABLE
+# define ST7789_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ST7789_ENABLE
#ifdef QUANTUM_PAINTER_ST7735_ENABLE
# include "qp_st7735.h"
+#else // QUANTUM_PAINTER_ST7735_ENABLE
+# define ST7735_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ST7735_ENABLE
#ifdef QUANTUM_PAINTER_GC9A01_ENABLE
# include "qp_gc9a01.h"
+#else // QUANTUM_PAINTER_GC9A01_ENABLE
+# define GC9A01_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_GC9A01_ENABLE
#ifdef QUANTUM_PAINTER_SSD1351_ENABLE
# include "qp_ssd1351.h"
+#else // QUANTUM_PAINTER_SSD1351_ENABLE
+# define SSD1351_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_SSD1351_ENABLE
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/quantum/painter/qp_comms.c b/quantum/painter/qp_comms.c
index dc17b49460..bcc6de8f2e 100644
--- a/quantum/painter/qp_comms.c
+++ b/quantum/painter/qp_comms.c
@@ -7,7 +7,7 @@
// Base comms APIs
bool qp_comms_init(painter_device_t device) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_comms_init: fail (validation_ok == false)\n");
return false;
@@ -17,7 +17,7 @@ bool qp_comms_init(painter_device_t device) {
}
bool qp_comms_start(painter_device_t device) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_comms_start: fail (validation_ok == false)\n");
return false;
@@ -27,7 +27,7 @@ bool qp_comms_start(painter_device_t device) {
}
void qp_comms_stop(painter_device_t device) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_comms_stop: fail (validation_ok == false)\n");
return;
@@ -37,7 +37,7 @@ void qp_comms_stop(painter_device_t device) {
}
uint32_t qp_comms_send(painter_device_t device, const void *data, uint32_t byte_count) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_comms_send: fail (validation_ok == false)\n");
return false;
@@ -50,8 +50,8 @@ uint32_t qp_comms_send(painter_device_t device, const void *data, uint32_t byte_
// Comms APIs that use a D/C pin
void qp_comms_command(painter_device_t device, uint8_t cmd) {
- struct painter_driver_t * driver = (struct painter_driver_t *)device;
- struct painter_comms_with_command_vtable_t *comms_vtable = (struct painter_comms_with_command_vtable_t *)driver->comms_vtable;
+ painter_driver_t * driver = (painter_driver_t *)device;
+ painter_comms_with_command_vtable_t *comms_vtable = (painter_comms_with_command_vtable_t *)driver->comms_vtable;
comms_vtable->send_command(device, cmd);
}
@@ -66,7 +66,7 @@ uint32_t qp_comms_command_databuf(painter_device_t device, uint8_t cmd, const vo
}
void qp_comms_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) {
- struct painter_driver_t * driver = (struct painter_driver_t *)device;
- struct painter_comms_with_command_vtable_t *comms_vtable = (struct painter_comms_with_command_vtable_t *)driver->comms_vtable;
+ painter_driver_t * driver = (painter_driver_t *)device;
+ painter_comms_with_command_vtable_t *comms_vtable = (painter_comms_with_command_vtable_t *)driver->comms_vtable;
comms_vtable->bulk_command_sequence(device, sequence, sequence_len);
}
diff --git a/quantum/painter/qp_draw.h b/quantum/painter/qp_draw.h
index 84b1946ca7..3d073efe8c 100644
--- a/quantum/painter/qp_draw.h
+++ b/quantum/painter/qp_draw.h
@@ -63,7 +63,7 @@ enum qp_internal_rle_mode_t {
NON_REPEATING_RUN,
};
-struct qp_internal_byte_input_state {
+typedef struct qp_internal_byte_input_state_t {
painter_device_t device;
qp_stream_t* src_stream;
int16_t curr;
@@ -74,22 +74,22 @@ struct qp_internal_byte_input_state {
uint8_t remain; // number of bytes remaining in the current mode
} rle;
};
-};
+} qp_internal_byte_input_state_t;
-struct qp_internal_pixel_output_state {
+typedef struct qp_internal_pixel_output_state_t {
painter_device_t device;
uint32_t pixel_write_pos;
uint32_t max_pixels;
-};
+} qp_internal_pixel_output_state_t;
bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg);
-struct qp_internal_byte_output_state {
+typedef struct qp_internal_byte_output_state_t {
painter_device_t device;
uint32_t byte_write_pos;
uint32_t max_bytes;
-};
+} qp_internal_byte_output_state_t;
bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg);
-qp_internal_byte_input_callback qp_internal_prepare_input_state(struct qp_internal_byte_input_state* input_state, painter_compression_t compression);
+qp_internal_byte_input_callback qp_internal_prepare_input_state(qp_internal_byte_input_state_t* input_state, painter_compression_t compression);
diff --git a/quantum/painter/qp_draw_circle.c b/quantum/painter/qp_draw_circle.c
index edaae35835..25517d91c5 100644
--- a/quantum/painter/qp_draw_circle.c
+++ b/quantum/painter/qp_draw_circle.c
@@ -127,7 +127,7 @@ static bool qp_circle_helper_impl(painter_device_t device, uint16_t centerx, uin
bool qp_circle(painter_device_t device, uint16_t x, uint16_t y, uint16_t radius, uint8_t hue, uint8_t sat, uint8_t val, bool filled) {
qp_dprintf("qp_circle: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_circle: fail (validation_ok == false)\n");
return false;
diff --git a/quantum/painter/qp_draw_codec.c b/quantum/painter/qp_draw_codec.c
index 5d1cf7c52e..cee2e32e28 100644
--- a/quantum/painter/qp_draw_codec.c
+++ b/quantum/painter/qp_draw_codec.c
@@ -54,8 +54,8 @@ bool qp_internal_decode_grayscale(painter_device_t device, uint32_t pixel_count,
}
bool qp_internal_decode_recolor(painter_device_t device, uint32_t pixel_count, uint8_t bits_per_pixel, qp_internal_byte_input_callback input_callback, void* input_arg, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, qp_internal_pixel_output_callback output_callback, void* output_arg) {
- struct painter_driver_t* driver = (struct painter_driver_t*)device;
- int16_t steps = 1 << bits_per_pixel; // number of items we need to interpolate
+ painter_driver_t* driver = (painter_driver_t*)device;
+ int16_t steps = 1 << bits_per_pixel; // number of items we need to interpolate
if (qp_internal_interpolate_palette(fg_hsv888, bg_hsv888, steps)) {
if (!driver->driver_vtable->palette_convert(device, steps, qp_internal_global_pixel_lookup_table)) {
return false;
@@ -84,13 +84,13 @@ bool qp_internal_send_bytes(painter_device_t device, uint32_t byte_count, qp_int
// Progressive pull of bytes, push of pixels
static inline int16_t qp_drawimage_byte_uncompressed_decoder(void* cb_arg) {
- struct qp_internal_byte_input_state* state = (struct qp_internal_byte_input_state*)cb_arg;
- state->curr = qp_stream_get(state->src_stream);
+ qp_internal_byte_input_state_t* state = (qp_internal_byte_input_state_t*)cb_arg;
+ state->curr = qp_stream_get(state->src_stream);
return state->curr;
}
static inline int16_t qp_drawimage_byte_rle_decoder(void* cb_arg) {
- struct qp_internal_byte_input_state* state = (struct qp_internal_byte_input_state*)cb_arg;
+ qp_internal_byte_input_state_t* state = (qp_internal_byte_input_state_t*)cb_arg;
// Work out if we're parsing the initial marker byte
if (state->rle.mode == MARKER_BYTE) {
@@ -126,8 +126,8 @@ static inline int16_t qp_drawimage_byte_rle_decoder(void* cb_arg) {
}
bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg) {
- struct qp_internal_pixel_output_state* state = (struct qp_internal_pixel_output_state*)cb_arg;
- struct painter_driver_t* driver = (struct painter_driver_t*)state->device;
+ qp_internal_pixel_output_state_t* state = (qp_internal_pixel_output_state_t*)cb_arg;
+ painter_driver_t* driver = (painter_driver_t*)state->device;
if (!driver->driver_vtable->append_pixels(state->device, qp_internal_global_pixdata_buffer, palette, state->pixel_write_pos++, 1, &index)) {
return false;
@@ -145,8 +145,8 @@ bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg
}
bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) {
- struct qp_internal_byte_output_state* state = (struct qp_internal_byte_output_state*)cb_arg;
- struct painter_driver_t* driver = (struct painter_driver_t*)state->device;
+ qp_internal_byte_output_state_t* state = (qp_internal_byte_output_state_t*)cb_arg;
+ painter_driver_t* driver = (painter_driver_t*)state->device;
if (!driver->driver_vtable->append_pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos++, byteval)) {
return false;
@@ -154,7 +154,7 @@ bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) {
// If we've hit the transmit limit, send out the entire buffer and reset the write position
if (state->byte_write_pos == state->max_bytes) {
- struct painter_driver_t* driver = (struct painter_driver_t*)state->device;
+ painter_driver_t* driver = (painter_driver_t*)state->device;
if (!driver->driver_vtable->pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos * 8 / driver->native_bits_per_pixel)) {
return false;
}
@@ -164,7 +164,7 @@ bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) {
return true;
}
-qp_internal_byte_input_callback qp_internal_prepare_input_state(struct qp_internal_byte_input_state* input_state, painter_compression_t compression) {
+qp_internal_byte_input_callback qp_internal_prepare_input_state(qp_internal_byte_input_state_t* input_state, painter_compression_t compression) {
switch (compression) {
case IMAGE_UNCOMPRESSED:
return qp_drawimage_byte_uncompressed_decoder;
diff --git a/quantum/painter/qp_draw_core.c b/quantum/painter/qp_draw_core.c
index 309ef93dd0..3988aaedf8 100644
--- a/quantum/painter/qp_draw_core.c
+++ b/quantum/painter/qp_draw_core.c
@@ -37,21 +37,21 @@ __attribute__((__aligned__(4))) qp_pixel_t qp_internal_global_pixel_lookup_table
// Helpers
uint32_t qp_internal_num_pixels_in_buffer(painter_device_t device) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
return ((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE * 8) / driver->native_bits_per_pixel);
}
// qp_setpixel internal implementation, but accepts a buffer with pre-converted native pixel. Only the first pixel is used.
bool qp_internal_setpixel_impl(painter_device_t device, uint16_t x, uint16_t y) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
return driver->driver_vtable->viewport(device, x, y, x, y) && driver->driver_vtable->pixdata(device, qp_internal_global_pixdata_buffer, 1);
}
// Fills the global native pixel buffer with equivalent pixels matching the supplied HSV
void qp_internal_fill_pixdata(painter_device_t device, uint32_t num_pixels, uint8_t hue, uint8_t sat, uint8_t val) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
- uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
- num_pixels = QP_MIN(pixels_in_pixdata, num_pixels);
+ painter_driver_t *driver = (painter_driver_t *)device;
+ uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
+ num_pixels = QP_MIN(pixels_in_pixdata, num_pixels);
// Convert the color to native pixel format
qp_pixel_t color = {.hsv888 = {.h = hue, .s = sat, .v = val}};
@@ -144,7 +144,7 @@ bool qp_internal_load_qgf_palette(qp_stream_t *stream, uint8_t bpp) {
// Quantum Painter External API: qp_setpixel
bool qp_setpixel(painter_device_t device, uint16_t x, uint16_t y, uint8_t hue, uint8_t sat, uint8_t val) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_setpixel: fail (validation_ok == false)\n");
return false;
@@ -174,7 +174,7 @@ bool qp_line(painter_device_t device, uint16_t x0, uint16_t y0, uint16_t x1, uin
}
qp_dprintf("qp_line(%d, %d, %d, %d): entry\n", (int)x0, (int)y0, (int)x1, (int)y1);
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_line: fail (validation_ok == false)\n");
return false;
@@ -228,8 +228,8 @@ bool qp_line(painter_device_t device, uint16_t x0, uint16_t y0, uint16_t x1, uin
// Quantum Painter External API: qp_rect
bool qp_internal_fillrect_helper_impl(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
- uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
+ painter_driver_t *driver = (painter_driver_t *)device;
uint16_t l = QP_MIN(left, right);
uint16_t r = QP_MAX(left, right);
@@ -252,7 +252,7 @@ bool qp_internal_fillrect_helper_impl(painter_device_t device, uint16_t left, ui
bool qp_rect(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint8_t hue, uint8_t sat, uint8_t val, bool filled) {
qp_dprintf("qp_rect(%d, %d, %d, %d): entry\n", (int)left, (int)top, (int)right, (int)bottom);
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_rect: fail (validation_ok == false)\n");
return false;
diff --git a/quantum/painter/qp_draw_ellipse.c b/quantum/painter/qp_draw_ellipse.c
index 7f2f4abcfd..5c7abd7a7d 100644
--- a/quantum/painter/qp_draw_ellipse.c
+++ b/quantum/painter/qp_draw_ellipse.c
@@ -61,7 +61,7 @@ static bool qp_ellipse_helper_impl(painter_device_t device, uint16_t centerx, ui
bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex, uint16_t sizey, uint8_t hue, uint8_t sat, uint8_t val, bool filled) {
qp_dprintf("qp_ellipse: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_ellipse: fail (validation_ok == false)\n");
return false;
diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c
index fa80617242..361c21b906 100644
--- a/quantum/painter/qp_draw_image.c
+++ b/quantum/painter/qp_draw_image.c
@@ -1,4 +1,4 @@
-// Copyright 2021 Nick Brassel (@tzarc)
+// Copyright 2021-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "qp_internal.h"
@@ -124,7 +124,7 @@ typedef struct qgf_frame_info_t {
} qgf_frame_info_t;
static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device, qgf_image_handle_t *qgf_image, uint16_t frame_number, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, qgf_frame_info_t *info) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
// Drop out if we can't actually place the data we read out anywhere
if (!info) {
@@ -209,7 +209,7 @@ static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device,
static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint16_t y, painter_image_handle_t image, int frame_number, qgf_frame_info_t *frame_info, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888) {
qp_dprintf("qp_drawimage_recolor: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_drawimage_recolor: fail (validation_ok == false)\n");
return false;
@@ -254,8 +254,8 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1
}
// Set up the input state
- struct qp_internal_byte_input_state input_state = {.device = device, .src_stream = &qgf_image->stream};
- qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, frame_info->compression_scheme);
+ qp_internal_byte_input_state_t input_state = {.device = device, .src_stream = &qgf_image->stream};
+ qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, frame_info->compression_scheme);
if (input_callback == NULL) {
qp_dprintf("qp_drawimage_recolor: fail (invalid image compression scheme)\n");
qp_comms_stop(device);
@@ -265,7 +265,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1
bool ret = false;
if (frame_info->bpp <= 8) {
// Set up the output state
- struct qp_internal_pixel_output_state output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)};
+ qp_internal_pixel_output_state_t output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)};
// Decode the pixel data and stream to the display
ret = qp_internal_decode_palette(device, pixel_count, frame_info->bpp, input_callback, &input_state, qp_internal_global_pixel_lookup_table, qp_internal_pixel_appender, &output_state);
@@ -275,7 +275,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1
}
} else {
// Set up the output state
- struct qp_internal_byte_output_state output_state = {.device = device, .byte_write_pos = 0, .max_bytes = qp_internal_num_pixels_in_buffer(device) * driver->native_bits_per_pixel / 8};
+ qp_internal_byte_output_state_t output_state = {.device = device, .byte_write_pos = 0, .max_bytes = qp_internal_num_pixels_in_buffer(device) * driver->native_bits_per_pixel / 8};
// Stream the raw pixel data to the display
uint32_t byte_count = pixel_count * frame_info->bpp / 8;
@@ -414,15 +414,3 @@ void qp_internal_animation_tick(void) {
static uint32_t last_anim_exec = 0;
deferred_exec_advanced_task(animation_executors, QUANTUM_PAINTER_CONCURRENT_ANIMATIONS, &last_anim_exec);
}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Quantum Painter Core API: qp_internal_task
-
-void qp_internal_task(void) {
- qp_internal_animation_tick();
-#ifdef QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE
- // Run LVGL ticks
- void qp_lvgl_internal_tick(void);
- qp_lvgl_internal_tick();
-#endif
-}
diff --git a/quantum/painter/qp_draw_text.c b/quantum/painter/qp_draw_text.c
index f9fb2bf08f..ed3d373867 100644
--- a/quantum/painter/qp_draw_text.c
+++ b/quantum/painter/qp_draw_text.c
@@ -164,7 +164,7 @@ typedef bool (*code_point_handler)(qff_font_handle_t *qff_font, uint32_t code_po
// Helper that sets up the palette (if required) and returns the offset in the stream that the data starts
static inline bool qp_drawtext_prepare_font_for_render(painter_device_t device, qff_font_handle_t *qff_font, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, uint32_t *data_offset) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
// Drop out if we can't actually place the data we read out anywhere
if (!data_offset) {
@@ -319,13 +319,13 @@ static inline bool qp_iterate_code_points(qff_font_handle_t *qff_font, const cha
// String width calculation
// Callback state
-struct code_point_iter_calcwidth_state {
+typedef struct code_point_iter_calcwidth_state_t {
int16_t width;
-};
+} code_point_iter_calcwidth_state_t;
// Codepoint handler callback: width calc
static inline bool qp_font_code_point_handler_calcwidth(qff_font_handle_t *qff_font, uint32_t code_point, uint8_t width, uint8_t height, void *cb_arg) {
- struct code_point_iter_calcwidth_state *state = (struct code_point_iter_calcwidth_state *)cb_arg;
+ code_point_iter_calcwidth_state_t *state = (code_point_iter_calcwidth_state_t *)cb_arg;
// Increment the overall width by this glyph's width
state->width += width;
@@ -337,19 +337,19 @@ static inline bool qp_font_code_point_handler_calcwidth(qff_font_handle_t *qff_f
// String drawing implementation
// Callback state
-struct code_point_iter_drawglyph_state {
- painter_device_t device;
- int16_t xpos;
- int16_t ypos;
- qp_internal_byte_input_callback input_callback;
- struct qp_internal_byte_input_state * input_state;
- struct qp_internal_pixel_output_state *output_state;
-};
+typedef struct code_point_iter_drawglyph_state_t {
+ painter_device_t device;
+ int16_t xpos;
+ int16_t ypos;
+ qp_internal_byte_input_callback input_callback;
+ qp_internal_byte_input_state_t * input_state;
+ qp_internal_pixel_output_state_t *output_state;
+} code_point_iter_drawglyph_state_t;
// Codepoint handler callback: drawing
static inline bool qp_font_code_point_handler_drawglyph(qff_font_handle_t *qff_font, uint32_t code_point, uint8_t width, uint8_t height, void *cb_arg) {
- struct code_point_iter_drawglyph_state *state = (struct code_point_iter_drawglyph_state *)cb_arg;
- struct painter_driver_t * driver = (struct painter_driver_t *)state->device;
+ code_point_iter_drawglyph_state_t *state = (code_point_iter_drawglyph_state_t *)cb_arg;
+ painter_driver_t * driver = (painter_driver_t *)state->device;
// Reset the input state's RLE mode -- the stream should already be correctly positioned by qp_iterate_code_points()
state->input_state->rle.mode = MARKER_BYTE; // ignored if not using RLE
@@ -386,7 +386,7 @@ int16_t qp_textwidth(painter_font_handle_t font, const char *str) {
}
// Create the codepoint iterator state
- struct code_point_iter_calcwidth_state state = {.width = 0};
+ code_point_iter_calcwidth_state_t state = {.width = 0};
// Iterate each codepoint, return the calculated width if successful.
return qp_iterate_code_points(qff_font, str, qp_font_code_point_handler_calcwidth, &state) ? state.width : 0;
}
@@ -405,7 +405,7 @@ int16_t qp_drawtext(painter_device_t device, uint16_t x, uint16_t y, painter_fon
int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, painter_font_handle_t font, const char *str, uint8_t hue_fg, uint8_t sat_fg, uint8_t val_fg, uint8_t hue_bg, uint8_t sat_bg, uint8_t val_bg) {
qp_dprintf("qp_drawtext_recolor: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_drawtext_recolor: fail (validation_ok == false)\n");
return 0;
@@ -423,8 +423,8 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
}
// Set up the byte input state and input callback
- struct qp_internal_byte_input_state input_state = {.device = device, .src_stream = &qff_font->stream};
- qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, qff_font->compression_scheme);
+ qp_internal_byte_input_state_t input_state = {.device = device, .src_stream = &qff_font->stream};
+ qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, qff_font->compression_scheme);
if (input_callback == NULL) {
qp_dprintf("qp_drawtext_recolor: fail (invalid font compression scheme)\n");
qp_comms_stop(device);
@@ -432,18 +432,18 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
}
// Set up the pixel output state
- struct qp_internal_pixel_output_state output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)};
+ qp_internal_pixel_output_state_t output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)};
// Set up the codepoint iteration state
- struct code_point_iter_drawglyph_state state = {// Common
- .device = device,
- .xpos = x,
- .ypos = y,
- // Input
- .input_callback = input_callback,
- .input_state = &input_state,
- // Output
- .output_state = &output_state};
+ code_point_iter_drawglyph_state_t state = {// Common
+ .device = device,
+ .xpos = x,
+ .ypos = y,
+ // Input
+ .input_callback = input_callback,
+ .input_state = &input_state,
+ // Output
+ .output_state = &output_state};
qp_pixel_t fg_hsv888 = {.hsv888 = {.h = hue_fg, .s = sat_fg, .v = val_fg}};
qp_pixel_t bg_hsv888 = {.hsv888 = {.h = hue_bg, .s = sat_bg, .v = val_bg}};
diff --git a/quantum/painter/qp_internal.c b/quantum/painter/qp_internal.c
new file mode 100644
index 0000000000..ea23aef7c3
--- /dev/null
+++ b/quantum/painter/qp_internal.c
@@ -0,0 +1,96 @@
+// Copyright 2023 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "qp_internal.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter Core API: device registration
+
+enum {
+ // Work out how many devices we're actually going to be instantiating
+ // NOTE: We intentionally do not include surfaces here, despite them conforming to the same API.
+ QP_NUM_DEVICES = (ILI9163_NUM_DEVICES) // ILI9163
+ + (ILI9341_NUM_DEVICES) // ILI9341
+ + (ILI9488_NUM_DEVICES) // ILI9488
+ + (ST7789_NUM_DEVICES) // ST7789
+ + (ST7735_NUM_DEVICES) // ST7735
+ + (GC9A01_NUM_DEVICES) // GC9A01
+ + (SSD1351_NUM_DEVICES) // SSD1351
+};
+
+static painter_device_t qp_devices[QP_NUM_DEVICES] = {NULL};
+
+bool qp_internal_register_device(painter_device_t driver) {
+ for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) {
+ if (qp_devices[i] == NULL) {
+ qp_devices[i] = driver;
+ return true;
+ }
+ }
+
+ // We should never get here -- someone has screwed up their device counts during config
+ qp_dprintf("qp_internal_register_device: no more space for devices!\n");
+ return false;
+}
+
+#if (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0
+static void qp_internal_display_timeout_task(void) {
+ // Handle power on/off state
+ static bool display_on = true;
+ bool should_change_display_state = false;
+ bool target_display_state = false;
+ if (last_input_activity_elapsed() < (QUANTUM_PAINTER_DISPLAY_TIMEOUT)) {
+ should_change_display_state = display_on == false;
+ target_display_state = true;
+ } else {
+ should_change_display_state = display_on == true;
+ target_display_state = false;
+ }
+
+ if (should_change_display_state) {
+ for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) {
+ if (qp_devices[i] != NULL) {
+ qp_power(qp_devices[i], target_display_state);
+ }
+ }
+
+ display_on = target_display_state;
+ }
+}
+#endif // (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter Core API: qp_internal_task
+
+_Static_assert((QUANTUM_PAINTER_TASK_THROTTLE) > 0 && (QUANTUM_PAINTER_TASK_THROTTLE) < 1000, "QUANTUM_PAINTER_TASK_THROTTLE must be between 1 and 999");
+
+void qp_internal_task(void) {
+ // Perform throttling of the internal processing of Quantum Painter
+ static uint32_t last_tick = 0;
+ uint32_t now = timer_read32();
+ if (TIMER_DIFF_32(now, last_tick) < (QUANTUM_PAINTER_TASK_THROTTLE)) {
+ return;
+ }
+ last_tick = now;
+
+#if (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0
+ qp_internal_display_timeout_task();
+#endif // (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0
+
+ // Handle animations
+ void qp_internal_animation_tick(void);
+ qp_internal_animation_tick();
+
+#ifdef QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE
+ // Run LVGL ticks
+ void qp_lvgl_internal_tick(void);
+ qp_lvgl_internal_tick();
+#endif
+
+ // Flush (render) dirty regions to corresponding displays
+ for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) {
+ if (qp_devices[i] != NULL) {
+ qp_flush(qp_devices[i]);
+ }
+ }
+}
diff --git a/quantum/painter/qp_internal_driver.h b/quantum/painter/qp_internal_driver.h
index 82a0178a73..69da966f8c 100644
--- a/quantum/painter/qp_internal_driver.h
+++ b/quantum/painter/qp_internal_driver.h
@@ -1,4 +1,4 @@
-// Copyright 2021 Nick Brassel (@tzarc)
+// Copyright 2021-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -19,7 +19,7 @@ typedef bool (*painter_driver_append_pixels)(painter_device_t device, uint8_t *t
typedef bool (*painter_driver_append_pixdata)(painter_device_t device, uint8_t *target_buffer, uint32_t pixdata_offset, uint8_t pixdata_byte);
// Driver vtable definition
-struct painter_driver_vtable_t {
+typedef struct painter_driver_vtable_t {
painter_driver_init_func init;
painter_driver_power_func power;
painter_driver_clear_func clear;
@@ -29,7 +29,7 @@ struct painter_driver_vtable_t {
painter_driver_convert_palette_func palette_convert;
painter_driver_append_pixels append_pixels;
painter_driver_append_pixdata append_pixdata;
-};
+} painter_driver_vtable_t;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Comms callbacks
@@ -39,28 +39,28 @@ typedef bool (*painter_driver_comms_start_func)(painter_device_t device);
typedef void (*painter_driver_comms_stop_func)(painter_device_t device);
typedef uint32_t (*painter_driver_comms_send_func)(painter_device_t device, const void *data, uint32_t byte_count);
-struct painter_comms_vtable_t {
+typedef struct painter_comms_vtable_t {
painter_driver_comms_init_func comms_init;
painter_driver_comms_start_func comms_start;
painter_driver_comms_stop_func comms_stop;
painter_driver_comms_send_func comms_send;
-};
+} painter_comms_vtable_t;
typedef void (*painter_driver_comms_send_command_func)(painter_device_t device, uint8_t cmd);
typedef void (*painter_driver_comms_bulk_command_sequence)(painter_device_t device, const uint8_t *sequence, size_t sequence_len);
-struct painter_comms_with_command_vtable_t {
- struct painter_comms_vtable_t base; // must be first, so this object can be cast from the painter_comms_vtable_t* type
+typedef struct painter_comms_with_command_vtable_t {
+ painter_comms_vtable_t base; // must be first, so this object can be cast from the painter_comms_vtable_t* type
painter_driver_comms_send_command_func send_command;
painter_driver_comms_bulk_command_sequence bulk_command_sequence;
-};
+} painter_comms_with_command_vtable_t;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Driver base definition
-struct painter_driver_t {
- const struct painter_driver_vtable_t *driver_vtable;
- const struct painter_comms_vtable_t * comms_vtable;
+typedef struct painter_driver_t {
+ const painter_driver_vtable_t *driver_vtable;
+ const painter_comms_vtable_t * comms_vtable;
// Flag signifying if validation was successful
bool validate_ok;
@@ -81,4 +81,9 @@ struct painter_driver_t {
// Comms config pointer -- needs to point to an appropriate comms config if the comms driver requires it.
void *comms_config;
-};
+} painter_driver_t;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Device internals
+
+bool qp_internal_register_device(painter_device_t driver);
diff --git a/quantum/painter/qp_stream.h b/quantum/painter/qp_stream.h
index c0e745adc1..4f2b612e43 100644
--- a/quantum/painter/qp_stream.h
+++ b/quantum/painter/qp_stream.h
@@ -48,14 +48,14 @@ uint32_t qp_stream_write_impl(const void *input_buf, uint32_t member_size, uint3
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Stream definition
-struct qp_stream_t {
+typedef struct qp_stream_t {
int16_t (*get)(qp_stream_t *stream);
bool (*put)(qp_stream_t *stream, uint8_t c);
int (*seek)(qp_stream_t *stream, int32_t offset, int origin);
int32_t (*tell)(qp_stream_t *stream);
bool (*is_eof)(qp_stream_t *stream);
void (*close)(qp_stream_t *stream);
-};
+} qp_stream_t;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Memory streams
diff --git a/quantum/painter/rules.mk b/quantum/painter/rules.mk
index 199e406dd6..7752936cbd 100644
--- a/quantum/painter/rules.mk
+++ b/quantum/painter/rules.mk
@@ -24,6 +24,7 @@ SRC += \
$(QUANTUM_DIR)/unicode/utf8.c \
$(QUANTUM_DIR)/color.c \
$(QUANTUM_DIR)/painter/qp.c \
+ $(QUANTUM_DIR)/painter/qp_internal.c \
$(QUANTUM_DIR)/painter/qp_stream.c \
$(QUANTUM_DIR)/painter/qgf.c \
$(QUANTUM_DIR)/painter/qff.c \