1
0
Fork 0

[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:
Xelus22 2021-08-24 16:28:26 +10:00 committed by GitHub
parent 6fd20acf4b
commit 4e1c5887c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
500 changed files with 1579 additions and 1387 deletions

View file

@ -24,7 +24,7 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += tap_dances.c
endif
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
ifeq ($(strip $(OLED_ENABLE)), yes)
SRC += oled.c
endif

View file

@ -140,7 +140,7 @@
# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_REST_MODE
#endif // RGB_MATRIX_ENABLE
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
# ifdef SPLIT_KEYBOARD
# define OLED_UPDATE_INTERVAL 60
# else

View file

@ -114,8 +114,9 @@ void shutdown_user(void) {
}
__attribute__((weak)) void suspend_power_down_keymap(void) {}
void suspend_power_down_user(void) {
#ifdef OLED_DRIVER_ENABLE
void suspend_power_down_user(void) {
#ifdef OLED_ENABLE
oled_off();
#endif
suspend_power_down_keymap();

View file

@ -29,7 +29,7 @@
#if defined(RGB_MATRIX_ENABLE)
# include "rgb_matrix_stuff.h"
#endif
#if defined(OLED_DRIVER_ENABLE)
#if defined(OLED_ENABLE)
# include "oled_stuff.h"
#endif
#if defined(PIMORONI_TRACKBALL_ENABLE)

View file

@ -70,7 +70,7 @@ void add_keylog(uint16_t keycode) {
bool process_record_user_oled(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
oled_timer = timer_read32();
add_keylog(keycode);
#endif

View file

@ -29,7 +29,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re
#ifdef KEYLOGGER_ENABLE
uprintf("KL: kc: 0x%04X, col: %2u, row: %2u, pressed: %b, time: %5u, int: %b, count: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed, record->event.time, record->tap.interrupted, record->tap.count);
#endif // KEYLOGGER_ENABLE
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
process_record_user_oled(keycode, record);
#endif // OLED

View file

@ -64,7 +64,7 @@ ifeq ($(strip $(PROTOCOL)), VUSB)
endif
CUSTOM_OLED_DRIVER ?= yes
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
ifeq ($(strip $(OLED_ENABLE)), yes)
ifeq ($(strip $(CUSTOM_OLED_DRIVER)), yes)
SRC += oled_stuff.c
OPT_DEFS += -DCUSTOM_OLED_DRIVER_CODE

View file

@ -71,6 +71,10 @@ void keyboard_post_init_transport_sync(void) {
void user_transport_update(void) {
if (is_keyboard_master()) {
# ifdef OLED_ENABLE
user_state.oled_on = is_oled_on();
# endif
transport_keymap_config = keymap_config.raw;
transport_userspace_config = userspace_config.raw;
#ifdef AUDIO_ENABLE
@ -85,6 +89,13 @@ void user_transport_update(void) {
#endif
} else {
# ifdef OLED_ENABLE
if (user_state.oled_on) {
oled_on();
} else {
oled_off();
}
# endif
keymap_config.raw = transport_keymap_config;
userspace_config.raw = transport_userspace_config;
#ifdef UNICODE_ENABLE

View file

@ -2,7 +2,7 @@
#include <stdio.h>
#include "ninjonas.h"
#if defined(OLED_DRIVER_ENABLE) & !defined(KEYBOARD_kyria_rev1)
#if defined(OLED_ENABLE) & !defined(KEYBOARD_kyria_rev1)
static uint32_t oled_timer = 0;
@ -49,16 +49,16 @@ void render_layer_state(void) {
bool adjust = layer_state_is(_ADJUST);
bool numpad = layer_state_is(_NUMPAD);
if(lower){
oled_write_P(PSTR(" Lower "), true);
} else if(raise){
oled_write_P(PSTR(" Raise "), true);
} else if(adjust){
oled_write_P(PSTR(" Adjust "), true);
if(lower){
oled_write_P(PSTR(" Lower "), true);
} else if(raise){
oled_write_P(PSTR(" Raise "), true);
} else if(adjust){
oled_write_P(PSTR(" Adjust "), true);
} else if(numpad) {
oled_write_P(PSTR(" Numpad "), true);
} else {
oled_write_P(PSTR(" Default"), false);
oled_write_P(PSTR(" Numpad "), true);
} else {
oled_write_P(PSTR(" Default"), false);
}
}

View file

@ -6,7 +6,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true;
__attribute__((weak))
bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; }
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
__attribute__((weak))
bool process_record_oled(uint16_t keycode, keyrecord_t *record) { return true; }
#endif
@ -110,7 +110,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
return process_record_keymap(keycode, record) && process_record_secrets(keycode, record)
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
&& process_record_oled(keycode, record)
#endif
; // Close return

View file

@ -25,6 +25,6 @@ enum custom_keycodes {
bool process_record_secrets(uint16_t keycode, keyrecord_t *record);
bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
bool process_record_oled(uint16_t keycode, keyrecord_t *record);
#endif

View file

@ -173,7 +173,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
};
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
static char receive_buffer[128] = {};
static uint8_t receive_buffer_length = 0;
@ -227,4 +227,4 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
#endif
#endif
#endif

View file

@ -58,7 +58,7 @@ void keyboard_post_init_user(void)
__attribute__((weak)) void suspend_power_down_keymap(void) {}
void suspend_power_down_user(void) {
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
oled_off();
#endif
suspend_power_down_keymap();

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
# include QMK_KEYBOARD_H
# include "quantum.h"
@ -138,4 +138,4 @@ void oled_task_user(void) {
}
}
#endif // OLED_DRIVER_ENABLE
#endif // OLED_ENABLE

View file

@ -18,7 +18,7 @@
#pragma once
#include "quantum.h"
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
# include "oled_driver.h"
# define OLED_RENDER_WPM_COUNTER " WPM: "
#endif
@ -27,4 +27,4 @@
#endif
#ifdef OCEAN_DREAM_ENABLE
# include "ocean_dream.h"
#endif
#endif

View file

@ -41,7 +41,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
```
4. In your `rules.mk` to make it easier to turn the animation on/off, add
```makefile
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
ifeq ($(strip $(OLED_ENABLE)), yes)
#... your code here...
ifdef OCEAN_DREAM_ENABLE
@ -59,7 +59,8 @@ endif
You're done! Now you can enable **Ocean Dream** by simply turning on the OLED feature
```makefile
OLED_DRIVER_ENABLE = yes
OLED_ENABLE = yes
OLED_DRIVER = SSD1306
```
And if you want to disable it without turning off the OLED Driver you can simply set

View file

@ -1,6 +1,6 @@
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
ifeq ($(strip $(OLED_ENABLE)), yes)
SRC += oled_setup.c
ifdef OCEAN_DREAM_ENABLE

View file

@ -35,7 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#if defined(RGB_MATRIX_ENABLE)
//# include "rgb_matrix_stuff.h"
//#endif
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
# include "oled_setup.h"
#endif

View file

@ -11,7 +11,8 @@ ifeq ($(strip $(KEYBOARD)), crkbd/rev1)
RGB_MATRIX_ENABLE = yes
EXTRAFLAGS += -flto
BOOTLOADER = qmk-dfu
OLED_DRIVER_ENABLE = yes
OLED_ENABLE = yes
OLED_DRIVER = SSD1306
endif
ifeq ($(strip $(KEYBOARD)), lazydesigners/dimple)

View file

@ -172,10 +172,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#endif
if (record->event.pressed) {
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
oled_timer = timer_read();
oled_on();
#endif // OLED_DRIVER_ENABLE
#endif // OLED_ENABLE
switch (keycode) {
case KC_BBB:
if (record->event.pressed) {
@ -193,7 +193,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
#ifdef KEYBOARD_crkbd_rev1
#ifdef OLED_DRIVER_ENABLE
#ifdef OLED_ENABLE
void render_logo(void) {
static const char PROGMEM logo[] = {
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,

View file

@ -27,6 +27,6 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
SRC += custom_rgb.c
endif
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
ifeq ($(strip $(OLED_ENABLE)), yes)
SRC += custom_oled.c
endif