From 5eb500a877d367d6b93f733db6068c3791b663b7 Mon Sep 17 00:00:00 2001 From: john-ezra <47311764+john-ezra@users.noreply.github.com> Date: Sat, 11 Sep 2021 07:31:24 -0700 Subject: [Keymap] Add john-ezra Kyria Keymap (#14338) Co-authored-by: Drashna Jaelre Co-authored-by: Ryan --- keyboards/splitkb/kyria/keymaps/john-ezra/config.h | 43 +++++ keyboards/splitkb/kyria/keymaps/john-ezra/keymap.c | 213 +++++++++++++++++++++ keyboards/splitkb/kyria/keymaps/john-ezra/oled.c | 143 ++++++++++++++ keyboards/splitkb/kyria/keymaps/john-ezra/rules.mk | 11 ++ 4 files changed, 410 insertions(+) create mode 100644 keyboards/splitkb/kyria/keymaps/john-ezra/config.h create mode 100644 keyboards/splitkb/kyria/keymaps/john-ezra/keymap.c create mode 100644 keyboards/splitkb/kyria/keymaps/john-ezra/oled.c create mode 100644 keyboards/splitkb/kyria/keymaps/john-ezra/rules.mk (limited to 'keyboards') diff --git a/keyboards/splitkb/kyria/keymaps/john-ezra/config.h b/keyboards/splitkb/kyria/keymaps/john-ezra/config.h new file mode 100644 index 0000000000..3602b560c1 --- /dev/null +++ b/keyboards/splitkb/kyria/keymaps/john-ezra/config.h @@ -0,0 +1,43 @@ +/* Copyright 2021 John Ezra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#ifdef OLED_DRIVER_ENABLE + #define OLED_DISPLAY_128X64 +#endif + +#ifdef RGBLIGHT_ENABLE +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_SNAKE +#define RGBLIGHT_EFFECT_KNIGHT +#define RGBLIGHT_EFFECT_CHRISTMAS +#define RGBLIGHT_EFFECT_STATIC_GRADIENT +#define RGBLIGHT_EFFECT_RGB_TEST +#define RGBLIGHT_EFFECT_ALTERNATING +#define RGBLIGHT_EFFECT_TWINKLE + #define RGBLIGHT_HUE_STEP 8 + #define RGBLIGHT_SAT_STEP 8 + #define RGBLIGHT_VAL_STEP 8 + #define RGBLIGHT_LIMIT_VAL 150 +#endif + +#undef DEBOUNCE +#define DEBOUNCE 1 + +#define SPLIT_WPM_ENABLE diff --git a/keyboards/splitkb/kyria/keymaps/john-ezra/keymap.c b/keyboards/splitkb/kyria/keymaps/john-ezra/keymap.c new file mode 100644 index 0000000000..3664fdfacf --- /dev/null +++ b/keyboards/splitkb/kyria/keymaps/john-ezra/keymap.c @@ -0,0 +1,213 @@ +/* Copyright 2021 John Ezra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include QMK_KEYBOARD_H + +enum kyria_layers { + _HNTS, + _QWERTY, + _LOWER, + _RAISE, + _ADJUST +}; + +enum kyria_keycodes { + HNTS = SAFE_RANGE, + QWERTY, + LOWER, + RAISE, + CPY_PST, + UNDO +}; + +#define BSP_CMD MT(MOD_LGUI, KC_BSPC) +#define SFT_ENT MT(MOD_LSFT, KC_ENT) +#define UNDO G(KC_Z) +#define FIND G(KC_F) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* + * Default: HNTS + * + * ,-----------------------------------------------. ,-----------------------------------------------. + * | ` | Z | R | L | D | W | | Y | P | U | X | Q | | \ | + * |-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------| + * | Esc | H | N | T | S | C | | B | I | E | O | A | Esc | + * |-------+-------+-------+-------+-------+-------+---------------. ,---------------+-------+-------+-------+-------+-------+-------| + * |Cpy/Pst| K | V | M | F | G | Ctrl | Alt | | Caps | Del | J | ; : | , < | . > | / ? | ' " | + * `-------+-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-----------------------' + * | Up | Down | Lower | Space | BSPC | | Tab | Shift | Raise | Left | Right | + * `---------------------------------------' `---------------------------------------' + */ + +[_HNTS] = LAYOUT( + FIND, KC_Z, KC_R, KC_L, KC_D, KC_W, KC_Y, KC_P, KC_U, KC_X, KC_Q, KC_BSLS, + CPY_PST, KC_H, KC_N, KC_T, KC_S, KC_C, KC_B, KC_I, KC_E, KC_O, KC_A, KC_ESC, + UNDO, KC_K, KC_V, KC_M, KC_F, KC_G, KC_LCTL, KC_LALT, KC_CAPS, KC_DEL, KC_J, KC_SCLN, KC_COMM, KC_DOT, KC_SLSH, KC_QUOT, + KC_UP, KC_DOWN, LOWER, KC_SPC, BSP_CMD, KC_TAB, SFT_ENT, RAISE, KC_LEFT, KC_RGHT +), + +/* + * Default: QWERTY + * + * ,-----------------------------------------------. ,-----------------------------------------------. + * | ` | Q | W | E | R | T | | Y | U | I | O | P | | \ | + * |-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------| + * | Esc | A | S | D | F | G | | H | J | K | L | ; | ' " | + * |-------+-------+-------+-------+-------+-------+---------------. ,---------------+-------+-------+-------+-------+-------+-------| + * |Cpy/Pst| Z | X | C | V | B | Ctrl | Alt | | Caps | Del | N | M | , < | . > | / ? |Cpy/Pst| + * `-------+-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-----------------------' + * | Up | Down | Lower | Space | BSPC | | Tab | Shift | Raise | Left | Right | + * `---------------------------------------' `---------------------------------------' + */ + +[_QWERTY] = LAYOUT( + KC_GRV, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + CPY_PST, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LCTL, KC_LALT, KC_CAPS, KC_DEL, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, CPY_PST, + KC_UP, KC_DOWN, LOWER, KC_SPC, BSP_CMD, KC_TAB, SFT_ENT, RAISE, KC_LEFT, KC_RGHT +), + +/* + * Lower: Symbols + * + * ,-----------------------------------------------. ,-----------------------------------------------. + * | | ! | @ | { | } | | | | | | | | | | \ | + * |-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------| + * | | # | $ | ( | ) | ` ~ | | + | - | * | / | = | | + * |-------+-------+-------+-------+-------+-------+---------------. ,---------------+-------+-------+-------+-------+-------+-------| + * | | % | ^ | [ | ] | & | | | | | | | | | | | | + * `-------+-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-----------------------' + * | | | | | | | | | | | | + * `---------------------------------------' `---------------------------------------' + */ + +[_LOWER] = LAYOUT( + KC_GRV, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, _______, _______, _______, _______, _______, _______, + KC_TILD, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_BSLS, KC_PLUS, KC_MINS, KC_ASTR, KC_SLSH, KC_EQL, _______, + KC_AMPR, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_UNDS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +), + +/* + * Raise: Numbers & Media + * + * ,-----------------------------------------------. ,-----------------------------------------------. + * | | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | + * |-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------| + * | | Prev | Play | Next | VolUp | Mute | |Bright+| Left | Down | Up | Right | | + * |-------+-------+-------+-------+-------+-------+---------------. ,---------------+-------+-------+-------+-------+-------+-------| + * | | | | | VolDn | | | | | | |Bright-| | | | | | + * `-------+-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-----------------------' + * | | | | | | | | | | | | + * `---------------------------------------' `---------------------------------------' + */ + +[_RAISE] = LAYOUT( + _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, + _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, + KC_VOLD, KC_VOLU, KC_MPRV, KC_MPLY, KC_MNXT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +), + + /* + * Adjust: Function Keys & RGB + * + * ,-----------------------------------------------. ,-----------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | | + * |-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------| + * | | TOG | SAI | HUI | VAI | MOD | | | | | F11 | F12 | NKRO | + * |-------+-------+-------+-------+-------+-------+---------------. ,---------------+-------+-------+-------+-------+-------+-------| + * | | | SAD | HUD | VAD | RMOD | | | | | | | | | | | | + * `-------+-------+-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-----------------------' + * | | | | | | | | | | | | + * `---------------------------------------' `---------------------------------------' + */ + +[_ADJUST] = LAYOUT( + _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, NK_TOGG, + _______, RGB_TOG, RGB_SAI, RGB_HUI, RGB_VAI, RGB_MOD, KC_BRIU, _______, _______, KC_F11, KC_F12, CG_TOGG, + _______, _______, RGB_SAD, RGB_HUD, RGB_VAD,RGB_RMOD,_______, _______, _______, _______, KC_BRID, _______, _______, _______, QWERTY, HNTS, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +), +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case HNTS: //Layer Control + if (record->event.pressed) { + set_single_persistent_default_layer(_HNTS); + } + return false; + break; + case QWERTY: + if (record->event.pressed) { + set_single_persistent_default_layer(_QWERTY); + } + return false; + break; + case LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case CPY_PST: // One key copy/paste + { + static uint16_t copy_paste_timer; + if (record->event.pressed) { + copy_paste_timer = timer_read(); + } else { + if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy + register_mods(mod_config(MOD_LGUI)); + tap_code(KC_C); + unregister_mods(mod_config(MOD_LGUI)); + } else { // Tap, paste + register_mods(mod_config(MOD_LGUI)); + tap_code(KC_V); + unregister_mods(mod_config(MOD_LGUI)); + } + } + } + break; + case UNDO: // Undo Redo + if ((get_mods() & MOD_BIT(KC_LGUI)) == MOD_BIT(KC_LGUI)) { + if (record->event.pressed) { + register_code(KC_Y); + } else { + unregister_code(KC_Y); + } + return false; + } + return true; + } + return true; +}; diff --git a/keyboards/splitkb/kyria/keymaps/john-ezra/oled.c b/keyboards/splitkb/kyria/keymaps/john-ezra/oled.c new file mode 100644 index 0000000000..d98cd598bc --- /dev/null +++ b/keyboards/splitkb/kyria/keymaps/john-ezra/oled.c @@ -0,0 +1,143 @@ +/* Copyright 2021 John Ezra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +//Sets up what the OLED screens display. + +#include QMK_KEYBOARD_H + +int timer = 0; +char wpm_counter[5]; +int x = 31; +int currwpm = 0; +int vert_count = 0; + +//============= USER CONFIG PARAMS =============== +float max_wpm = 150.0f; //WPM value at the top of the graph window +int graph_refresh_interval = 80; //in milliseconds +int graph_area_fill_interval = 3; //determines how dense the horizontal lines under the graph line are; lower = more dense +int vert_interval = 3; //determines frequency of vertical lines under the graph line +bool vert_line = false; //determines whether to draw vertical lines +int graph_line_thickness = 2; //determines thickness of graph line in pixels +//============= END USER PARAMS =============== + +#ifdef OLED_ENABLE +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + return OLED_ROTATION_180; +} + +static void render_qmk_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); +} + +void render_bootmagic_status(void) { + oled_write_P((keymap_config.swap_lctl_lgui) ? PSTR("OS: Windows\n\n") : PSTR("OS: MacOS\n\n"), false); + oled_write_P((keymap_config.nkro) ? PSTR("NKRO ") : PSTR(" "), false); +} + +void render_wpm(void) { + //get current WPM value + currwpm = get_current_wpm(); + //check if it's been long enough before refreshing graph + if(timer_elapsed(timer) > graph_refresh_interval){ + // main calculation to plot graph line + x = 64 - ((currwpm / max_wpm) * 64); + //first draw actual value line + for(int i = 0; i <= graph_line_thickness - 1; i++){ + oled_write_pixel(1, x + i, true); + } + //then fill in area below the value line + if(vert_line){ + if(vert_count == vert_interval){ + vert_count = 0; + while(x <= 64){ + oled_write_pixel(1, x, true); + x++; + } + } else { + for(int i = 64; i > x; i--){ + if(i % graph_area_fill_interval == 0){ + oled_write_pixel(1, i, true); + } + } + vert_count++; + } + } else { + for(int i = 64; i > x; i--){ + if(i % graph_area_fill_interval == 0){ + oled_write_pixel(1, i, true); + } + } + } + //then move the entire graph one pixel to the right + oled_pan(false); + //refresh the timer for the next iteration + timer = timer_read(); + } + //format current WPM value into a printable string + char buf[4]; + oled_set_cursor(14, 0); + oled_write("WPM:", false); + buf[0] = currwpm >= 100 ? ((currwpm/100) + '0') : ' '; + buf[1] = currwpm >= 10 ? (((currwpm/10) % 10) + '0') : ' '; + buf[2] = (currwpm % 10) + '0'; + buf[3] = 0; + oled_write(buf, false); +} + +static void render_status(void) { + // QMK Logo and version information + render_qmk_logo(); + oled_write_P(PSTR("Kyria: Rev1.0\n"), false); + + // Host Keyboard Layer Status + oled_write_P(PSTR("Layer: "), false); + switch (get_highest_layer(layer_state)) { + case 0: + oled_write_P(PSTR("Default\n"), false); + break; + case 2: + oled_write_P(PSTR("Lower\n"), false); + break; + case 3: + oled_write_P(PSTR("Raise\n"), false); + break; + case 4: + oled_write_P(PSTR("Adjust\n"), false); + break; + default: + oled_write_P(PSTR("Undefined\n"), false); + } + + render_bootmagic_status(); + +// Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + oled_write_P(led_state.caps_lock ? PSTR("CAPLCK ") : PSTR(" "), false); +} + +void oled_task_user(void) { + if (is_keyboard_master()) { + render_status(); + } else { + render_wpm(); + } +} +#endif diff --git a/keyboards/splitkb/kyria/keymaps/john-ezra/rules.mk b/keyboards/splitkb/kyria/keymaps/john-ezra/rules.mk new file mode 100644 index 0000000000..7fca028d22 --- /dev/null +++ b/keyboards/splitkb/kyria/keymaps/john-ezra/rules.mk @@ -0,0 +1,11 @@ +OLED_ENABLE = yes # Enables the use of OLED displays +OLED_DRIVER = SSD1306 +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +NKRO_ENABLE = yes # Enable N-Key Rollover +ENCODER_ENABLE = no # Disable Rotary Encoder +SPACE_CADET_ENABLE = no # Disable Space Cadet Shift +GRAVE_ESC_ENABLE = no # Disable Grave Escape +MOUSEKEY_ENABLE = no # Disable Mousekeys +WPM_ENABLE = yes # Enable WPM Counter (Works with default wpm files, but works better with vectorstorm updated wpm.c and wpm.h -> https://github.com/vectorstorm/qmk_firmware/tree/wpm_exact) + +SRC += oled.c -- cgit v1.2.3