logo

qmk_firmware

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

qp_sh1106.h (2760B)


  1. // Copyright 2023 Nick Brassel (@tzarc)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "gpio.h"
  5. #include "qp_internal.h"
  6. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  7. // Quantum Painter SH1106 configurables (add to your keyboard's config.h)
  8. #if defined(QUANTUM_PAINTER_SH1106_SPI_ENABLE) && !defined(SH1106_NUM_SPI_DEVICES)
  9. /**
  10. * @def This controls the maximum number of SPI SH1106 devices that Quantum Painter can communicate with at any one time.
  11. * Increasing this number allows for multiple displays to be used.
  12. */
  13. # define SH1106_NUM_SPI_DEVICES 1
  14. #else
  15. # define SH1106_NUM_SPI_DEVICES 0
  16. #endif
  17. #if defined(QUANTUM_PAINTER_SH1106_I2C_ENABLE) && !defined(SH1106_NUM_I2C_DEVICES)
  18. /**
  19. * @def This controls the maximum number of I2C SH1106 devices that Quantum Painter can communicate with at any one time.
  20. * Increasing this number allows for multiple displays to be used.
  21. */
  22. # define SH1106_NUM_I2C_DEVICES 1
  23. #else
  24. # define SH1106_NUM_I2C_DEVICES 0
  25. #endif
  26. #define SH1106_NUM_DEVICES ((SH1106_NUM_SPI_DEVICES) + (SH1106_NUM_I2C_DEVICES))
  27. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  28. // Quantum Painter SH1106 device factories
  29. #ifdef QUANTUM_PAINTER_SH1106_SPI_ENABLE
  30. /**
  31. * Factory method for an SH1106 SPI LCD device.
  32. *
  33. * @param panel_width[in] the width of the display in pixels (usually 128)
  34. * @param panel_height[in] the height of the display in pixels (usually 64)
  35. * @param chip_select_pin[in] the GPIO pin used for SPI chip select
  36. * @param dc_pin[in] the GPIO pin used for D/C control
  37. * @param reset_pin[in] the GPIO pin used for RST
  38. * @param spi_divisor[in] the SPI divisor to use when communicating with the display
  39. * @param spi_mode[in] the SPI mode to use when communicating with the display
  40. * @return the device handle used with all drawing routines in Quantum Painter
  41. */
  42. painter_device_t qp_sh1106_make_spi_device(uint16_t panel_width, uint16_t panel_height, pin_t chip_select_pin, pin_t dc_pin, pin_t reset_pin, uint16_t spi_divisor, int spi_mode);
  43. #endif // QUANTUM_PAINTER_SH1106_SPI_ENABLE
  44. #ifdef QUANTUM_PAINTER_SH1106_I2C_ENABLE
  45. /**
  46. * Factory method for an SH1106 I2C LCD device.
  47. *
  48. * @param panel_width[in] the width of the display in pixels (usually 128)
  49. * @param panel_height[in] the height of the display in pixels (usually 64)
  50. * @param i2c_address[in] the I2C address to use
  51. * @return the device handle used with all drawing routines in Quantum Painter
  52. */
  53. painter_device_t qp_sh1106_make_i2c_device(uint16_t panel_width, uint16_t panel_height, uint8_t i2c_address);
  54. #endif // QUANTUM_PAINTER_SH1106_I2C_ENABLE