[Core] Refactor OLED to allow easy addition of other types (#13454)
* add docs * core changes * update keyboards to new OLED * updated users to new OLED * update layouts to new OLED * fixup docs * drashna's suggestion * fix up docs * new keyboards with oled * core split changes * remaining keyboard files * Fix The Helix keyboards oled options * reflect develop Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: mtei <2170248+mtei@users.noreply.github.com>
This commit is contained in:
parent
6fd20acf4b
commit
4e1c5887c5
500 changed files with 1579 additions and 1387 deletions
|
|
@ -592,11 +592,21 @@ ifeq ($(strip $(HD44780_ENABLE)), yes)
|
|||
OPT_DEFS += -DHD44780_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
|
||||
OPT_DEFS += -DOLED_DRIVER_ENABLE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/oled
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
SRC += oled_driver.c
|
||||
VALID_OLED_DRIVER_TYPES := SSD1306 custom
|
||||
OLED_DRIVER ?= SSD1306
|
||||
ifeq ($(strip $(OLED_ENABLE)), yes)
|
||||
ifeq ($(filter $(OLED_DRIVER),$(VALID_OLED_DRIVER_TYPES)),)
|
||||
$(error OLED_DRIVER="$(OLED_DRIVER)" is not a valid OLED driver)
|
||||
else
|
||||
OPT_DEFS += -DOLED_ENABLE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/oled
|
||||
|
||||
OPT_DEFS += -DOLED_DRIVER_$(strip $(shell echo $(OLED_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
ifeq ($(strip $(OLED_DRIVER)), SSD1306)
|
||||
SRC += ssd1306_sh1106.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(ST7565_ENABLE)), yes)
|
||||
|
|
|
|||
|
|
@ -21,13 +21,23 @@ Hardware configurations using Arm-based microcontrollers or different sizes of O
|
|||
To enable the OLED feature, there are three steps. First, when compiling your keyboard, you'll need to add the following to your `rules.mk`:
|
||||
|
||||
```make
|
||||
OLED_DRIVER_ENABLE = yes
|
||||
OLED_ENABLE = yes
|
||||
```
|
||||
|
||||
## OLED type
|
||||
|OLED Driver |Supported Device |
|
||||
|-------------------|---------------------------|
|
||||
|SSD1306 (default) |For both SSD1306 and SH1106|
|
||||
|
||||
e.g.
|
||||
```make
|
||||
OLED_DRIVER = SSD1306
|
||||
```
|
||||
|
||||
Then in your `keymap.c` file, implement the OLED task call. This example assumes your keymap has three layers named `_QWERTY`, `_FN` and `_ADJ`:
|
||||
|
||||
```c
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
void oled_task_user(void) {
|
||||
// Host Keyboard Layer Status
|
||||
oled_write_P(PSTR("Layer: "), false);
|
||||
|
|
@ -114,7 +124,7 @@ static void fade_display(void) {
|
|||
In split keyboards, it is very common to have two OLED displays that each render different content and are oriented or flipped differently. You can do this by switching which content to render by using the return value from `is_keyboard_master()` or `is_keyboard_left()` found in `split_util.h`, e.g:
|
||||
|
||||
```c
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
if (!is_keyboard_master()) {
|
||||
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
|||
#endif
|
||||
|
||||
/* oled stuff :) */
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
uint16_t startup_timer;
|
||||
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
|||
#endif
|
||||
|
||||
/* oled stuff :) */
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
uint16_t startup_timer;
|
||||
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
|||
#endif
|
||||
|
||||
/* oled stuff :) */
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
uint16_t startup_timer;
|
||||
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
|||
#endif
|
||||
|
||||
/* oled stuff :) */
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
uint16_t startup_timer;
|
||||
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
|
|
|
|||
|
|
@ -24,4 +24,5 @@ AUDIO_ENABLE = no # Audio output
|
|||
|
||||
ENCODER_ENABLE = yes
|
||||
LTO_ENABLE = yes
|
||||
OLED_DRIVER_ENABLE = yes
|
||||
OLED_ENABLE = yes
|
||||
OLED_DRIVER = SSD1306
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
|||
#endif
|
||||
|
||||
/* oled stuff :) */
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
uint16_t startup_timer = 0;
|
||||
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
|||
#endif
|
||||
|
||||
/* oled stuff :) */
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
uint16_t startup_timer = 0;
|
||||
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
|
|
|
|||
|
|
@ -23,4 +23,5 @@ AUDIO_ENABLE = no # Audio output
|
|||
|
||||
ENCODER_ENABLE = yes
|
||||
LTO_ENABLE = yes
|
||||
OLED_DRIVER_ENABLE = yes
|
||||
OLED_ENABLE = yes
|
||||
OLED_DRIVER = SSD1306
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ static void render_logo(void) {
|
|||
oled_write_P(qmk_logo, false);
|
||||
}
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
void oled_task_user(void) { render_logo(); }
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ static void render_logo(void) {
|
|||
oled_write_P(qmk_logo, false);
|
||||
}
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
void oled_task_user(void) { render_logo(); }
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -24,5 +24,6 @@ RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
|||
BLUETOOTH_ENABLE = no # Enable Bluetooth
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
BLUETOOTH = AdafruitBLE
|
||||
OLED_DRIVER_ENABLE = yes
|
||||
OLED_ENABLE = yes
|
||||
OLED_DRIVER = SSD1306
|
||||
ENCODER_ENABLE = yes
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: htt
|
|||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
AUDIO_ENABLE = no
|
||||
RGBLIGHT_ENABLE = yes
|
||||
OLED_DRIVER_ENABLE = no
|
||||
OLED_ENABLE = no
|
||||
|
||||
DEFAULT_FOLDER = 8pack/rev12
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
)
|
||||
};
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
|
||||
void render_layer_state(void) {
|
||||
oled_write_ln(PSTR("LAYER"), false);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
)
|
||||
};
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
|
||||
void render_layer_state(void) {
|
||||
oled_write_ln(PSTR("LAYER"), false);
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
VIA_ENABLE = yes
|
||||
OLED_ENABLE = yes
|
||||
# OLED_DRIVER = not a real thing
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// Tested and verified working on ext65rev2
|
||||
void matrix_io_delay(void) { __asm__ volatile("nop\nnop\nnop\n"); }
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
void board_init(void) {
|
||||
SYSCFG->CFGR1 |= SYSCFG_CFGR1_I2C1_DMA_RMP;
|
||||
SYSCFG->CFGR1 &= ~(SYSCFG_CFGR1_SPI2_DMA_RMP);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
#define OLED_DISPLAY_128X64
|
||||
#define OLED_TIMEOUT 400000
|
||||
#endif
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue