Add LD7032 support to QP. (#20828)

Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
This commit is contained in:
Dasky 2024-09-18 12:44:33 +01:00 committed by GitHub
parent 7983f7409b
commit 49e339ba8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 591 additions and 1 deletions

View File

@ -28,6 +28,8 @@ Supported devices:
| ILI9341 | RGB LCD | 240x320 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9341_spi` | | ILI9341 | RGB LCD | 240x320 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9341_spi` |
| ILI9486 | RGB LCD | 320x480 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9486_spi` | | ILI9486 | RGB LCD | 320x480 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9486_spi` |
| ILI9488 | RGB LCD | 320x480 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9488_spi` | | ILI9488 | RGB LCD | 320x480 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9488_spi` |
| LD7032 (SPI) | Monochrome OLED | 128x40 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ld7032_spi` |
| LD7032 (I2C) | Monochrome OLED | 128x40 | I2C | `QUANTUM_PAINTER_DRIVERS += ld7032_i2c` |
| SSD1351 | RGB OLED | 128x128 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ssd1351_spi` | | SSD1351 | RGB OLED | 128x128 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ssd1351_spi` |
| ST7735 | RGB LCD | 132x162, 80x160 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += st7735_spi` | | ST7735 | RGB LCD | 132x162, 80x160 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += st7735_spi` |
| ST7789 | RGB LCD | 240x320, 240x240 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += st7789_spi` | | ST7789 | RGB LCD | 240x320, 240x240 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += st7789_spi` |
@ -478,6 +480,40 @@ Native color format mono2 is compatible with SH1106
SSD1306 and SH1106 are almost entirely identical, to the point of being indisinguishable by Quantum Painter. Enable SH1106 support in Quantum Painter and create SH1106 devices in firmware to perform drawing operations on SSD1306 displays. SSD1306 and SH1106 are almost entirely identical, to the point of being indisinguishable by Quantum Painter. Enable SH1106 support in Quantum Painter and create SH1106 devices in firmware to perform drawing operations on SSD1306 displays.
==== LD7032
Enabling support for the LD7032 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
# For SPI:
QUANTUM_PAINTER_DRIVERS += ld7032_spi
# For I2C:
QUANTUM_PAINTER_DRIVERS += ld7032_i2c
```
Creating a SH1106 device in firmware can then be done with the following APIs:
```c
// SPI-based LD7032:
painter_device_t qp_ld7032_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);
// I2C-based LD7032:
painter_device_t qp_ld7032_make_i2c_device(uint16_t panel_width, uint16_t panel_height, uint8_t i2c_address);
```
The device handle returned from the `qp_ld7032_make_???_device` function can be used to perform all other drawing operations.
The maximum number of displays of each type can be configured by changing the following in your `config.h` (default is 1):
```c
// 3 SPI displays:
#define LD7032_NUM_SPI_DEVICES 3
// 3 I2C displays:
#define LD7032_NUM_I2C_DEVICES 3
```
Native color format mono2 is compatible with LD7032.
::::: :::::
===== Surface ===== Surface

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,66 @@
// Copyright 2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "gpio.h"
#include "qp_internal.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter LD7032 configurables (add to your keyboard's config.h)
#if defined(QUANTUM_PAINTER_LD7032_SPI_ENABLE) && !defined(LD7032_NUM_SPI_DEVICES)
/**
* @def This controls the maximum number of SPI LD7032 devices that Quantum Painter can communicate with at any one time.
* Increasing this number allows for multiple displays to be used.
*/
# define LD7032_NUM_SPI_DEVICES 1
#else
# define LD7032_NUM_SPI_DEVICES 0
#endif
#if defined(QUANTUM_PAINTER_LD7032_I2C_ENABLE) && !defined(LD7032_NUM_I2C_DEVICES)
/**
* @def This controls the maximum number of I2C LD7032 devices that Quantum Painter can communicate with at any one time.
* Increasing this number allows for multiple displays to be used.
*/
# define LD7032_NUM_I2C_DEVICES 1
#else
# define LD7032_NUM_I2C_DEVICES 0
#endif
#define LD7032_NUM_DEVICES ((LD7032_NUM_SPI_DEVICES) + (LD7032_NUM_I2C_DEVICES))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter LD7032 device factories
#ifdef QUANTUM_PAINTER_LD7032_SPI_ENABLE
/**
* Factory method for an LD7032 SPI LCD device.
*
* @param panel_width[in] the width of the display in pixels (usually 128)
* @param panel_height[in] the height of the display in pixels (usually 64)
* @param chip_select_pin[in] the GPIO pin used for SPI chip select
* @param dc_pin[in] the GPIO pin used for D/C control
* @param reset_pin[in] the GPIO pin used for RST
* @param spi_divisor[in] the SPI divisor to use when communicating with the display
* @param spi_mode[in] the SPI mode to use when communicating with the display
* @return the device handle used with all drawing routines in Quantum Painter
*/
painter_device_t qp_ld7032_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);
#endif // QUANTUM_PAINTER_LD7032_SPI_ENABLE
#ifdef QUANTUM_PAINTER_LD7032_I2C_ENABLE
/**
* Factory method for an LD7032 I2C LCD device.
*
* @param panel_width[in] the width of the display in pixels (usually 128)
* @param panel_height[in] the height of the display in pixels (usually 64)
* @param i2c_address[in] the I2C address to use
* @return the device handle used with all drawing routines in Quantum Painter
*/
painter_device_t qp_ld7032_make_i2c_device(uint16_t panel_width, uint16_t panel_height, uint8_t i2c_address);
#endif // QUANTUM_PAINTER_LD7032_I2C_ENABLE

View File

@ -0,0 +1,45 @@
// Copyright 2023 Dasky (@daskygit)
// SPDX-License-Identifier: GPL-2.0-or-later
typedef enum {
LD7032_SOFTRES = 0x01,
LD7032_DISP_ON_OFF = 0x02,
LD7032_DATA_RW = 0x08,
LD7032_DISP_DIRECTION = 0x09,
LD7032_IFMODE = 0x0D,
LD7032_PEAK_WIDTH = 0x10,
LD7032_DOT_CURRENT = 0x12,
LD7032_SCAN_MODE = 0x13,
LD7032_DISP_STBY_ON_OFF = 0x14,
LD7032_PEAK_DELAY = 0x16,
LD7032_ROW_SCAN = 0x17,
LD7032_PRE_C_WIDTH = 0x18,
LD7032_DFRAME = 0x1A,
LD7032_DATA_REVERSE = 0x1C,
LD7032_WRITE_DIRECTION = 0x1D,
LD7032_READREG = 0x20,
LD7032_DISP_SIZE_X = 0x30,
LD7032_DISP_SIZE_Y = 0x32,
LD7032_X_BOX_ADR_START = 0x34,
LD7032_X_BOX_ADR_END = 0x35,
LD7032_Y_BOX_ADR_START = 0x36,
LD7032_Y_BOX_ADR_END = 0x37,
LD7032_X_DISP_START = 0x38,
LD7032_Y_DISP_START = 0x39,
LD7032_XTALK_EN = 0x3A,
LD7032_XTALK_REF = 0x3B,
LD7032_AGING_EN = 0x3C,
LD7032_VDD_SEL = 0x3D,
LD7032_TESTCNT0 = 0x3E,
LD7032_VCC_R_SEL = 0x3F,
LD7032_PRE_C_SELECT = 0x44,
LD7032_ROW_OVERLAP = 0x48,
LD7032_S_SLEEP_TIMER = 0xC0,
LD7032_S_SLEEP_START = 0xC2,
LD7032_S_STEP_TIMER = 0xC3,
LD7032_S_STEP_UNIT = 0xC4,
LD7032_S_CONDITION = 0xCC,
LD7032_S_START_STOP = 0xCD,
LD7032_S_SELECT = 0xCE,
LD7032_TESTCNT1 = 0xF0, //-0xFF
} ld7032_opcodes;

View File

@ -557,6 +557,12 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
# define SH1106_NUM_DEVICES 0 # define SH1106_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_SH1106_ENABLE #endif // QUANTUM_PAINTER_SH1106_ENABLE
#ifdef QUANTUM_PAINTER_LD7032_ENABLE
# include "qp_ld7032.h"
#else // QUANTUM_PAINTER_LD7032_ENABLE
# define LD7032_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_LD7032_ENABLE
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter Extras // Quantum Painter Extras

View File

@ -19,6 +19,7 @@ enum {
+ (GC9107_NUM_DEVICES) // GC9107 + (GC9107_NUM_DEVICES) // GC9107
+ (SSD1351_NUM_DEVICES) // SSD1351 + (SSD1351_NUM_DEVICES) // SSD1351
+ (SH1106_NUM_DEVICES) // SH1106 + (SH1106_NUM_DEVICES) // SH1106
+ (LD7032_NUM_DEVICES) // LD7032
}; };
static painter_device_t qp_devices[QP_NUM_DEVICES] = {NULL}; static painter_device_t qp_devices[QP_NUM_DEVICES] = {NULL};

View File

@ -17,7 +17,9 @@ VALID_QUANTUM_PAINTER_DRIVERS := \
gc9107_spi \ gc9107_spi \
ssd1351_spi \ ssd1351_spi \
sh1106_i2c \ sh1106_i2c \
sh1106_spi sh1106_spi \
ld7032_i2c \
ld7032_spi
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -182,6 +184,29 @@ define handle_quantum_painter_driver
$(DRIVER_PATH)/painter/oled_panel/qp_oled_panel.c \ $(DRIVER_PATH)/painter/oled_panel/qp_oled_panel.c \
$(DRIVER_PATH)/painter/sh1106/qp_sh1106.c $(DRIVER_PATH)/painter/sh1106/qp_sh1106.c
else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),ld7032_spi)
QUANTUM_PAINTER_NEEDS_SURFACE := yes
QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes
QUANTUM_PAINTER_NEEDS_COMMS_SPI_DC_RESET := yes
OPT_DEFS += -DQUANTUM_PAINTER_LD7032_ENABLE -DQUANTUM_PAINTER_LD7032_SPI_ENABLE
COMMON_VPATH += \
$(DRIVER_PATH)/painter/oled_panel \
$(DRIVER_PATH)/painter/ld7032
SRC += \
$(DRIVER_PATH)/painter/oled_panel/qp_oled_panel.c \
$(DRIVER_PATH)/painter/ld7032/qp_ld7032.c
else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),ld7032_i2c)
QUANTUM_PAINTER_NEEDS_SURFACE := yes
QUANTUM_PAINTER_NEEDS_COMMS_I2C := yes
OPT_DEFS += -DQUANTUM_PAINTER_LD7032_ENABLE -DQUANTUM_PAINTER_LD7032_I2C_ENABLE
COMMON_VPATH += \
$(DRIVER_PATH)/painter/oled_panel \
$(DRIVER_PATH)/painter/ld7032
SRC += \
$(DRIVER_PATH)/painter/oled_panel/qp_oled_panel.c \
$(DRIVER_PATH)/painter/ld7032/qp_ld7032.c
endif endif
endef endef