1f2b1dedcc
* Install dependencies before executing unit tests. * Split out UTF-8 decoder. * Fixup python formatting rules. * Add documentation for QGF/QFF and the RLE format used. * Add CLI commands for converting images and fonts. * Add stub rules.mk for QP. * Add stream type. * Add base driver and comms interfaces. * Add support for SPI, SPI+D/C comms drivers. * Include <qp.h> when enabled. * Add base support for SPI+D/C+RST panels, as well as concrete implementation of ST7789. * Add support for GC9A01. * Add support for ILI9341. * Add support for ILI9163. * Add support for SSD1351. * Implement qp_setpixel, including pixdata buffer management. * Implement qp_line. * Implement qp_rect. * Implement qp_circle. * Implement qp_ellipse. * Implement palette interpolation. * Allow for streams to work with either flash or RAM. * Image loading. * Font loading. * QGF palette loading. * Progressive decoder of pixel data supporting Raw+RLE, 1-,2-,4-,8-bpp monochrome and palette-based images. * Image drawing. * Animations. * Font rendering. * Check against 256 colours, dump out the loaded palette if debugging enabled. * Fix build. * AVR is not the intended audience. * `qmk format-c` * Generation fix. * First batch of docs. * More docs and examples. * Review comments. * Public API documentation.
68 lines
2.7 KiB
C
68 lines
2.7 KiB
C
// Copyright 2021 Nick Brassel (@tzarc)
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "color.h"
|
|
#include "qp_internal.h"
|
|
|
|
#ifdef QUANTUM_PAINTER_SPI_ENABLE
|
|
# include "qp_comms_spi.h"
|
|
#endif // QUANTUM_PAINTER_SPI_ENABLE
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Common TFT panel implementation using D/C, and RST pins.
|
|
|
|
typedef uint16_t (*rgb888_to_native_uint16_t)(uint8_t r, uint8_t g, uint8_t b);
|
|
|
|
// Driver vtable with extras
|
|
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
|
|
|
|
// Conversion function for palette entries
|
|
rgb888_to_native_uint16_t rgb888_to_native16bit;
|
|
|
|
// Number of bytes for transmitting x/y coordinates
|
|
uint8_t num_window_bytes;
|
|
|
|
// Whether or not the x/y coords should be swapped on 90/270 rotation
|
|
bool swap_window_coords;
|
|
|
|
// Opcodes for normal display operation
|
|
struct {
|
|
uint8_t display_on;
|
|
uint8_t display_off;
|
|
uint8_t set_column_address;
|
|
uint8_t set_row_address;
|
|
uint8_t enable_writes;
|
|
} opcodes;
|
|
};
|
|
|
|
// Device definition
|
|
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
|
|
|
|
union {
|
|
#ifdef QUANTUM_PAINTER_SPI_ENABLE
|
|
// SPI-based configurables
|
|
struct qp_comms_spi_dc_reset_config_t spi_dc_reset_config;
|
|
#endif // QUANTUM_PAINTER_SPI_ENABLE
|
|
|
|
// TODO: I2C/parallel etc.
|
|
};
|
|
} tft_panel_dc_reset_painter_device_t;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Forward declarations for injecting into concrete driver vtables
|
|
|
|
bool qp_tft_panel_power(painter_device_t device, bool power_on);
|
|
bool qp_tft_panel_clear(painter_device_t device);
|
|
bool qp_tft_panel_flush(painter_device_t device);
|
|
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_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count);
|
|
bool qp_tft_panel_palette_convert(painter_device_t device, int16_t palette_size, qp_pixel_t *palette);
|
|
bool qp_tft_panel_append_pixels(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices);
|
|
|
|
uint16_t qp_rgb888_to_rgb565(uint8_t r, uint8_t g, uint8_t b);
|
|
uint16_t qp_rgb888_to_rgb565_swapped(uint8_t r, uint8_t g, uint8_t b);
|
|
uint16_t qp_rgb888_to_bgr565(uint8_t r, uint8_t g, uint8_t b);
|
|
uint16_t qp_rgb888_to_bgr565_swapped(uint8_t r, uint8_t g, uint8_t b);
|