logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

qp_tft_panel.h (2828B)


  1. // Copyright 2021 Nick Brassel (@tzarc)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "color.h"
  5. #include "qp_internal.h"
  6. #ifdef QUANTUM_PAINTER_SPI_ENABLE
  7. # include "qp_comms_spi.h"
  8. #endif // QUANTUM_PAINTER_SPI_ENABLE
  9. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. // Common TFT panel implementation using D/C, and RST pins.
  11. // Driver vtable with extras
  12. typedef struct tft_panel_dc_reset_painter_driver_vtable_t {
  13. painter_driver_vtable_t base; // must be first, so it can be cast to/from the painter_driver_vtable_t* type
  14. // Number of bytes for transmitting x/y coordinates
  15. uint8_t num_window_bytes;
  16. // Whether or not the x/y coords should be swapped on 90/270 rotation
  17. bool swap_window_coords;
  18. // Opcodes for normal display operation
  19. struct {
  20. uint8_t display_on;
  21. uint8_t display_off;
  22. uint8_t set_column_address;
  23. uint8_t set_row_address;
  24. uint8_t enable_writes;
  25. } opcodes;
  26. } tft_panel_dc_reset_painter_driver_vtable_t;
  27. // Device definition
  28. typedef struct tft_panel_dc_reset_painter_device_t {
  29. painter_driver_t base; // must be first, so it can be cast to/from the painter_device_t* type
  30. union {
  31. #ifdef QUANTUM_PAINTER_SPI_ENABLE
  32. // SPI-based configurables
  33. qp_comms_spi_dc_reset_config_t spi_dc_reset_config;
  34. #endif // QUANTUM_PAINTER_SPI_ENABLE
  35. // TODO: I2C/parallel etc.
  36. };
  37. } tft_panel_dc_reset_painter_device_t;
  38. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  39. // Forward declarations for injecting into concrete driver vtables
  40. bool qp_tft_panel_power(painter_device_t device, bool power_on);
  41. bool qp_tft_panel_clear(painter_device_t device);
  42. bool qp_tft_panel_flush(painter_device_t device);
  43. bool qp_tft_panel_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom);
  44. bool qp_tft_panel_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count);
  45. bool qp_tft_panel_palette_convert_rgb565_swapped(painter_device_t device, int16_t palette_size, qp_pixel_t *palette);
  46. bool qp_tft_panel_palette_convert_rgb888(painter_device_t device, int16_t palette_size, qp_pixel_t *palette);
  47. bool qp_tft_panel_append_pixels_rgb565(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices);
  48. bool qp_tft_panel_append_pixels_rgb888(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices);
  49. bool qp_tft_panel_append_pixdata(painter_device_t device, uint8_t *target_buffer, uint32_t pixdata_offset, uint8_t pixdata_byte);