logo

qmk_firmware

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

qp_oled_panel.h (3137B)


  1. // Copyright 2023 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. #include "qp_surface_internal.h"
  7. #ifdef QUANTUM_PAINTER_SPI_ENABLE
  8. # include "qp_comms_spi.h"
  9. #endif // QUANTUM_PAINTER_SPI_ENABLE
  10. #ifdef QUANTUM_PAINTER_I2C_ENABLE
  11. # include "qp_comms_i2c.h"
  12. #endif // QUANTUM_PAINTER_I2C_ENABLE
  13. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  14. // Common OLED panel implementation
  15. // Driver vtable with extras
  16. typedef struct oled_panel_painter_driver_vtable_t {
  17. painter_driver_vtable_t base; // must be first, so it can be cast to/from the painter_driver_vtable_t* type
  18. // Opcodes for normal display operation
  19. struct {
  20. uint8_t display_on;
  21. uint8_t display_off;
  22. uint8_t set_page;
  23. uint8_t set_column_lsb;
  24. uint8_t set_column_msb;
  25. } opcodes;
  26. } oled_panel_painter_driver_vtable_t;
  27. // Device definition
  28. typedef struct oled_panel_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. #ifdef QUANTUM_PAINTER_I2C_ENABLE
  36. // I2C-based configurables
  37. qp_comms_i2c_config_t i2c_config;
  38. #endif // QUANTUM_PAINTER_I2C_ENABLE
  39. };
  40. surface_painter_device_t surface;
  41. } oled_panel_painter_device_t;
  42. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  43. // Forward declarations for injecting into concrete driver vtables
  44. bool qp_oled_panel_power(painter_device_t device, bool power_on);
  45. bool qp_oled_panel_clear(painter_device_t device);
  46. bool qp_oled_panel_passthru_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count);
  47. bool qp_oled_panel_passthru_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom);
  48. bool qp_oled_panel_passthru_palette_convert(painter_device_t device, int16_t palette_size, qp_pixel_t *palette);
  49. bool qp_oled_panel_passthru_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);
  50. bool qp_oled_panel_passthru_append_pixdata(painter_device_t device, uint8_t *target_buffer, uint32_t pixdata_offset, uint8_t pixdata_byte);
  51. // Helpers for flushing data from the dirty region to the correct location on the OLED
  52. void qp_oled_panel_page_column_flush_rot0(painter_device_t device, surface_dirty_data_t *dirty, const uint8_t *framebuffer);
  53. void qp_oled_panel_page_column_flush_rot90(painter_device_t device, surface_dirty_data_t *dirty, const uint8_t *framebuffer);
  54. void qp_oled_panel_page_column_flush_rot180(painter_device_t device, surface_dirty_data_t *dirty, const uint8_t *framebuffer);
  55. void qp_oled_panel_page_column_flush_rot270(painter_device_t device, surface_dirty_data_t *dirty, const uint8_t *framebuffer);