mirror of
https://github.com/qmk/qmk_firmware
synced 2025-01-03 13:40:36 +00:00
[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:
@ -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
|
||||
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
|
||||
SRC += oled_driver.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
|
||||
|
@ -70,7 +70,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
)
|
||||
|
||||
};
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
|
||||
static void render_logo(void) {
|
||||
static const char PROGMEM qmk_logo[] = {
|
||||
|
@ -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_128X32
|
||||
#define OLED_TIMEOUT 400000
|
||||
#endif
|
||||
|
@ -73,7 +73,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
)
|
||||
|
||||
};
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
|
||||
static void render_logo(void) {
|
||||
static const char PROGMEM qmk_logo[] = {
|
||||
|
@ -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
|
||||
|
@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
|
||||
static void render_logo(void) {
|
||||
static const char PROGMEM qmk_logo[] = {
|
||||
|
@ -20,7 +20,8 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
OLED_DRIVER_ENABLE = yes # Enable Support for SSD1306 or SH1106 OLED Displays; Communicating over I2C
|
||||
OLED_ENABLE = yes
|
||||
OLED_DRIVER = SSD1306 # Enable Support for SSD1306 or SH1106 OLED Displays; Communicating over I2C
|
||||
ENCODER_ENABLE = yes
|
||||
SPLIT_KEYBOARD = yes
|
||||
LTO_ENABLE = yes
|
||||
|
@ -64,7 +64,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# define RGBLIGHT_LIMIT_VAL 255
|
||||
#endif
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
# define OLED_DISPLAY_128X64
|
||||
# define OLED_TIMEOUT 60000
|
||||
# define OLED_FONT_H "keyboards/anavi/macropad8/glcdfont.c"
|
||||
|
@ -17,7 +17,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
)
|
||||
};
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
)
|
||||
};
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
)
|
||||
};
|
||||
|
||||
#ifdef OLED_DRIVER_ENABLE
|
||||
#ifdef OLED_ENABLE
|
||||
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user