[Cleanup] Quantum Painter (#19825)
Co-authored-by: Nick Brassel <nick@tzarc.org>
This commit is contained in:
parent
e640fd65ff
commit
cd542a0f67
|
@ -10,8 +10,8 @@
|
||||||
// Base SPI support
|
// Base SPI support
|
||||||
|
|
||||||
bool qp_comms_spi_init(painter_device_t device) {
|
bool qp_comms_spi_init(painter_device_t device) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct qp_comms_spi_config_t *comms_config = (struct qp_comms_spi_config_t *)driver->comms_config;
|
qp_comms_spi_config_t *comms_config = (qp_comms_spi_config_t *)driver->comms_config;
|
||||||
|
|
||||||
// Initialize the SPI peripheral
|
// Initialize the SPI peripheral
|
||||||
spi_init();
|
spi_init();
|
||||||
|
@ -24,8 +24,8 @@ bool qp_comms_spi_init(painter_device_t device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qp_comms_spi_start(painter_device_t device) {
|
bool qp_comms_spi_start(painter_device_t device) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct qp_comms_spi_config_t *comms_config = (struct qp_comms_spi_config_t *)driver->comms_config;
|
qp_comms_spi_config_t *comms_config = (qp_comms_spi_config_t *)driver->comms_config;
|
||||||
|
|
||||||
return spi_start(comms_config->chip_select_pin, comms_config->lsb_first, comms_config->mode, comms_config->divisor);
|
return spi_start(comms_config->chip_select_pin, comms_config->lsb_first, comms_config->mode, comms_config->divisor);
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,10 @@ bool qp_comms_spi_start(painter_device_t device) {
|
||||||
uint32_t qp_comms_spi_send_data(painter_device_t device, const void *data, uint32_t byte_count) {
|
uint32_t qp_comms_spi_send_data(painter_device_t device, const void *data, uint32_t byte_count) {
|
||||||
uint32_t bytes_remaining = byte_count;
|
uint32_t bytes_remaining = byte_count;
|
||||||
const uint8_t *p = (const uint8_t *)data;
|
const uint8_t *p = (const uint8_t *)data;
|
||||||
|
const uint32_t max_msg_length = 1024;
|
||||||
|
|
||||||
while (bytes_remaining > 0) {
|
while (bytes_remaining > 0) {
|
||||||
uint32_t bytes_this_loop = bytes_remaining < 1024 ? bytes_remaining : 1024;
|
uint32_t bytes_this_loop = QP_MIN(bytes_remaining, max_msg_length);
|
||||||
spi_transmit(p, bytes_this_loop);
|
spi_transmit(p, bytes_this_loop);
|
||||||
p += bytes_this_loop;
|
p += bytes_this_loop;
|
||||||
bytes_remaining -= bytes_this_loop;
|
bytes_remaining -= bytes_this_loop;
|
||||||
|
@ -44,13 +46,13 @@ uint32_t qp_comms_spi_send_data(painter_device_t device, const void *data, uint3
|
||||||
}
|
}
|
||||||
|
|
||||||
void qp_comms_spi_stop(painter_device_t device) {
|
void qp_comms_spi_stop(painter_device_t device) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct qp_comms_spi_config_t *comms_config = (struct qp_comms_spi_config_t *)driver->comms_config;
|
qp_comms_spi_config_t *comms_config = (qp_comms_spi_config_t *)driver->comms_config;
|
||||||
spi_stop();
|
spi_stop();
|
||||||
writePinHigh(comms_config->chip_select_pin);
|
writePinHigh(comms_config->chip_select_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct painter_comms_vtable_t spi_comms_vtable = {
|
const painter_comms_vtable_t spi_comms_vtable = {
|
||||||
.comms_init = qp_comms_spi_init,
|
.comms_init = qp_comms_spi_init,
|
||||||
.comms_start = qp_comms_spi_start,
|
.comms_start = qp_comms_spi_start,
|
||||||
.comms_send = qp_comms_spi_send_data,
|
.comms_send = qp_comms_spi_send_data,
|
||||||
|
@ -67,8 +69,8 @@ bool qp_comms_spi_dc_reset_init(painter_device_t device) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct qp_comms_spi_dc_reset_config_t *comms_config = (struct qp_comms_spi_dc_reset_config_t *)driver->comms_config;
|
qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config;
|
||||||
|
|
||||||
// Set up D/C as output low, if specified
|
// Set up D/C as output low, if specified
|
||||||
if (comms_config->dc_pin != NO_PIN) {
|
if (comms_config->dc_pin != NO_PIN) {
|
||||||
|
@ -89,15 +91,15 @@ bool qp_comms_spi_dc_reset_init(painter_device_t device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void *data, uint32_t byte_count) {
|
uint32_t qp_comms_spi_dc_reset_send_data(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;
|
||||||
struct qp_comms_spi_dc_reset_config_t *comms_config = (struct qp_comms_spi_dc_reset_config_t *)driver->comms_config;
|
qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config;
|
||||||
writePinHigh(comms_config->dc_pin);
|
writePinHigh(comms_config->dc_pin);
|
||||||
return qp_comms_spi_send_data(device, data, byte_count);
|
return qp_comms_spi_send_data(device, data, byte_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd) {
|
void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct qp_comms_spi_dc_reset_config_t *comms_config = (struct qp_comms_spi_dc_reset_config_t *)driver->comms_config;
|
qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config;
|
||||||
writePinLow(comms_config->dc_pin);
|
writePinLow(comms_config->dc_pin);
|
||||||
spi_write(cmd);
|
spi_write(cmd);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +120,7 @@ void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct painter_comms_with_command_vtable_t spi_comms_with_dc_vtable = {
|
const painter_comms_with_command_vtable_t spi_comms_with_dc_vtable = {
|
||||||
.base =
|
.base =
|
||||||
{
|
{
|
||||||
.comms_init = qp_comms_spi_dc_reset_init,
|
.comms_init = qp_comms_spi_dc_reset_init,
|
||||||
|
|
|
@ -13,36 +13,36 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Base SPI support
|
// Base SPI support
|
||||||
|
|
||||||
struct qp_comms_spi_config_t {
|
typedef struct qp_comms_spi_config_t {
|
||||||
pin_t chip_select_pin;
|
pin_t chip_select_pin;
|
||||||
uint16_t divisor;
|
uint16_t divisor;
|
||||||
bool lsb_first;
|
bool lsb_first;
|
||||||
int8_t mode;
|
int8_t mode;
|
||||||
};
|
} qp_comms_spi_config_t;
|
||||||
|
|
||||||
bool qp_comms_spi_init(painter_device_t device);
|
bool qp_comms_spi_init(painter_device_t device);
|
||||||
bool qp_comms_spi_start(painter_device_t device);
|
bool qp_comms_spi_start(painter_device_t device);
|
||||||
uint32_t qp_comms_spi_send_data(painter_device_t device, const void* data, uint32_t byte_count);
|
uint32_t qp_comms_spi_send_data(painter_device_t device, const void* data, uint32_t byte_count);
|
||||||
void qp_comms_spi_stop(painter_device_t device);
|
void qp_comms_spi_stop(painter_device_t device);
|
||||||
|
|
||||||
extern const struct painter_comms_vtable_t spi_comms_vtable;
|
extern const painter_comms_vtable_t spi_comms_vtable;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// SPI with D/C and RST pins
|
// SPI with D/C and RST pins
|
||||||
|
|
||||||
# ifdef QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
|
# ifdef QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
|
||||||
|
|
||||||
struct qp_comms_spi_dc_reset_config_t {
|
typedef struct qp_comms_spi_dc_reset_config_t {
|
||||||
struct qp_comms_spi_config_t spi_config;
|
qp_comms_spi_config_t spi_config;
|
||||||
pin_t dc_pin;
|
pin_t dc_pin;
|
||||||
pin_t reset_pin;
|
pin_t reset_pin;
|
||||||
};
|
} qp_comms_spi_dc_reset_config_t;
|
||||||
|
|
||||||
void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd);
|
void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd);
|
||||||
uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void* data, uint32_t byte_count);
|
uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void* data, uint32_t byte_count);
|
||||||
void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t* sequence, size_t sequence_len);
|
void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t* sequence, size_t sequence_len);
|
||||||
|
|
||||||
extern const struct painter_comms_with_command_vtable_t spi_comms_with_dc_vtable;
|
extern const painter_comms_with_command_vtable_t spi_comms_with_dc_vtable;
|
||||||
|
|
||||||
# endif // QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
|
# endif // QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ __attribute__((weak)) bool qp_gc9a01_init(painter_device_t device, painter_rotat
|
||||||
// Driver vtable
|
// Driver vtable
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
const struct tft_panel_dc_reset_painter_driver_vtable_t gc9a01_driver_vtable = {
|
const tft_panel_dc_reset_painter_driver_vtable_t gc9a01_driver_vtable = {
|
||||||
.base =
|
.base =
|
||||||
{
|
{
|
||||||
.init = qp_gc9a01_init,
|
.init = qp_gc9a01_init,
|
||||||
|
@ -125,8 +125,8 @@ painter_device_t qp_gc9a01_make_spi_device(uint16_t panel_width, uint16_t panel_
|
||||||
for (uint32_t i = 0; i < GC9A01_NUM_DEVICES; ++i) {
|
for (uint32_t i = 0; i < GC9A01_NUM_DEVICES; ++i) {
|
||||||
tft_panel_dc_reset_painter_device_t *driver = &gc9a01_drivers[i];
|
tft_panel_dc_reset_painter_device_t *driver = &gc9a01_drivers[i];
|
||||||
if (!driver->base.driver_vtable) {
|
if (!driver->base.driver_vtable) {
|
||||||
driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&gc9a01_driver_vtable;
|
driver->base.driver_vtable = (const painter_driver_vtable_t *)&gc9a01_driver_vtable;
|
||||||
driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
driver->base.comms_vtable = (const painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
||||||
driver->base.native_bits_per_pixel = 16; // RGB565
|
driver->base.native_bits_per_pixel = 16; // RGB565
|
||||||
driver->base.panel_width = panel_width;
|
driver->base.panel_width = panel_width;
|
||||||
driver->base.panel_height = panel_height;
|
driver->base.panel_height = panel_height;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
// Device definition
|
// Device definition
|
||||||
typedef struct rgb565_surface_painter_device_t {
|
typedef struct rgb565_surface_painter_device_t {
|
||||||
struct painter_driver_t base; // must be first, so it can be cast to/from the painter_device_t* type
|
painter_driver_t base; // must be first, so it can be cast to/from the painter_device_t* type
|
||||||
|
|
||||||
// The target buffer
|
// The target buffer
|
||||||
uint16_t *buffer;
|
uint16_t *buffer;
|
||||||
|
@ -95,7 +95,7 @@ static inline void stream_pixdata(rgb565_surface_painter_device_t *surface, cons
|
||||||
// Driver vtable
|
// Driver vtable
|
||||||
|
|
||||||
static bool qp_rgb565_surface_init(painter_device_t device, painter_rotation_t rotation) {
|
static bool qp_rgb565_surface_init(painter_device_t device, painter_rotation_t rotation) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
|
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
|
||||||
memset(surface->buffer, 0, driver->panel_width * driver->panel_height * driver->native_bits_per_pixel / 8);
|
memset(surface->buffer, 0, driver->panel_width * driver->panel_height * driver->native_bits_per_pixel / 8);
|
||||||
return true;
|
return true;
|
||||||
|
@ -107,13 +107,13 @@ static bool qp_rgb565_surface_power(painter_device_t device, bool power_on) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool qp_rgb565_surface_clear(painter_device_t device) {
|
static bool qp_rgb565_surface_clear(painter_device_t device) {
|
||||||
struct painter_driver_t *driver = (struct painter_driver_t *)device;
|
painter_driver_t *driver = (painter_driver_t *)device;
|
||||||
driver->driver_vtable->init(device, driver->rotation); // Re-init the surface
|
driver->driver_vtable->init(device, driver->rotation); // Re-init the surface
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool qp_rgb565_surface_flush(painter_device_t device) {
|
static bool qp_rgb565_surface_flush(painter_device_t device) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
|
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
|
||||||
surface->dirty_l = surface->dirty_t = UINT16_MAX;
|
surface->dirty_l = surface->dirty_t = UINT16_MAX;
|
||||||
surface->dirty_r = surface->dirty_b = 0;
|
surface->dirty_r = surface->dirty_b = 0;
|
||||||
|
@ -122,7 +122,7 @@ static bool qp_rgb565_surface_flush(painter_device_t device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool qp_rgb565_surface_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
|
static bool qp_rgb565_surface_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
|
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
|
||||||
|
|
||||||
// Set the viewport locations
|
// Set the viewport locations
|
||||||
|
@ -139,7 +139,7 @@ static bool qp_rgb565_surface_viewport(painter_device_t device, uint16_t left, u
|
||||||
|
|
||||||
// Stream pixel data to the current write position in GRAM
|
// Stream pixel data to the current write position in GRAM
|
||||||
static bool qp_rgb565_surface_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
|
static bool qp_rgb565_surface_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
|
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
|
||||||
stream_pixdata(surface, (const uint16_t *)pixel_data, native_pixel_count);
|
stream_pixdata(surface, (const uint16_t *)pixel_data, native_pixel_count);
|
||||||
return true;
|
return true;
|
||||||
|
@ -170,7 +170,7 @@ static bool qp_rgb565_surface_append_pixdata(painter_device_t device, uint8_t *t
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct painter_driver_vtable_t rgb565_surface_driver_vtable = {
|
const painter_driver_vtable_t rgb565_surface_driver_vtable = {
|
||||||
.init = qp_rgb565_surface_init,
|
.init = qp_rgb565_surface_init,
|
||||||
.power = qp_rgb565_surface_power,
|
.power = qp_rgb565_surface_power,
|
||||||
.clear = qp_rgb565_surface_clear,
|
.clear = qp_rgb565_surface_clear,
|
||||||
|
@ -201,7 +201,7 @@ uint32_t qp_rgb565_surface_comms_send(painter_device_t device, const void *data,
|
||||||
return byte_count;
|
return byte_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct painter_comms_vtable_t rgb565_surface_driver_comms_vtable = {
|
painter_comms_vtable_t rgb565_surface_driver_comms_vtable = {
|
||||||
// These are all effective no-op's because they're not actually needed.
|
// These are all effective no-op's because they're not actually needed.
|
||||||
.comms_init = qp_rgb565_surface_comms_init,
|
.comms_init = qp_rgb565_surface_comms_init,
|
||||||
.comms_start = qp_rgb565_surface_comms_start,
|
.comms_start = qp_rgb565_surface_comms_start,
|
||||||
|
@ -234,7 +234,7 @@ painter_device_t qp_rgb565_make_surface(uint16_t panel_width, uint16_t panel_hei
|
||||||
// Drawing routine to copy out the dirty region and send it to another device
|
// Drawing routine to copy out the dirty region and send it to another device
|
||||||
|
|
||||||
bool qp_rgb565_surface_draw(painter_device_t surface, painter_device_t display, uint16_t x, uint16_t y) {
|
bool qp_rgb565_surface_draw(painter_device_t surface, painter_device_t display, uint16_t x, uint16_t y) {
|
||||||
struct painter_driver_t * surface_driver = (struct painter_driver_t *)surface;
|
painter_driver_t * surface_driver = (painter_driver_t *)surface;
|
||||||
rgb565_surface_painter_device_t *surface_handle = (rgb565_surface_painter_device_t *)surface_driver;
|
rgb565_surface_painter_device_t *surface_handle = (rgb565_surface_painter_device_t *)surface_driver;
|
||||||
|
|
||||||
// If we're not dirty... we're done.
|
// If we're not dirty... we're done.
|
||||||
|
|
|
@ -58,7 +58,7 @@ __attribute__((weak)) bool qp_ili9163_init(painter_device_t device, painter_rota
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Driver vtable
|
// Driver vtable
|
||||||
|
|
||||||
const struct tft_panel_dc_reset_painter_driver_vtable_t ili9163_driver_vtable = {
|
const tft_panel_dc_reset_painter_driver_vtable_t ili9163_driver_vtable = {
|
||||||
.base =
|
.base =
|
||||||
{
|
{
|
||||||
.init = qp_ili9163_init,
|
.init = qp_ili9163_init,
|
||||||
|
@ -93,8 +93,8 @@ painter_device_t qp_ili9163_make_spi_device(uint16_t panel_width, uint16_t panel
|
||||||
for (uint32_t i = 0; i < ILI9163_NUM_DEVICES; ++i) {
|
for (uint32_t i = 0; i < ILI9163_NUM_DEVICES; ++i) {
|
||||||
tft_panel_dc_reset_painter_device_t *driver = &ili9163_drivers[i];
|
tft_panel_dc_reset_painter_device_t *driver = &ili9163_drivers[i];
|
||||||
if (!driver->base.driver_vtable) {
|
if (!driver->base.driver_vtable) {
|
||||||
driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&ili9163_driver_vtable;
|
driver->base.driver_vtable = (const painter_driver_vtable_t *)&ili9163_driver_vtable;
|
||||||
driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
driver->base.comms_vtable = (const painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
||||||
driver->base.panel_width = panel_width;
|
driver->base.panel_width = panel_width;
|
||||||
driver->base.panel_height = panel_height;
|
driver->base.panel_height = panel_height;
|
||||||
driver->base.rotation = QP_ROTATION_0;
|
driver->base.rotation = QP_ROTATION_0;
|
||||||
|
|
|
@ -65,7 +65,7 @@ __attribute__((weak)) bool qp_ili9341_init(painter_device_t device, painter_rota
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Driver vtable
|
// Driver vtable
|
||||||
|
|
||||||
const struct tft_panel_dc_reset_painter_driver_vtable_t ili9341_driver_vtable = {
|
const tft_panel_dc_reset_painter_driver_vtable_t ili9341_driver_vtable = {
|
||||||
.base =
|
.base =
|
||||||
{
|
{
|
||||||
.init = qp_ili9341_init,
|
.init = qp_ili9341_init,
|
||||||
|
@ -100,8 +100,8 @@ painter_device_t qp_ili9341_make_spi_device(uint16_t panel_width, uint16_t panel
|
||||||
for (uint32_t i = 0; i < ILI9341_NUM_DEVICES; ++i) {
|
for (uint32_t i = 0; i < ILI9341_NUM_DEVICES; ++i) {
|
||||||
tft_panel_dc_reset_painter_device_t *driver = &ili9341_drivers[i];
|
tft_panel_dc_reset_painter_device_t *driver = &ili9341_drivers[i];
|
||||||
if (!driver->base.driver_vtable) {
|
if (!driver->base.driver_vtable) {
|
||||||
driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&ili9341_driver_vtable;
|
driver->base.driver_vtable = (const painter_driver_vtable_t *)&ili9341_driver_vtable;
|
||||||
driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
driver->base.comms_vtable = (const painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
||||||
driver->base.native_bits_per_pixel = 16; // RGB565
|
driver->base.native_bits_per_pixel = 16; // RGB565
|
||||||
driver->base.panel_width = panel_width;
|
driver->base.panel_width = panel_width;
|
||||||
driver->base.panel_height = panel_height;
|
driver->base.panel_height = panel_height;
|
||||||
|
|
|
@ -58,7 +58,7 @@ __attribute__((weak)) bool qp_ili9488_init(painter_device_t device, painter_rota
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Driver vtable
|
// Driver vtable
|
||||||
|
|
||||||
const struct tft_panel_dc_reset_painter_driver_vtable_t ili9488_driver_vtable = {
|
const tft_panel_dc_reset_painter_driver_vtable_t ili9488_driver_vtable = {
|
||||||
.base =
|
.base =
|
||||||
{
|
{
|
||||||
.init = qp_ili9488_init,
|
.init = qp_ili9488_init,
|
||||||
|
@ -93,8 +93,8 @@ painter_device_t qp_ili9488_make_spi_device(uint16_t panel_width, uint16_t panel
|
||||||
for (uint32_t i = 0; i < ILI9488_NUM_DEVICES; ++i) {
|
for (uint32_t i = 0; i < ILI9488_NUM_DEVICES; ++i) {
|
||||||
tft_panel_dc_reset_painter_device_t *driver = &ili9488_drivers[i];
|
tft_panel_dc_reset_painter_device_t *driver = &ili9488_drivers[i];
|
||||||
if (!driver->base.driver_vtable) {
|
if (!driver->base.driver_vtable) {
|
||||||
driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&ili9488_driver_vtable;
|
driver->base.driver_vtable = (const painter_driver_vtable_t *)&ili9488_driver_vtable;
|
||||||
driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
driver->base.comms_vtable = (const painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
||||||
driver->base.native_bits_per_pixel = 24; // RGB888
|
driver->base.native_bits_per_pixel = 24; // RGB888
|
||||||
driver->base.panel_width = panel_width;
|
driver->base.panel_width = panel_width;
|
||||||
driver->base.panel_height = panel_height;
|
driver->base.panel_height = panel_height;
|
||||||
|
|
|
@ -62,7 +62,7 @@ __attribute__((weak)) bool qp_ssd1351_init(painter_device_t device, painter_rota
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Driver vtable
|
// Driver vtable
|
||||||
|
|
||||||
const struct tft_panel_dc_reset_painter_driver_vtable_t ssd1351_driver_vtable = {
|
const tft_panel_dc_reset_painter_driver_vtable_t ssd1351_driver_vtable = {
|
||||||
.base =
|
.base =
|
||||||
{
|
{
|
||||||
.init = qp_ssd1351_init,
|
.init = qp_ssd1351_init,
|
||||||
|
@ -97,8 +97,8 @@ painter_device_t qp_ssd1351_make_spi_device(uint16_t panel_width, uint16_t panel
|
||||||
for (uint32_t i = 0; i < SSD1351_NUM_DEVICES; ++i) {
|
for (uint32_t i = 0; i < SSD1351_NUM_DEVICES; ++i) {
|
||||||
tft_panel_dc_reset_painter_device_t *driver = &ssd1351_drivers[i];
|
tft_panel_dc_reset_painter_device_t *driver = &ssd1351_drivers[i];
|
||||||
if (!driver->base.driver_vtable) {
|
if (!driver->base.driver_vtable) {
|
||||||
driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&ssd1351_driver_vtable;
|
driver->base.driver_vtable = (const painter_driver_vtable_t *)&ssd1351_driver_vtable;
|
||||||
driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
driver->base.comms_vtable = (const painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
||||||
driver->base.panel_width = panel_width;
|
driver->base.panel_width = panel_width;
|
||||||
driver->base.panel_height = panel_height;
|
driver->base.panel_height = panel_height;
|
||||||
driver->base.rotation = QP_ROTATION_0;
|
driver->base.rotation = QP_ROTATION_0;
|
||||||
|
|
|
@ -25,7 +25,7 @@ tft_panel_dc_reset_painter_device_t st7735_drivers[ST7735_NUM_DEVICES] = {0};
|
||||||
|
|
||||||
#ifndef ST7735_NO_AUTOMATIC_OFFSETS
|
#ifndef ST7735_NO_AUTOMATIC_OFFSETS
|
||||||
static inline void st7735_automatic_viewport_offsets(painter_device_t device, painter_rotation_t rotation) {
|
static inline void st7735_automatic_viewport_offsets(painter_device_t device, painter_rotation_t rotation) {
|
||||||
struct painter_driver_t *driver = (struct painter_driver_t *)device;
|
painter_driver_t *driver = (painter_driver_t *)device;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
const struct {
|
const struct {
|
||||||
|
@ -82,7 +82,7 @@ __attribute__((weak)) bool qp_st7735_init(painter_device_t device, painter_rotat
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Driver vtable
|
// Driver vtable
|
||||||
|
|
||||||
const struct tft_panel_dc_reset_painter_driver_vtable_t st7735_driver_vtable = {
|
const tft_panel_dc_reset_painter_driver_vtable_t st7735_driver_vtable = {
|
||||||
.base =
|
.base =
|
||||||
{
|
{
|
||||||
.init = qp_st7735_init,
|
.init = qp_st7735_init,
|
||||||
|
@ -117,8 +117,8 @@ painter_device_t qp_st7735_make_spi_device(uint16_t panel_width, uint16_t panel_
|
||||||
for (uint32_t i = 0; i < ST7735_NUM_DEVICES; ++i) {
|
for (uint32_t i = 0; i < ST7735_NUM_DEVICES; ++i) {
|
||||||
tft_panel_dc_reset_painter_device_t *driver = &st7735_drivers[i];
|
tft_panel_dc_reset_painter_device_t *driver = &st7735_drivers[i];
|
||||||
if (!driver->base.driver_vtable) {
|
if (!driver->base.driver_vtable) {
|
||||||
driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&st7735_driver_vtable;
|
driver->base.driver_vtable = (const painter_driver_vtable_t *)&st7735_driver_vtable;
|
||||||
driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
driver->base.comms_vtable = (const painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
||||||
driver->base.panel_width = panel_width;
|
driver->base.panel_width = panel_width;
|
||||||
driver->base.panel_height = panel_height;
|
driver->base.panel_height = panel_height;
|
||||||
driver->base.rotation = QP_ROTATION_0;
|
driver->base.rotation = QP_ROTATION_0;
|
||||||
|
|
|
@ -24,7 +24,7 @@ tft_panel_dc_reset_painter_device_t st7789_drivers[ST7789_NUM_DEVICES] = {0};
|
||||||
|
|
||||||
#ifndef ST7789_NO_AUTOMATIC_OFFSETS
|
#ifndef ST7789_NO_AUTOMATIC_OFFSETS
|
||||||
static inline void st7789_automatic_viewport_offsets(painter_device_t device, painter_rotation_t rotation) {
|
static inline void st7789_automatic_viewport_offsets(painter_device_t device, painter_rotation_t rotation) {
|
||||||
struct painter_driver_t *driver = (struct painter_driver_t *)device;
|
painter_driver_t *driver = (painter_driver_t *)device;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
const struct {
|
const struct {
|
||||||
|
@ -81,7 +81,7 @@ __attribute__((weak)) bool qp_st7789_init(painter_device_t device, painter_rotat
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Driver vtable
|
// Driver vtable
|
||||||
|
|
||||||
const struct tft_panel_dc_reset_painter_driver_vtable_t st7789_driver_vtable = {
|
const tft_panel_dc_reset_painter_driver_vtable_t st7789_driver_vtable = {
|
||||||
.base =
|
.base =
|
||||||
{
|
{
|
||||||
.init = qp_st7789_init,
|
.init = qp_st7789_init,
|
||||||
|
@ -116,8 +116,8 @@ painter_device_t qp_st7789_make_spi_device(uint16_t panel_width, uint16_t panel_
|
||||||
for (uint32_t i = 0; i < ST7789_NUM_DEVICES; ++i) {
|
for (uint32_t i = 0; i < ST7789_NUM_DEVICES; ++i) {
|
||||||
tft_panel_dc_reset_painter_device_t *driver = &st7789_drivers[i];
|
tft_panel_dc_reset_painter_device_t *driver = &st7789_drivers[i];
|
||||||
if (!driver->base.driver_vtable) {
|
if (!driver->base.driver_vtable) {
|
||||||
driver->base.driver_vtable = (const struct painter_driver_vtable_t *)&st7789_driver_vtable;
|
driver->base.driver_vtable = (const painter_driver_vtable_t *)&st7789_driver_vtable;
|
||||||
driver->base.comms_vtable = (const struct painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
driver->base.comms_vtable = (const painter_comms_vtable_t *)&spi_comms_with_dc_vtable;
|
||||||
driver->base.panel_width = panel_width;
|
driver->base.panel_width = panel_width;
|
||||||
driver->base.panel_height = panel_height;
|
driver->base.panel_height = panel_height;
|
||||||
driver->base.rotation = QP_ROTATION_0;
|
driver->base.rotation = QP_ROTATION_0;
|
||||||
|
|
|
@ -12,15 +12,15 @@
|
||||||
|
|
||||||
// Power control
|
// Power control
|
||||||
bool qp_tft_panel_power(painter_device_t device, bool power_on) {
|
bool qp_tft_panel_power(painter_device_t device, bool power_on) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct tft_panel_dc_reset_painter_driver_vtable_t *vtable = (struct tft_panel_dc_reset_painter_driver_vtable_t *)driver->driver_vtable;
|
tft_panel_dc_reset_painter_driver_vtable_t *vtable = (tft_panel_dc_reset_painter_driver_vtable_t *)driver->driver_vtable;
|
||||||
qp_comms_command(device, power_on ? vtable->opcodes.display_on : vtable->opcodes.display_off);
|
qp_comms_command(device, power_on ? vtable->opcodes.display_on : vtable->opcodes.display_off);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Screen clear
|
// Screen clear
|
||||||
bool qp_tft_panel_clear(painter_device_t device) {
|
bool qp_tft_panel_clear(painter_device_t device) {
|
||||||
struct painter_driver_t *driver = (struct painter_driver_t *)device;
|
painter_driver_t *driver = (painter_driver_t *)device;
|
||||||
driver->driver_vtable->init(device, driver->rotation); // Re-init the LCD
|
driver->driver_vtable->init(device, driver->rotation); // Re-init the LCD
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ bool qp_tft_panel_flush(painter_device_t device) {
|
||||||
|
|
||||||
// Viewport to draw to
|
// Viewport to draw to
|
||||||
bool qp_tft_panel_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
|
bool qp_tft_panel_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct tft_panel_dc_reset_painter_driver_vtable_t *vtable = (struct tft_panel_dc_reset_painter_driver_vtable_t *)driver->driver_vtable;
|
tft_panel_dc_reset_painter_driver_vtable_t *vtable = (tft_panel_dc_reset_painter_driver_vtable_t *)driver->driver_vtable;
|
||||||
|
|
||||||
// Fix up the drawing location if required
|
// Fix up the drawing location if required
|
||||||
left += driver->offset_x;
|
left += driver->offset_x;
|
||||||
|
@ -80,7 +80,7 @@ bool qp_tft_panel_viewport(painter_device_t device, uint16_t left, uint16_t top,
|
||||||
|
|
||||||
// Stream pixel data to the current write position in GRAM
|
// Stream pixel data to the current write position in GRAM
|
||||||
bool qp_tft_panel_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
|
bool qp_tft_panel_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
|
||||||
struct painter_driver_t *driver = (struct painter_driver_t *)device;
|
painter_driver_t *driver = (painter_driver_t *)device;
|
||||||
qp_comms_send(device, pixel_data, native_pixel_count * driver->native_bits_per_pixel / 8);
|
qp_comms_send(device, pixel_data, native_pixel_count * driver->native_bits_per_pixel / 8);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
// Common TFT panel implementation using D/C, and RST pins.
|
// Common TFT panel implementation using D/C, and RST pins.
|
||||||
|
|
||||||
// Driver vtable with extras
|
// Driver vtable with extras
|
||||||
struct tft_panel_dc_reset_painter_driver_vtable_t {
|
typedef struct tft_panel_dc_reset_painter_driver_vtable_t {
|
||||||
struct painter_driver_vtable_t base; // must be first, so it can be cast to/from the painter_driver_vtable_t* type
|
painter_driver_vtable_t base; // must be first, so it can be cast to/from the painter_driver_vtable_t* type
|
||||||
|
|
||||||
// Number of bytes for transmitting x/y coordinates
|
// Number of bytes for transmitting x/y coordinates
|
||||||
uint8_t num_window_bytes;
|
uint8_t num_window_bytes;
|
||||||
|
@ -29,16 +29,16 @@ struct tft_panel_dc_reset_painter_driver_vtable_t {
|
||||||
uint8_t set_row_address;
|
uint8_t set_row_address;
|
||||||
uint8_t enable_writes;
|
uint8_t enable_writes;
|
||||||
} opcodes;
|
} opcodes;
|
||||||
};
|
} tft_panel_dc_reset_painter_driver_vtable_t;
|
||||||
|
|
||||||
// Device definition
|
// Device definition
|
||||||
typedef struct tft_panel_dc_reset_painter_device_t {
|
typedef struct tft_panel_dc_reset_painter_device_t {
|
||||||
struct painter_driver_t base; // must be first, so it can be cast to/from the painter_device_t* type
|
painter_driver_t base; // must be first, so it can be cast to/from the painter_device_t* type
|
||||||
|
|
||||||
union {
|
union {
|
||||||
#ifdef QUANTUM_PAINTER_SPI_ENABLE
|
#ifdef QUANTUM_PAINTER_SPI_ENABLE
|
||||||
// SPI-based configurables
|
// SPI-based configurables
|
||||||
struct qp_comms_spi_dc_reset_config_t spi_dc_reset_config;
|
qp_comms_spi_dc_reset_config_t spi_dc_reset_config;
|
||||||
#endif // QUANTUM_PAINTER_SPI_ENABLE
|
#endif // QUANTUM_PAINTER_SPI_ENABLE
|
||||||
|
|
||||||
// TODO: I2C/parallel etc.
|
// TODO: I2C/parallel etc.
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool qp_lvgl_attach(painter_device_t device) {
|
||||||
qp_dprintf("qp_lvgl_start: entry\n");
|
qp_dprintf("qp_lvgl_start: entry\n");
|
||||||
qp_lvgl_detach();
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_lvgl_attach: fail (validation_ok == false)\n");
|
qp_dprintf("qp_lvgl_attach: fail (validation_ok == false)\n");
|
||||||
qp_lvgl_detach();
|
qp_lvgl_detach();
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define QFF_FONT_DESCRIPTOR_TYPEID 0x00
|
#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 }
|
qgf_block_header_v1_t header; // = { .type_id = 0x00, .neg_type_id = (~0x00), .length = 20 }
|
||||||
uint32_t magic : 24; // constant, equal to 0x464651 ("QFF")
|
uint32_t magic : 24; // constant, equal to 0x464651 ("QFF")
|
||||||
uint8_t qff_version; // constant, equal to 0x01
|
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_BITS 18
|
||||||
#define QFF_GLYPH_OFFSET_MASK (((1 << QFF_GLYPH_OFFSET_BITS) - 1) << QFF_GLYPH_WIDTH_BITS)
|
#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
|
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
|
||||||
} qff_ascii_glyph_v1_t;
|
} 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");
|
_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 }
|
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_v1_t glyph[95]; // 95 glyphs, 0x20..0x7E
|
||||||
} qff_ascii_glyph_table_v1_t;
|
} 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
|
#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 code_point : 24;
|
||||||
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
|
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
|
||||||
} qff_unicode_glyph_v1_t;
|
} 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");
|
_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) }
|
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_v1_t glyph[0]; // Extent of '0' signifies that this struct is immediately followed by the glyph data
|
||||||
} qff_unicode_glyph_table_v1_t;
|
} qff_unicode_glyph_table_v1_t;
|
||||||
|
|
|
@ -11,15 +11,15 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Internal driver validation
|
// 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;
|
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;
|
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);
|
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) {
|
bool qp_init(painter_device_t device, painter_rotation_t rotation) {
|
||||||
qp_dprintf("qp_init: entry\n");
|
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;
|
driver->validate_ok = false;
|
||||||
if (!validate_driver_integrity(driver)) {
|
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) {
|
bool qp_power(painter_device_t device, bool power_on) {
|
||||||
qp_dprintf("qp_power: entry\n");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_power: fail (validation_ok == false)\n");
|
qp_dprintf("qp_power: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -86,7 +86,7 @@ bool qp_power(painter_device_t device, bool power_on) {
|
||||||
|
|
||||||
bool qp_clear(painter_device_t device) {
|
bool qp_clear(painter_device_t device) {
|
||||||
qp_dprintf("qp_clear: entry\n");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_clear: fail (validation_ok == false)\n");
|
qp_dprintf("qp_clear: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -108,7 +108,7 @@ bool qp_clear(painter_device_t device) {
|
||||||
|
|
||||||
bool qp_flush(painter_device_t device) {
|
bool qp_flush(painter_device_t device) {
|
||||||
qp_dprintf("qp_flush: entry\n");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_flush: fail (validation_ok == false)\n");
|
qp_dprintf("qp_flush: fail (validation_ok == false)\n");
|
||||||
return false;
|
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) {
|
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");
|
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) {
|
switch (driver->rotation) {
|
||||||
default:
|
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) {
|
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");
|
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_x = offset_x;
|
||||||
driver->offset_y = offset_y;
|
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) {
|
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");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_viewport: fail (validation_ok == false)\n");
|
qp_dprintf("qp_viewport: fail (validation_ok == false)\n");
|
||||||
return false;
|
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) {
|
bool qp_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
|
||||||
qp_dprintf("qp_pixdata: entry\n");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_pixdata: fail (validation_ok == false)\n");
|
qp_dprintf("qp_pixdata: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
// Base comms APIs
|
// Base comms APIs
|
||||||
|
|
||||||
bool qp_comms_init(painter_device_t device) {
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_comms_init: fail (validation_ok == false)\n");
|
qp_dprintf("qp_comms_init: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -17,7 +17,7 @@ bool qp_comms_init(painter_device_t device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qp_comms_start(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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_comms_start: fail (validation_ok == false)\n");
|
qp_dprintf("qp_comms_start: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,7 +27,7 @@ bool qp_comms_start(painter_device_t device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void qp_comms_stop(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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_comms_stop: fail (validation_ok == false)\n");
|
qp_dprintf("qp_comms_stop: fail (validation_ok == false)\n");
|
||||||
return;
|
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) {
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_comms_send: fail (validation_ok == false)\n");
|
qp_dprintf("qp_comms_send: fail (validation_ok == false)\n");
|
||||||
return false;
|
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
|
// Comms APIs that use a D/C pin
|
||||||
|
|
||||||
void qp_comms_command(painter_device_t device, uint8_t cmd) {
|
void qp_comms_command(painter_device_t device, uint8_t cmd) {
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)device;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct painter_comms_with_command_vtable_t *comms_vtable = (struct painter_comms_with_command_vtable_t *)driver->comms_vtable;
|
painter_comms_with_command_vtable_t *comms_vtable = (painter_comms_with_command_vtable_t *)driver->comms_vtable;
|
||||||
comms_vtable->send_command(device, cmd);
|
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) {
|
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;
|
painter_driver_t * driver = (painter_driver_t *)device;
|
||||||
struct painter_comms_with_command_vtable_t *comms_vtable = (struct painter_comms_with_command_vtable_t *)driver->comms_vtable;
|
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);
|
comms_vtable->bulk_command_sequence(device, sequence, sequence_len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ enum qp_internal_rle_mode_t {
|
||||||
NON_REPEATING_RUN,
|
NON_REPEATING_RUN,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct qp_internal_byte_input_state {
|
typedef struct qp_internal_byte_input_state_t {
|
||||||
painter_device_t device;
|
painter_device_t device;
|
||||||
qp_stream_t* src_stream;
|
qp_stream_t* src_stream;
|
||||||
int16_t curr;
|
int16_t curr;
|
||||||
|
@ -74,22 +74,22 @@ struct qp_internal_byte_input_state {
|
||||||
uint8_t remain; // number of bytes remaining in the current mode
|
uint8_t remain; // number of bytes remaining in the current mode
|
||||||
} rle;
|
} 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;
|
painter_device_t device;
|
||||||
uint32_t pixel_write_pos;
|
uint32_t pixel_write_pos;
|
||||||
uint32_t max_pixels;
|
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);
|
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;
|
painter_device_t device;
|
||||||
uint32_t byte_write_pos;
|
uint32_t byte_write_pos;
|
||||||
uint32_t max_bytes;
|
uint32_t max_bytes;
|
||||||
};
|
} qp_internal_byte_output_state_t;
|
||||||
|
|
||||||
bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg);
|
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);
|
||||||
|
|
|
@ -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) {
|
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");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_circle: fail (validation_ok == false)\n");
|
qp_dprintf("qp_circle: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -54,7 +54,7 @@ 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) {
|
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;
|
painter_driver_t* driver = (painter_driver_t*)device;
|
||||||
int16_t steps = 1 << bits_per_pixel; // number of items we need to interpolate
|
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 (qp_internal_interpolate_palette(fg_hsv888, bg_hsv888, steps)) {
|
||||||
if (!driver->driver_vtable->palette_convert(device, steps, qp_internal_global_pixel_lookup_table)) {
|
if (!driver->driver_vtable->palette_convert(device, steps, qp_internal_global_pixel_lookup_table)) {
|
||||||
|
@ -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
|
// Progressive pull of bytes, push of pixels
|
||||||
|
|
||||||
static inline int16_t qp_drawimage_byte_uncompressed_decoder(void* cb_arg) {
|
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;
|
qp_internal_byte_input_state_t* state = (qp_internal_byte_input_state_t*)cb_arg;
|
||||||
state->curr = qp_stream_get(state->src_stream);
|
state->curr = qp_stream_get(state->src_stream);
|
||||||
return state->curr;
|
return state->curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int16_t qp_drawimage_byte_rle_decoder(void* cb_arg) {
|
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
|
// Work out if we're parsing the initial marker byte
|
||||||
if (state->rle.mode == 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) {
|
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;
|
qp_internal_pixel_output_state_t* state = (qp_internal_pixel_output_state_t*)cb_arg;
|
||||||
struct painter_driver_t* driver = (struct painter_driver_t*)state->device;
|
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)) {
|
if (!driver->driver_vtable->append_pixels(state->device, qp_internal_global_pixdata_buffer, palette, state->pixel_write_pos++, 1, &index)) {
|
||||||
return false;
|
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) {
|
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;
|
qp_internal_byte_output_state_t* state = (qp_internal_byte_output_state_t*)cb_arg;
|
||||||
struct painter_driver_t* driver = (struct painter_driver_t*)state->device;
|
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)) {
|
if (!driver->driver_vtable->append_pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos++, byteval)) {
|
||||||
return false;
|
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 we've hit the transmit limit, send out the entire buffer and reset the write position
|
||||||
if (state->byte_write_pos == state->max_bytes) {
|
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)) {
|
if (!driver->driver_vtable->pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos * 8 / driver->native_bits_per_pixel)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) {
|
||||||
return true;
|
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) {
|
switch (compression) {
|
||||||
case IMAGE_UNCOMPRESSED:
|
case IMAGE_UNCOMPRESSED:
|
||||||
return qp_drawimage_byte_uncompressed_decoder;
|
return qp_drawimage_byte_uncompressed_decoder;
|
||||||
|
|
|
@ -37,19 +37,19 @@ __attribute__((__aligned__(4))) qp_pixel_t qp_internal_global_pixel_lookup_table
|
||||||
// Helpers
|
// Helpers
|
||||||
|
|
||||||
uint32_t qp_internal_num_pixels_in_buffer(painter_device_t device) {
|
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);
|
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.
|
// 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) {
|
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);
|
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
|
// 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) {
|
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;
|
painter_driver_t *driver = (painter_driver_t *)device;
|
||||||
uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
|
uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
|
||||||
num_pixels = QP_MIN(pixels_in_pixdata, num_pixels);
|
num_pixels = QP_MIN(pixels_in_pixdata, num_pixels);
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ bool qp_internal_load_qgf_palette(qp_stream_t *stream, uint8_t bpp) {
|
||||||
// Quantum Painter External API: qp_setpixel
|
// 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) {
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_setpixel: fail (validation_ok == false)\n");
|
qp_dprintf("qp_setpixel: fail (validation_ok == false)\n");
|
||||||
return false;
|
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);
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_line: fail (validation_ok == false)\n");
|
qp_dprintf("qp_line: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -229,7 +229,7 @@ bool qp_line(painter_device_t device, uint16_t x0, uint16_t y0, uint16_t x1, uin
|
||||||
|
|
||||||
bool qp_internal_fillrect_helper_impl(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
|
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);
|
uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
|
||||||
struct painter_driver_t *driver = (struct painter_driver_t *)device;
|
painter_driver_t *driver = (painter_driver_t *)device;
|
||||||
|
|
||||||
uint16_t l = QP_MIN(left, right);
|
uint16_t l = QP_MIN(left, right);
|
||||||
uint16_t r = QP_MAX(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) {
|
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);
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_rect: fail (validation_ok == false)\n");
|
qp_dprintf("qp_rect: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -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) {
|
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");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_ellipse: fail (validation_ok == false)\n");
|
qp_dprintf("qp_ellipse: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -124,7 +124,7 @@ typedef struct qgf_frame_info_t {
|
||||||
} 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) {
|
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
|
// Drop out if we can't actually place the data we read out anywhere
|
||||||
if (!info) {
|
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) {
|
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");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_drawimage_recolor: fail (validation_ok == false)\n");
|
qp_dprintf("qp_drawimage_recolor: fail (validation_ok == false)\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -254,7 +254,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the input state
|
// Set up the input state
|
||||||
struct qp_internal_byte_input_state input_state = {.device = device, .src_stream = &qgf_image->stream};
|
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);
|
qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, frame_info->compression_scheme);
|
||||||
if (input_callback == NULL) {
|
if (input_callback == NULL) {
|
||||||
qp_dprintf("qp_drawimage_recolor: fail (invalid image compression scheme)\n");
|
qp_dprintf("qp_drawimage_recolor: fail (invalid image compression scheme)\n");
|
||||||
|
@ -265,7 +265,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (frame_info->bpp <= 8) {
|
if (frame_info->bpp <= 8) {
|
||||||
// Set up the output state
|
// 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
|
// 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);
|
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 {
|
} else {
|
||||||
// Set up the output state
|
// 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
|
// Stream the raw pixel data to the display
|
||||||
uint32_t byte_count = pixel_count * frame_info->bpp / 8;
|
uint32_t byte_count = pixel_count * frame_info->bpp / 8;
|
||||||
|
|
|
@ -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
|
// 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) {
|
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
|
// Drop out if we can't actually place the data we read out anywhere
|
||||||
if (!data_offset) {
|
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
|
// String width calculation
|
||||||
|
|
||||||
// Callback state
|
// Callback state
|
||||||
struct code_point_iter_calcwidth_state {
|
typedef struct code_point_iter_calcwidth_state_t {
|
||||||
int16_t width;
|
int16_t width;
|
||||||
};
|
} code_point_iter_calcwidth_state_t;
|
||||||
|
|
||||||
// Codepoint handler callback: width calc
|
// 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) {
|
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
|
// Increment the overall width by this glyph's width
|
||||||
state->width += 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
|
// String drawing implementation
|
||||||
|
|
||||||
// Callback state
|
// Callback state
|
||||||
struct code_point_iter_drawglyph_state {
|
typedef struct code_point_iter_drawglyph_state_t {
|
||||||
painter_device_t device;
|
painter_device_t device;
|
||||||
int16_t xpos;
|
int16_t xpos;
|
||||||
int16_t ypos;
|
int16_t ypos;
|
||||||
qp_internal_byte_input_callback input_callback;
|
qp_internal_byte_input_callback input_callback;
|
||||||
struct qp_internal_byte_input_state * input_state;
|
qp_internal_byte_input_state_t * input_state;
|
||||||
struct qp_internal_pixel_output_state *output_state;
|
qp_internal_pixel_output_state_t *output_state;
|
||||||
};
|
} code_point_iter_drawglyph_state_t;
|
||||||
|
|
||||||
// Codepoint handler callback: drawing
|
// 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) {
|
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;
|
code_point_iter_drawglyph_state_t *state = (code_point_iter_drawglyph_state_t *)cb_arg;
|
||||||
struct painter_driver_t * driver = (struct painter_driver_t *)state->device;
|
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()
|
// 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
|
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
|
// 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.
|
// 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;
|
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) {
|
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");
|
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) {
|
if (!driver->validate_ok) {
|
||||||
qp_dprintf("qp_drawtext_recolor: fail (validation_ok == false)\n");
|
qp_dprintf("qp_drawtext_recolor: fail (validation_ok == false)\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -423,7 +423,7 @@ 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
|
// 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_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);
|
qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, qff_font->compression_scheme);
|
||||||
if (input_callback == NULL) {
|
if (input_callback == NULL) {
|
||||||
qp_dprintf("qp_drawtext_recolor: fail (invalid font compression scheme)\n");
|
qp_dprintf("qp_drawtext_recolor: fail (invalid font compression scheme)\n");
|
||||||
|
@ -432,10 +432,10 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the pixel output state
|
// 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
|
// Set up the codepoint iteration state
|
||||||
struct code_point_iter_drawglyph_state state = {// Common
|
code_point_iter_drawglyph_state_t state = {// Common
|
||||||
.device = device,
|
.device = device,
|
||||||
.xpos = x,
|
.xpos = x,
|
||||||
.ypos = y,
|
.ypos = y,
|
||||||
|
|
|
@ -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);
|
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
|
// Driver vtable definition
|
||||||
struct painter_driver_vtable_t {
|
typedef struct painter_driver_vtable_t {
|
||||||
painter_driver_init_func init;
|
painter_driver_init_func init;
|
||||||
painter_driver_power_func power;
|
painter_driver_power_func power;
|
||||||
painter_driver_clear_func clear;
|
painter_driver_clear_func clear;
|
||||||
|
@ -29,7 +29,7 @@ struct painter_driver_vtable_t {
|
||||||
painter_driver_convert_palette_func palette_convert;
|
painter_driver_convert_palette_func palette_convert;
|
||||||
painter_driver_append_pixels append_pixels;
|
painter_driver_append_pixels append_pixels;
|
||||||
painter_driver_append_pixdata append_pixdata;
|
painter_driver_append_pixdata append_pixdata;
|
||||||
};
|
} painter_driver_vtable_t;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Comms callbacks
|
// 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 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);
|
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_init_func comms_init;
|
||||||
painter_driver_comms_start_func comms_start;
|
painter_driver_comms_start_func comms_start;
|
||||||
painter_driver_comms_stop_func comms_stop;
|
painter_driver_comms_stop_func comms_stop;
|
||||||
painter_driver_comms_send_func comms_send;
|
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_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);
|
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 {
|
typedef 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
|
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_send_command_func send_command;
|
||||||
painter_driver_comms_bulk_command_sequence bulk_command_sequence;
|
painter_driver_comms_bulk_command_sequence bulk_command_sequence;
|
||||||
};
|
} painter_comms_with_command_vtable_t;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Driver base definition
|
// Driver base definition
|
||||||
|
|
||||||
struct painter_driver_t {
|
typedef struct painter_driver_t {
|
||||||
const struct painter_driver_vtable_t *driver_vtable;
|
const painter_driver_vtable_t *driver_vtable;
|
||||||
const struct painter_comms_vtable_t * comms_vtable;
|
const painter_comms_vtable_t * comms_vtable;
|
||||||
|
|
||||||
// Flag signifying if validation was successful
|
// Flag signifying if validation was successful
|
||||||
bool validate_ok;
|
bool validate_ok;
|
||||||
|
@ -81,7 +81,7 @@ struct painter_driver_t {
|
||||||
|
|
||||||
// Comms config pointer -- needs to point to an appropriate comms config if the comms driver requires it.
|
// Comms config pointer -- needs to point to an appropriate comms config if the comms driver requires it.
|
||||||
void *comms_config;
|
void *comms_config;
|
||||||
};
|
} painter_driver_t;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Device internals
|
// Device internals
|
||||||
|
|
|
@ -48,14 +48,14 @@ uint32_t qp_stream_write_impl(const void *input_buf, uint32_t member_size, uint3
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Stream definition
|
// Stream definition
|
||||||
|
|
||||||
struct qp_stream_t {
|
typedef struct qp_stream_t {
|
||||||
int16_t (*get)(qp_stream_t *stream);
|
int16_t (*get)(qp_stream_t *stream);
|
||||||
bool (*put)(qp_stream_t *stream, uint8_t c);
|
bool (*put)(qp_stream_t *stream, uint8_t c);
|
||||||
int (*seek)(qp_stream_t *stream, int32_t offset, int origin);
|
int (*seek)(qp_stream_t *stream, int32_t offset, int origin);
|
||||||
int32_t (*tell)(qp_stream_t *stream);
|
int32_t (*tell)(qp_stream_t *stream);
|
||||||
bool (*is_eof)(qp_stream_t *stream);
|
bool (*is_eof)(qp_stream_t *stream);
|
||||||
void (*close)(qp_stream_t *stream);
|
void (*close)(qp_stream_t *stream);
|
||||||
};
|
} qp_stream_t;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Memory streams
|
// Memory streams
|
||||||
|
|
Loading…
Reference in New Issue