From 8c030db96cd7844807be8f8e0d84c38e942a8217 Mon Sep 17 00:00:00 2001 From: Bernardo Farah Date: Tue, 26 May 2020 09:58:35 -0700 Subject: [PATCH] lily58: Update to use OLED driver Pursuant https://github.com/qmk/qmk_firmware/pull/6260 Update to take advantage of refactor (and OLED driver). Next up: - Figure out custom logo - Work on OLED configuration --- lily58/config.h | 3 --- lily58/keymap.c | 68 ++++++++++++++++--------------------------------- lily58/rules.mk | 4 +-- 3 files changed, 24 insertions(+), 51 deletions(-) diff --git a/lily58/config.h b/lily58/config.h index dfafaee..37148c1 100644 --- a/lily58/config.h +++ b/lily58/config.h @@ -27,9 +27,6 @@ along with this program. If not, see . #define MASTER_RIGHT // #define EE_HANDS -// OLED -#define SSD1306OLED - // Underglow #undef RGBLED_NUM #define RGBLIGHT_ANIMATIONS diff --git a/lily58/keymap.c b/lily58/keymap.c index b6189fb..eb2ab5f 100644 --- a/lily58/keymap.c +++ b/lily58/keymap.c @@ -4,9 +4,6 @@ #include "lufa.h" #include "split_util.h" #endif -#ifdef SSD1306OLED - #include "ssd1306.h" -#endif #include "keymap_alias.h" @@ -16,8 +13,6 @@ extern rgblight_config_t rgblight_config; #endif -extern uint8_t is_master; - enum keyboard_layers { _QWERTY = 0, // default layer _WIN, // windows layer @@ -156,21 +151,19 @@ void matrix_init_user(void) { #ifdef RGBLIGHT_ENABLE RGB_current_mode = rgblight_config.mode; #endif - //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h - #ifdef SSD1306OLED - iota_gfx_init(!has_usb()); // turns on the display - #endif } -//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h -#ifdef SSD1306OLED +#ifdef OLED_DRIVER_ENABLE -/* oled_rotation_t oled_init_user(oled_rotation_t rotation) { */ -/* if (is_master) { */ -/* return OLED_ROTATION_270; */ -/* } */ -/* return OLED_ROTATION_180; */ -/* } */ +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + /* if (is_keyboard_master()) { */ + /* return OLED_ROTATION_270; */ + /* } */ + /* return OLED_ROTATION_180; */ + if (!is_keyboard_master()) + return OLED_ROTATION_180; + return rotation; +} #define L_QWERTY 0 #define L_WIN 2 @@ -228,10 +221,6 @@ const char *read_keylogs(void); // void set_timelog(void); // const char *read_timelog(void); -void matrix_scan_user(void) { - iota_gfx_task(); -} - char rotary_message[24]; const char *read_rotary(void) { switch(CURRENT_ROTARY_MODE) { @@ -257,35 +246,22 @@ const char *read_rotary(void) { return rotary_message; } -void matrix_render_user(struct CharacterMatrix *matrix) { - if (is_master) { +void oled_task_user(void) { + if (is_keyboard_master()) { // If you want to change the display of OLED, you need to change here - matrix_write_ln(matrix, read_custom_layer_state()); - matrix_write_ln(matrix, read_keylog()); - matrix_write_ln(matrix, read_rotary()); - // matrix_write_ln(matrix, read_keylogs()); - // matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui)); - // matrix_write_ln(matrix, read_host_led_state()); - // matrix_write_ln(matrix, read_timelog()); + oled_write_ln(read_custom_layer_state(), false); + oled_write_ln(read_keylog(), false); + oled_write_ln(read_rotary(), false); + // oled_write_ln(read_keylogs(), false); + // oled_write_ln(read_mode_icon(keymap_config.swap_lalt_lgui), false); + // oled_write_ln(read_host_led_state(), false); + // oled_write_ln(read_timelog(), false); } else { - matrix_write(matrix, read_logo()); + oled_write(read_logo(), false); } } -void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { - if (memcmp(dest->display, source->display, sizeof(dest->display))) { - memcpy(dest->display, source->display, sizeof(dest->display)); - dest->dirty = true; - } -} - -void iota_gfx_task_user(void) { - struct CharacterMatrix matrix; - matrix_clear(&matrix); - matrix_render_user(&matrix); - matrix_update(&display, &matrix); -} -#endif//SSD1306OLED +#endif // OLED Driver #ifdef ENCODER_ENABLE void encoder_update_user(uint8_t index, bool clockwise) { @@ -340,7 +316,7 @@ void encoder_update_user(uint8_t index, bool clockwise) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { -#ifdef SSD1306OLED +#ifdef OLED_DRIVER_ENABLE set_keylog(keycode, record); #endif // set_timelog(); diff --git a/lily58/rules.mk b/lily58/rules.mk index 0636faa..881edaa 100644 --- a/lily58/rules.mk +++ b/lily58/rules.mk @@ -15,14 +15,14 @@ UNICODE_ENABLE = no # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. SWAP_HANDS_ENABLE = no # Enable one-hand typing +OLED_DRIVER_ENABLE = yes # OLED display # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend ENCODER_ENABLE = yes # If you want to change the display of OLED, you need to change here -SRC += ./lib/glcdfont.c \ - ./lib/rgb_state_reader.c \ +SRC += ./lib/rgb_state_reader.c \ ./lib/layer_state_reader.c \ ./lib/logo_reader.c \ ./lib/keylogger.c \