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