From c67e30459390982f4f1b47f46c62322f1fe9ba87 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 31 Mar 2020 16:26:43 -0700 Subject: [Keymap] Drashna's Cleanup and RGB Divide (#8506) * Enable External EEPROM on Planck Rev6 * Update KC_MAKE macro to use qmk cli util * Disable additional gradients for rgb matrix * Update analog code for newer methods * Update ergodox layout * Disable Grave Escape * Cleanup OLED code a bit * Remove old unicode code * Seperate RGB Matrix code from RGB Light code in userspace * Massive overhaul an generalization of personal OLED code Now lets hope I NEVER get a keyboard using a 128x32 in a normal orientation. * Super tiny cleanup * Enable Diablo layer on kyria * clang format pass * Additional OLED cleanup --- keyboards/kyria/keymaps/drashna/config.h | 2 + keyboards/kyria/keymaps/drashna/keymap.c | 208 ++----------------------------- keyboards/kyria/keymaps/drashna/rules.mk | 2 + 3 files changed, 14 insertions(+), 198 deletions(-) (limited to 'keyboards/kyria/keymaps') diff --git a/keyboards/kyria/keymaps/drashna/config.h b/keyboards/kyria/keymaps/drashna/config.h index e566b16d5c..f93069ac00 100644 --- a/keyboards/kyria/keymaps/drashna/config.h +++ b/keyboards/kyria/keymaps/drashna/config.h @@ -37,3 +37,5 @@ // If you are using an Elite C rev3 on the slave side, uncomment the lines below: #define SPLIT_USB_DETECT #define SPLIT_USB_TIMEOUT 1000 + +#define KEYLOGGER_LENGTH 10 diff --git a/keyboards/kyria/keymaps/drashna/keymap.c b/keyboards/kyria/keymaps/drashna/keymap.c index 5604f1a692..5e97ca55ad 100644 --- a/keyboards/kyria/keymaps/drashna/keymap.c +++ b/keyboards/kyria/keymaps/drashna/keymap.c @@ -2,35 +2,6 @@ uint8_t is_master; -#ifdef OLED_DRIVER_ENABLE -# define KEYLOGGER_LENGTH 10 -static uint32_t oled_timer = 0; -static char keylog_str[KEYLOGGER_LENGTH + 1] = {"\n"}; -static uint16_t log_timer = 0; -// clang-format off -static const char PROGMEM code_to_name[0xFF] = { -// 0 1 2 3 4 5 6 7 8 9 A B c D E F - ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x - '3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x - ']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x - ' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx - 'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx -}; - -void add_keylog(uint16_t keycode); -#endif - #ifndef UNICODE_ENABLE # define UC(x) KC_NO #endif @@ -52,7 +23,7 @@ void add_keylog(uint16_t keycode); LAYOUT_wrapper( \ KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \ LALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(KC_QUOT), \ - OS_LSFT, CTL_T(K21), K22, K23, K24, K25, KC_NO, KC_NO, MEH(KC_MINS), KC_NO, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \ + OS_LSFT, CTL_T(K21), K22, K23, K24, K25, KC_NO, MEH(KC_MINS), TG(_DIABLO), KC_NO, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \ KC_MUTE, OS_LALT, KC_GRV, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI, UC(0x03A8), UC(0x2E2E) \ ) /* Re-pass though to allow templates to be used */ @@ -107,12 +78,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _____________CARPLAX_QFMLWY_L2_____________, _____________CARPLAX_QFMLWY_R2_____________, _____________CARPLAX_QFMLWY_L3_____________, _____________CARPLAX_QFMLWY_R3_____________ ), + [_MODS] = LAYOUT_wrapper( _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, KC_LSFT, ___________________BLANK___________________, _______, _______, _______, _______, ___________________BLANK___________________, KC_RSFT, _______, _______, KC_LALT, _______, _______, _______, _______, KC_RGUI, _______, _______ ), + [_DIABLO] = LAYOUT_wrapper( + KC_ESC, KC_S, KC_I, KC_F, KC_M, KC_T, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO, KC_NO, + KC_TAB, KC_1, KC_2, KC_3, KC_4, KC_G, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, + KC_LCTL, KC_D3_1, KC_D3_2, KC_D3_3, KC_D3_4, KC_Z, KC_J, KC_L, TG(_DIABLO), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, + KC_DIABLO_CLEAR, KC_J, KC_NO, SFT_T(KC_SPACE), ALT_T(KC_Q), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO + ), [_LOWER] = LAYOUT_wrapper( KC_F12, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_F11, _______, _________________LOWER_L2__________________, _________________LOWER_R2__________________, KC_PIPE, @@ -142,10 +120,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { -#ifdef OLED_DRIVER_ENABLE - oled_timer = timer_read32(); - add_keylog(keycode); -#endif #ifndef SPLIT_KEYBOARD if (keycode == RESET && !is_master) { return false; @@ -154,133 +128,16 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { } return true; } + void matrix_init_keymap(void) { is_master = (uint8_t)is_keyboard_master(); } #ifdef OLED_DRIVER_ENABLE oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_180; } -void add_keylog(uint16_t keycode) { - if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) { - keycode = keycode & 0xFF; - } else if (keycode > 0xFF) { - keycode = 0; - } - - for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) { - keylog_str[i] = keylog_str[i - 1]; - } - - if (keycode < (sizeof(code_to_name) / sizeof(char))) { - keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); - } - - log_timer = timer_read(); -} - -void update_log(void) { - if (timer_elapsed(log_timer) > 750) { - // add_keylog(0); - } -} - -void render_keylogger_status(void) { - oled_write_P(PSTR("Keylogger: "), false); - oled_write(keylog_str, false); -} - -void render_default_layer_state(void) { - oled_write_P(PSTR("Layout: "), false); - switch (get_highest_layer(default_layer_state)) { - case _QWERTY: oled_write_ln_P(PSTR("Qwerty"), false); break; - case _COLEMAK: oled_write_ln_P(PSTR("Colemak"), false); break; - case _DVORAK: oled_write_ln_P(PSTR("Dvorak"), false); break; - case _WORKMAN: oled_write_ln_P(PSTR("Workman"), false); break; - case _NORMAN: oled_write_ln_P(PSTR("Norman"), false); break; - case _MALTRON: oled_write_ln_P(PSTR("Maltron"), false); break; - case _EUCALYN: oled_write_ln_P(PSTR("Eucalyn"), false); break; - case _CARPLAX: oled_write_ln_P(PSTR("Carplax"), false); break; - } -} - -void render_layer_state(void) { - oled_write_ln_P(PSTR("Layer:"), false); - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("Lower"), layer_state_is(_LOWER)); - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("Raise"), layer_state_is(_RAISE)); - oled_write_P(PSTR(" "), false); - oled_write_ln_P(PSTR("Mods"), layer_state_is(_MODS)); -} - -void render_keylock_status(uint8_t led_usb_state) { - oled_write_P(PSTR("Lock: "), false); - oled_write_P(PSTR("NUML"), led_usb_state & (1 << USB_LED_NUM_LOCK)); - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("CAPS"), led_usb_state & (1 << USB_LED_CAPS_LOCK)); - oled_write_P(PSTR(" "), false); - oled_write_ln_P(PSTR("SCLK"), led_usb_state & (1 << USB_LED_SCROLL_LOCK)); -} - -void render_mod_status(uint8_t modifiers) { - oled_write_P(PSTR("Mods: "), false); - oled_write_P(PSTR("Sft"), (modifiers & MOD_MASK_SHIFT)); - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("Ctl"), (modifiers & MOD_MASK_CTRL)); - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("Alt"), (modifiers & MOD_MASK_ALT)); - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("GUI"), (modifiers & MOD_MASK_GUI)); -} - -void render_bootmagic_status(void) { - /* Show Ctrl-Gui Swap options */ - static const char PROGMEM logo[][2][3] = { - {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}, - {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, - }; - oled_write_P(PSTR("Boot "), false); - if (keymap_config.swap_lctl_lgui) { - oled_write_P(logo[1][0], false); - } else { - oled_write_P(logo[0][0], false); - } - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("NKRO"), keymap_config.nkro); - oled_write_P(PSTR(" "), false); - oled_write_ln_P(PSTR("GUI"), !keymap_config.no_gui); - oled_write_P(PSTR("Magic "), false); - if (keymap_config.swap_lctl_lgui) { - oled_write_P(logo[1][1], false); - } else { - oled_write_P(logo[0][1], false); - } - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("GRV"), keymap_config.swap_grave_esc); - oled_write_P(PSTR(" "), false); - oled_write_ln_P(PSTR("CAPS"), keymap_config.swap_control_capslock); -} - -void render_user_status(void) { - oled_write_P(PSTR("USER: "), false); - oled_write_P(PSTR("Anim"), userspace_config.rgb_matrix_idle_anim); - oled_write_P(PSTR(" "), false); - oled_write_P(PSTR("Layr"), userspace_config.rgb_layer_change); - oled_write_P(PSTR(" "), false); - oled_write_ln_P(PSTR("Nuke"), userspace_config.nuke_switch); -} - // clang-format off -void render_logo(void) { - static const char PROGMEM qmk_logo[] = { - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, - 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, - 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0}; - - oled_write_P(qmk_logo, false); -} # ifndef SPLIT_TRANSPORT_MIRROR -void render_kyria_logo(void) { +void oled_driver_render_logo(void) { static const char PROGMEM kyria_logo[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,128,192,224,240,112,120, 56, 60, 28, 30, 14, 14, 14, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 14, 14, 14, 30, 28, 60, 56,120,112,240,224,192,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,224,240,124, 62, 31, 15, 7, 3, 1,128,192,224,240,120, 56, 60, 28, 30, 14, 14, 7, 7,135,231,127, 31,255,255, 31,127,231,135, 7, 7, 14, 14, 30, 28, 60, 56,120,240,224,192,128, 1, 3, 7, 15, 31, 62,124,240,224,192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -294,51 +151,6 @@ void render_kyria_logo(void) { oled_write_raw_P(kyria_logo, sizeof(kyria_logo)); } # endif -// clang-format on - -void render_status_main(void) { - /* Show Keyboard Layout */ - render_default_layer_state(); - render_keylock_status(host_keyboard_leds()); - render_bootmagic_status(); - render_user_status(); - - render_keylogger_status(); -} - -void render_status_secondary(void) { - /* Show Keyboard Layout */ - render_logo(); - render_default_layer_state(); - render_layer_state(); - render_mod_status(get_mods() | get_oneshot_mods()); - - render_keylogger_status(); -} - -void oled_task_user(void) { - if (timer_elapsed32(oled_timer) > 30000) { - oled_off(); - return; - } -# ifndef SPLIT_KEYBOARD - else { - oled_on(); - } -# endif - - update_log(); - if (is_master) { - render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) - } else { -# ifdef SPLIT_TRANSPORT_MIRROR - render_status_secondary(); -# else - render_kyria_logo(); -# endif - } -} - #endif #ifdef ENCODER_ENABLE diff --git a/keyboards/kyria/keymaps/drashna/rules.mk b/keyboards/kyria/keymaps/drashna/rules.mk index e835340bbf..2486ecd5d5 100644 --- a/keyboards/kyria/keymaps/drashna/rules.mk +++ b/keyboards/kyria/keymaps/drashna/rules.mk @@ -20,3 +20,5 @@ HD44780_ENABLE = no # Enable support for HD44780 based LCDs BOOTLOADER = atmel-dfu SPLIT_TRANSPORT = mirror + +TAP_DANCE_ENABLE = yes -- cgit v1.2.3