diff options
| author | Joel Challis <git@zvecr.com> | 2024-02-16 13:25:44 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-16 13:25:44 +0000 |
| commit | 78a74ca9748b12c27fcddef576a2a9f7f8a9eb38 (patch) | |
| tree | 13f73755150379bc824424610740411f6fc76b30 /keyboards/nullbitsco | |
| parent | b8646bc40bd616167da150f6da4eda372f7de23d (diff) | |
[Keymap Removal] keyboard with most keymaps (#23092)
Diffstat (limited to 'keyboards/nullbitsco')
| -rw-r--r-- | keyboards/nullbitsco/snap/keymaps/typehud/config.h | 46 | ||||
| -rw-r--r-- | keyboards/nullbitsco/snap/keymaps/typehud/keymap.c | 157 | ||||
| -rw-r--r-- | keyboards/nullbitsco/snap/keymaps/typehud/readme.md | 51 | ||||
| -rw-r--r-- | keyboards/nullbitsco/snap/keymaps/typehud/rules.mk | 6 | ||||
| -rw-r--r-- | keyboards/nullbitsco/snap/keymaps/typehud/typehud.c | 349 | ||||
| -rw-r--r-- | keyboards/nullbitsco/snap/keymaps/typehud/typehud.h | 87 |
6 files changed, 0 insertions, 696 deletions
diff --git a/keyboards/nullbitsco/snap/keymaps/typehud/config.h b/keyboards/nullbitsco/snap/keymaps/typehud/config.h deleted file mode 100644 index 62c11709a2..0000000000 --- a/keyboards/nullbitsco/snap/keymaps/typehud/config.h +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | /* Copyright 2022 Chris Tanaka <https://github.com/christanaka> | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | /* space savers */ | ||
| 20 | #define DYNAMIC_KEYMAP_LAYER_COUNT 3 | ||
| 21 | #define NO_ACTION_TAPPING | ||
| 22 | #define NO_ACTION_ONESHOT | ||
| 23 | #define TAPPING_FORCE_HOLD | ||
| 24 | |||
| 25 | // Old configuration | ||
| 26 | #define OLED_BRIGHTNESS 128 | ||
| 27 | #define OLED_TIMEOUT 30000 | ||
| 28 | #define OLED_UPDATE_INTERVAL 200 | ||
| 29 | |||
| 30 | // Selectively undefine to save space | ||
| 31 | // VIA support won't fit otherwise | ||
| 32 | #ifdef RGBLIGHT_ENABLE | ||
| 33 | #undef RGBLIGHT_EFFECT_TWINKLE | ||
| 34 | #endif //RGB LIGHT_ENABLE | ||
| 35 | |||
| 36 | // Split configuration | ||
| 37 | #define SPLIT_TRANSPORT_MIRROR | ||
| 38 | #define SPLIT_WPM_ENABLE | ||
| 39 | |||
| 40 | // Typehud configuration | ||
| 41 | #define TYPEHUD_FILLGRAPH | ||
| 42 | #define TYPEHUD_MATRIX_COLS 16 | ||
| 43 | // #define TYPEHUD_MASTER | ||
| 44 | // #define TYPEHUD_MATRIX_ROTATE_90 | ||
| 45 | // #define TYPEHUD_MATRIX_ROTATE_180 | ||
| 46 | // #define TYPEHUD_MATRIX_ROTATE_270 | ||
diff --git a/keyboards/nullbitsco/snap/keymaps/typehud/keymap.c b/keyboards/nullbitsco/snap/keymaps/typehud/keymap.c deleted file mode 100644 index 231c9d8545..0000000000 --- a/keyboards/nullbitsco/snap/keymaps/typehud/keymap.c +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 1 | /* Copyright 2022 Chris Tanaka <https://github.com/christanaka> | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include QMK_KEYBOARD_H | ||
| 18 | #include "typehud.h" | ||
| 19 | |||
| 20 | // clang-format off | ||
| 21 | enum layers { | ||
| 22 | _BASE, | ||
| 23 | _VIA1, | ||
| 24 | _VIA2 | ||
| 25 | }; | ||
| 26 | |||
| 27 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 28 | [_BASE] = LAYOUT_all( | ||
| 29 | KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_PAUS, | ||
| 30 | KC_F13, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL, KC_HOME, | ||
| 31 | KC_F14, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END, | ||
| 32 | KC_F15, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, | ||
| 33 | KC_F16, KC_LSFT, KC_NUHS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, | ||
| 34 | KC_F17, KC_LCTL, KC_LGUI, KC_LALT, MO(_VIA1), KC_SPC, KC_SPC, MO(_VIA1), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT | ||
| 35 | ), | ||
| 36 | [_VIA1] = LAYOUT_all( | ||
| 37 | QK_BOOT,KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 38 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 39 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 40 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 41 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 42 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO | ||
| 43 | ), | ||
| 44 | [_VIA2] = LAYOUT_all( | ||
| 45 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 46 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 47 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 48 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 49 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, | ||
| 50 | KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO | ||
| 51 | ) | ||
| 52 | }; | ||
| 53 | // clang-format on | ||
| 54 | |||
| 55 | #if defined(ENCODER_MAP_ENABLE) | ||
| 56 | const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { | ||
| 57 | [_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_MPRV, KC_MNXT) }, | ||
| 58 | [_VIA1] = { ENCODER_CCW_CW(KC_NO, KC_NO), ENCODER_CCW_CW(KC_NO, KC_NO) }, | ||
| 59 | [_VIA2] = { ENCODER_CCW_CW(KC_NO, KC_NO), ENCODER_CCW_CW(KC_NO, KC_NO) } | ||
| 60 | }; | ||
| 61 | #endif | ||
| 62 | |||
| 63 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | ||
| 64 | oled_clear(); | ||
| 65 | |||
| 66 | #ifdef TYPEHUD_MASTER | ||
| 67 | if (is_keyboard_master()) { | ||
| 68 | #else | ||
| 69 | if (!is_keyboard_master()) { | ||
| 70 | #endif | ||
| 71 | typehud_init(); | ||
| 72 | } | ||
| 73 | |||
| 74 | if (is_keyboard_left()) | ||
| 75 | return OLED_ROTATION_0; | ||
| 76 | else | ||
| 77 | return OLED_ROTATION_180; | ||
| 78 | } | ||
| 79 | |||
| 80 | static void render_status(void) { | ||
| 81 | oled_set_cursor(0, 0); | ||
| 82 | oled_write_P(PSTR("SNAP75 "), false); | ||
| 83 | oled_write_P(PSTR("Layer "), false); | ||
| 84 | switch (get_highest_layer(layer_state)) { | ||
| 85 | case _VIA1: | ||
| 86 | oled_write_P(PSTR("FN1 "), false); | ||
| 87 | break; | ||
| 88 | case _VIA2: | ||
| 89 | oled_write_P(PSTR("FN2 "), false); | ||
| 90 | break; | ||
| 91 | default: // use BASE case as default | ||
| 92 | oled_write_P(PSTR("Base"), false); | ||
| 93 | } | ||
| 94 | |||
| 95 | // Host Keyboard LED Status | ||
| 96 | oled_set_cursor(0, 1); | ||
| 97 | static led_t persistent_led_state = {0}; | ||
| 98 | led_t led_state = host_keyboard_led_state(); | ||
| 99 | |||
| 100 | // Only update if the LED state has changed | ||
| 101 | // Otherwise, the OLED will not turn off if an LED is on. | ||
| 102 | if (persistent_led_state.raw != led_state.raw) { | ||
| 103 | persistent_led_state = led_state; | ||
| 104 | |||
| 105 | oled_write_ln_P(PSTR(" "), false); | ||
| 106 | |||
| 107 | if (led_state.caps_lock) { | ||
| 108 | oled_set_cursor(0, 1); | ||
| 109 | oled_write_P(PSTR("CAPS"), false); | ||
| 110 | } | ||
| 111 | |||
| 112 | if (led_state.num_lock) { | ||
| 113 | oled_set_cursor(5, 1); | ||
| 114 | oled_write_P(PSTR("NUM"), true); | ||
| 115 | } | ||
| 116 | |||
| 117 | if (led_state.scroll_lock) { | ||
| 118 | oled_set_cursor(9, 1); | ||
| 119 | oled_write_P(PSTR("SCR"), false); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | // WPM and max WPM | ||
| 124 | oled_set_cursor(0, 2); | ||
| 125 | oled_write_P(PSTR("WPM "), false); | ||
| 126 | uint8_t current_wpm = get_current_wpm(); | ||
| 127 | oled_write(get_u8_str(current_wpm, '0'), true); | ||
| 128 | |||
| 129 | oled_set_cursor(8, 2); | ||
| 130 | oled_write_P(PSTR("MAX "), false); | ||
| 131 | static uint8_t max_wpm; | ||
| 132 | max_wpm = MAX(max_wpm, current_wpm); | ||
| 133 | oled_write(get_u8_str(max_wpm, '0'), true); | ||
| 134 | } | ||
| 135 | |||
| 136 | bool oled_task_user(void) { | ||
| 137 | #ifdef TYPEHUD_MASTER | ||
| 138 | if (is_keyboard_master()) { | ||
| 139 | #else | ||
| 140 | if (!is_keyboard_master()) { | ||
| 141 | #endif | ||
| 142 | typehud_render(); | ||
| 143 | } else { | ||
| 144 | render_status(); | ||
| 145 | } | ||
| 146 | |||
| 147 | return true; | ||
| 148 | } | ||
| 149 | |||
| 150 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 151 | typehud_process_record(record); | ||
| 152 | return true; | ||
| 153 | } | ||
| 154 | |||
| 155 | bool should_process_keypress(void) { | ||
| 156 | return true; | ||
| 157 | } | ||
diff --git a/keyboards/nullbitsco/snap/keymaps/typehud/readme.md b/keyboards/nullbitsco/snap/keymaps/typehud/readme.md deleted file mode 100644 index d5f50f310c..0000000000 --- a/keyboards/nullbitsco/snap/keymaps/typehud/readme.md +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | # Typehud Keymap | ||
| 2 | |||
| 3 | VIA compatible keymap that displays a live wpm HUD on your OLED. | ||
| 4 | |||
| 5 | <https://nullbits.co/static/file/snap-typehud.webp> | ||
| 6 | |||
| 7 | ## Configuration | ||
| 8 | |||
| 9 | Configuration options (other than the keymap itself) can be found in `typehud/config.h`. | ||
| 10 | |||
| 11 | ### Graph Type | ||
| 12 | |||
| 13 | By default the graph is filled. For a non-filled graph remove or comment out the following line: | ||
| 14 | |||
| 15 | ```c | ||
| 16 | #define TYPEHUD_FILLGRAPH | ||
| 17 | ``` | ||
| 18 | |||
| 19 | ### Keyboard Matrix Orientation | ||
| 20 | |||
| 21 | To change the keyboard matrix orientation add one of the following: | ||
| 22 | |||
| 23 | - `TYPEHUD_MATRIX_ROTATE_90` | ||
| 24 | - `TYPEHUD_MATRIX_ROTATE_180` | ||
| 25 | - `TYPEHUD_MATRIX_ROTATE_270` | ||
| 26 | |||
| 27 | ### Keyboard Matrix Key Overrides | ||
| 28 | |||
| 29 | If the number of physical keys doesn't match the keyboard matrix rows/columns you can override it: | ||
| 30 | |||
| 31 | ```c | ||
| 32 | #define TYPEHUD_MATRIX_ROWS 6 | ||
| 33 | #define TYPEHUD_MATRIX_COLS 16 | ||
| 34 | ``` | ||
| 35 | |||
| 36 | In addition if the position of the physical keys doesn't match the matrix you can override it. Negative numbers will shift the keys left/up and positive numbers will shift the keys right/down: | ||
| 37 | |||
| 38 | ```c | ||
| 39 | #define TYPEHUD_MATRIX_ROW_SHIFT -1 | ||
| 40 | #define TYPEHUD_MATRIX_COL_SHIFT -2 | ||
| 41 | ``` | ||
| 42 | |||
| 43 | ### Split Keyboard Side | ||
| 44 | |||
| 45 | For split keyboards, the keymap assumes it will be rendered to the slave side. | ||
| 46 | |||
| 47 | To render to master instead, add the following configuration line: | ||
| 48 | |||
| 49 | ```c | ||
| 50 | #define TYPEHUD_MASTER | ||
| 51 | ``` | ||
diff --git a/keyboards/nullbitsco/snap/keymaps/typehud/rules.mk b/keyboards/nullbitsco/snap/keymaps/typehud/rules.mk deleted file mode 100644 index 16bd6085c0..0000000000 --- a/keyboards/nullbitsco/snap/keymaps/typehud/rules.mk +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | OLED_ENABLE = yes | ||
| 2 | WPM_ENABLE = yes | ||
| 3 | VIA_ENABLE = yes | ||
| 4 | ENCODER_MAP_ENABLE = yes | ||
| 5 | |||
| 6 | SRC += typehud.c | ||
diff --git a/keyboards/nullbitsco/snap/keymaps/typehud/typehud.c b/keyboards/nullbitsco/snap/keymaps/typehud/typehud.c deleted file mode 100644 index ad884f843b..0000000000 --- a/keyboards/nullbitsco/snap/keymaps/typehud/typehud.c +++ /dev/null | |||
| @@ -1,349 +0,0 @@ | |||
| 1 | /* Copyright 2023 Jay Greco | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "typehud.h" | ||
| 18 | |||
| 19 | static bool is_initialized; | ||
| 20 | static uint16_t timer; | ||
| 21 | static int8_t bar_height; | ||
| 22 | static uint8_t wpm_arr[_GRAPH_WIDTH]; | ||
| 23 | static uint8_t point_arr[_GRAPH_WIDTH]; | ||
| 24 | |||
| 25 | |||
| 26 | static void | ||
| 27 | render_graph(uint8_t wpm), | ||
| 28 | render_caret(void), | ||
| 29 | render_axis(void), | ||
| 30 | render_bar(void), | ||
| 31 | render_init(void); | ||
| 32 | |||
| 33 | /* | ||
| 34 | * Renders the wpm counter. | ||
| 35 | */ | ||
| 36 | static void render_wpm(uint8_t wpm) { | ||
| 37 | oled_set_cursor(0, 0); | ||
| 38 | oled_write("WPM", false); | ||
| 39 | oled_set_cursor(0, 1); | ||
| 40 | oled_write(get_u8_str(wpm, '0'), false); | ||
| 41 | } | ||
| 42 | |||
| 43 | /* | ||
| 44 | * Renders the keyboard matrix. | ||
| 45 | */ | ||
| 46 | static void render_matrix(keyrecord_t *record) { | ||
| 47 | uint8_t x = _MATRIX_X; | ||
| 48 | uint8_t y = _MATRIX_Y; | ||
| 49 | uint8_t width = _MATRIX_WIDTH; | ||
| 50 | uint8_t height = _MATRIX_HEIGHT; | ||
| 51 | #ifdef SPLIT_KEYBOARD | ||
| 52 | uint8_t rows = _NML_MATRIX_ROWS; | ||
| 53 | uint8_t cols = _NML_MATRIX_COLS; | ||
| 54 | #endif | ||
| 55 | |||
| 56 | // On initial render draw the matrix outline | ||
| 57 | if (!is_initialized) { | ||
| 58 | for (uint8_t i = 1; i <= width - 2; i++) { | ||
| 59 | oled_write_pixel(x + i, y, true); | ||
| 60 | oled_write_pixel(x + i, y + height - 1, true); | ||
| 61 | } | ||
| 62 | for (uint8_t j = 1; j <= height - 2; j++) { | ||
| 63 | oled_write_pixel(x, y + j, true); | ||
| 64 | oled_write_pixel(x + width - 1, y + j, true); | ||
| 65 | } | ||
| 66 | return; | ||
| 67 | } | ||
| 68 | |||
| 69 | // Determine position based on matrix rotation | ||
| 70 | // For split keyboards the keys on the right half get appended as additional rows and | ||
| 71 | // have their columns reset at 0 | ||
| 72 | #ifdef SPLIT_KEYBOARD | ||
| 73 | uint8_t row = (record->event.key.row % rows); | ||
| 74 | uint8_t col = record->event.key.col; | ||
| 75 | if (record->event.key.row >= rows) { | ||
| 76 | col += (cols / 2); | ||
| 77 | } | ||
| 78 | #else | ||
| 79 | uint8_t row = record->event.key.row; | ||
| 80 | uint8_t col = record->event.key.col; | ||
| 81 | #endif | ||
| 82 | |||
| 83 | #ifdef TYPEHUD_MATRIX_ROW_SHIFT | ||
| 84 | row += TYPEHUD_MATRIX_ROW_SHIFT; | ||
| 85 | #endif | ||
| 86 | #ifdef TYPEHUD_MATRIX_COL_SHIFT | ||
| 87 | col += TYPEHUD_MATRIX_COL_SHIFT; | ||
| 88 | #endif | ||
| 89 | |||
| 90 | // Scale position to key size | ||
| 91 | uint8_t size = _MATRIX_SIZE; | ||
| 92 | row *= size; | ||
| 93 | col *= size; | ||
| 94 | |||
| 95 | // Render key in matrix | ||
| 96 | for (int i = 0; i < size; i++) { | ||
| 97 | for (int j = 0; j < size; j++) { | ||
| 98 | #if defined(TYPEHUD_MATRIX_ROTATE_90) | ||
| 99 | uint8_t key_x = x + width - 1 - size - row; | ||
| 100 | uint8_t key_y = y + 1 + col; | ||
| 101 | #elif defined(TYPEHUD_MATRIX_ROTATE_180) | ||
| 102 | uint8_t key_x = x + width - 1 - size - col; | ||
| 103 | uint8_t key_y = y + height - 1 - size - row; | ||
| 104 | #elif defined(TYPEHUD_MATRIX_ROTATE_270) | ||
| 105 | uint8_t key_x = x + 1 + row; | ||
| 106 | uint8_t key_y = y + height - 1 - size - col; | ||
| 107 | #else | ||
| 108 | uint8_t key_x = x + 1 + col; | ||
| 109 | uint8_t key_y = y + 1 + row; | ||
| 110 | #endif | ||
| 111 | oled_write_pixel(key_x + i, key_y + j, record->event.pressed); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | /* | ||
| 117 | * Renders the graph. | ||
| 118 | */ | ||
| 119 | static void render_graph(uint8_t wpm) { | ||
| 120 | uint8_t x = _GRAPH_X; | ||
| 121 | uint8_t y = _GRAPH_Y + _GRAPH_HEIGHT; | ||
| 122 | uint8_t width = _GRAPH_WIDTH; | ||
| 123 | uint8_t height = _GRAPH_HEIGHT; | ||
| 124 | |||
| 125 | // Handle intial graph render | ||
| 126 | if (!is_initialized) { | ||
| 127 | for (uint8_t i = 0; i < width; i++) { | ||
| 128 | oled_write_pixel(x + i, y, true); | ||
| 129 | } | ||
| 130 | return; | ||
| 131 | } | ||
| 132 | |||
| 133 | uint8_t i = 0; | ||
| 134 | |||
| 135 | // Shift all graph points except last to the left and re-render | ||
| 136 | for (; i < width - 1; i++) { | ||
| 137 | int8_t point_delta = point_arr[i + 1] - point_arr[i]; | ||
| 138 | |||
| 139 | #ifdef TYPEHUD_FILLGRAPH | ||
| 140 | if (point_delta < 0) { | ||
| 141 | #else | ||
| 142 | if (point_delta != 0) { | ||
| 143 | #endif | ||
| 144 | oled_write_pixel(x + i, y - point_arr[i], false); | ||
| 145 | } | ||
| 146 | |||
| 147 | wpm_arr[i] = wpm_arr[i + 1]; | ||
| 148 | point_arr[i] = point_arr[i + 1]; | ||
| 149 | |||
| 150 | if (point_delta != 0) { | ||
| 151 | oled_write_pixel(x + i, y - point_arr[i], true); | ||
| 152 | } | ||
| 153 | } | ||
| 154 | |||
| 155 | // Clear last graph point | ||
| 156 | if (wpm > wpm_arr[i] && point_arr[i] + 1 <= height) { | ||
| 157 | #ifndef TYPEHUD_FILLGRAPH | ||
| 158 | oled_write_pixel(x + i, y - point_arr[i], false); | ||
| 159 | #endif | ||
| 160 | point_arr[i] = point_arr[i] + 1; | ||
| 161 | } else if ((wpm < wpm_arr[i] && point_arr[i] - 1 >= 0) || (wpm <= 0 && point_arr[i] > 0)) { | ||
| 162 | oled_write_pixel(x + i, y - point_arr[i], false); | ||
| 163 | point_arr[i] = point_arr[i] - 1; | ||
| 164 | } | ||
| 165 | |||
| 166 | // Render last graph point | ||
| 167 | wpm_arr[i] = wpm; | ||
| 168 | |||
| 169 | if (point_arr[i] != point_arr[i - 1]) { | ||
| 170 | oled_write_pixel(x + i, y - point_arr[i], true); | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | /* | ||
| 175 | * Renders the caret. | ||
| 176 | */ | ||
| 177 | static void render_caret(void) { | ||
| 178 | uint8_t x = _GRAPH_X + _GRAPH_WIDTH + _GRAPH_RPAD + _CARET_WIDTH; | ||
| 179 | uint8_t y = 0; | ||
| 180 | uint8_t width = _CARET_WIDTH; | ||
| 181 | uint8_t height = _CARET_HEIGHT; | ||
| 182 | uint8_t g_width = _GRAPH_WIDTH; | ||
| 183 | uint8_t g_height = _GRAPH_HEIGHT; | ||
| 184 | |||
| 185 | // Handle initial caret render | ||
| 186 | if (!is_initialized) { | ||
| 187 | y = g_height - point_arr[g_width - 1]; | ||
| 188 | |||
| 189 | for (uint8_t i = 0; i < width; i++) { | ||
| 190 | for (uint8_t j = i; j < height - i; j++) { | ||
| 191 | oled_write_pixel(x - i, y - j, true); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | return; | ||
| 195 | } | ||
| 196 | |||
| 197 | // Handle caret updates and re-render | ||
| 198 | int8_t point_delta = point_arr[g_width - 1] - point_arr[g_width - 2]; | ||
| 199 | if (point_delta > 0) { | ||
| 200 | y = g_height - point_arr[g_width - 2]; | ||
| 201 | if (y - height + 1 > 0) { | ||
| 202 | for (uint8_t i = 0; i < width; i++) { | ||
| 203 | oled_write_pixel(x - i, y - i, false); | ||
| 204 | oled_write_pixel(x - i, y - height + i, true); | ||
| 205 | } | ||
| 206 | } | ||
| 207 | } else if (point_delta < 0) { | ||
| 208 | y = g_height - point_arr[g_width - 1]; | ||
| 209 | if (y - height + 1 > 0) { | ||
| 210 | for (uint8_t i = 0; i < width; i++) { | ||
| 211 | oled_write_pixel(x - i, y - height + i, false); | ||
| 212 | oled_write_pixel(x - i, y - i, true); | ||
| 213 | } | ||
| 214 | } | ||
| 215 | } | ||
| 216 | } | ||
| 217 | |||
| 218 | /* | ||
| 219 | * Renders the axis. | ||
| 220 | */ | ||
| 221 | static void render_axis(void) { | ||
| 222 | uint8_t x = _AXIS_X; | ||
| 223 | uint8_t y = _AXIS_HEIGHT; | ||
| 224 | uint8_t width = _AXIS_WIDTH; | ||
| 225 | uint8_t height = _AXIS_HEIGHT; | ||
| 226 | uint8_t tick_width = _AXIS_TICK_WIDTH; | ||
| 227 | uint8_t subtick_width = _AXIS_SUBTICK_WIDTH; | ||
| 228 | uint8_t interval = _AXIS_INTERVAL; | ||
| 229 | uint8_t tick_interval = _AXIS_TICK_INTERVAL; | ||
| 230 | |||
| 231 | for (uint8_t j = 0; j <= height; j += interval) { | ||
| 232 | uint8_t curr_tick_width = 0; | ||
| 233 | |||
| 234 | // Determine tick width and draw extra point if at interval | ||
| 235 | if (j % tick_interval == 0) { | ||
| 236 | curr_tick_width = tick_width; | ||
| 237 | oled_write_pixel(x, y - j, true); | ||
| 238 | } else { | ||
| 239 | curr_tick_width = subtick_width; | ||
| 240 | } | ||
| 241 | |||
| 242 | // Draw tick | ||
| 243 | for (uint8_t i = 0; i < curr_tick_width; i++) { | ||
| 244 | oled_write_pixel(x + width - i, y - j, true); | ||
| 245 | } | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | /* | ||
| 250 | * Renders the input bar. | ||
| 251 | */ | ||
| 252 | static void render_bar(void) { | ||
| 253 | uint8_t x = _BAR_X; | ||
| 254 | uint8_t width = _BAR_WIDTH; | ||
| 255 | uint8_t height = _BAR_HEIGHT; | ||
| 256 | |||
| 257 | // Increment bar height | ||
| 258 | bar_height = (bar_height + 1) % height; | ||
| 259 | |||
| 260 | // When bar resets back to 0, clear bar pixels | ||
| 261 | if (bar_height % height == 0) { | ||
| 262 | for (uint8_t i = 0; i < width; i++) { | ||
| 263 | for (uint8_t j = 0; j < height; j++) { | ||
| 264 | oled_write_pixel(x + i, j, false); | ||
| 265 | } | ||
| 266 | } | ||
| 267 | } | ||
| 268 | |||
| 269 | // Draw new bar pixels | ||
| 270 | for (uint8_t i = 0; i < width; i++) { | ||
| 271 | oled_write_pixel(x + i, height - bar_height, true); | ||
| 272 | } | ||
| 273 | } | ||
| 274 | |||
| 275 | /* | ||
| 276 | * Renders the initial frame for all components. | ||
| 277 | */ | ||
| 278 | static void render_init(void) { | ||
| 279 | render_graph(0); | ||
| 280 | render_caret(); | ||
| 281 | render_matrix(NULL); | ||
| 282 | render_axis(); | ||
| 283 | } | ||
| 284 | |||
| 285 | /* | ||
| 286 | * Initializes and resets the typehud. | ||
| 287 | */ | ||
| 288 | void typehud_init(void) { | ||
| 289 | // Reset variables | ||
| 290 | is_initialized = false; | ||
| 291 | timer = 0; | ||
| 292 | bar_height = -1; | ||
| 293 | |||
| 294 | for (uint8_t i = 0; i < _GRAPH_WIDTH; i++) { | ||
| 295 | wpm_arr[i] = 0; | ||
| 296 | point_arr[i] = 0; | ||
| 297 | } | ||
| 298 | |||
| 299 | // Draw the initial graph | ||
| 300 | for (uint8_t i = 0; i < _GRAPH_WIDTH; i++) { | ||
| 301 | oled_write_pixel(_GRAPH_X + i, _GRAPH_HEIGHT, true); | ||
| 302 | } | ||
| 303 | } | ||
| 304 | |||
| 305 | /* | ||
| 306 | * Renders the typehud. | ||
| 307 | */ | ||
| 308 | void typehud_render(void) { | ||
| 309 | uint8_t wpm = get_current_wpm(); | ||
| 310 | |||
| 311 | // Run initial rendering once | ||
| 312 | if (!is_initialized) { | ||
| 313 | render_init(); | ||
| 314 | is_initialized = true; | ||
| 315 | } | ||
| 316 | |||
| 317 | // Render wpm | ||
| 318 | render_wpm(wpm); | ||
| 319 | |||
| 320 | // Render next graph and caret frame when timer reaches refresh rate | ||
| 321 | if (timer_elapsed(timer) > _GRAPH_REFRESH) { | ||
| 322 | render_graph(wpm); | ||
| 323 | render_caret(); | ||
| 324 | timer = timer_read(); | ||
| 325 | } | ||
| 326 | } | ||
| 327 | |||
| 328 | /* | ||
| 329 | * Handles keypresses for the typehud. | ||
| 330 | */ | ||
| 331 | void typehud_process_record(keyrecord_t *record) { | ||
| 332 | // For split keyboards, only draw on correct side | ||
| 333 | #ifdef SPLIT_KEYBOARD | ||
| 334 | # ifdef TYPEHUD_MASTER | ||
| 335 | if (!is_keyboard_master()) { | ||
| 336 | # else | ||
| 337 | if (is_keyboard_master()) { | ||
| 338 | # endif | ||
| 339 | return; | ||
| 340 | } | ||
| 341 | #endif | ||
| 342 | // Render/update matrix | ||
| 343 | render_matrix(record); | ||
| 344 | |||
| 345 | // Render/update input bar on keypress | ||
| 346 | if (record->event.pressed) { | ||
| 347 | render_bar(); | ||
| 348 | } | ||
| 349 | } | ||
diff --git a/keyboards/nullbitsco/snap/keymaps/typehud/typehud.h b/keyboards/nullbitsco/snap/keymaps/typehud/typehud.h deleted file mode 100644 index c3ed876c42..0000000000 --- a/keyboards/nullbitsco/snap/keymaps/typehud/typehud.h +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | /* Copyright 2022 Chris Tanaka <https://github.com/christanaka> | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include QMK_KEYBOARD_H | ||
| 18 | |||
| 19 | // clang-format off | ||
| 20 | #define _OLED_WIDTH (OLED_DISPLAY_WIDTH - 1) | ||
| 21 | #define _OLED_HEIGHT (OLED_DISPLAY_HEIGHT - 1) | ||
| 22 | |||
| 23 | #ifdef SPLIT_KEYBOARD | ||
| 24 | #define _PHYSICAL_PARTS 2 | ||
| 25 | #else | ||
| 26 | #define _PHYSICAL_PARTS 1 | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #ifdef TYPEHUD_MATRIX_ROWS | ||
| 30 | #define _NML_MATRIX_ROWS TYPEHUD_MATRIX_ROWS | ||
| 31 | #else | ||
| 32 | # ifdef SPLIT_KEYBOARD | ||
| 33 | #define _NML_MATRIX_ROWS (MATRIX_ROWS / 2) | ||
| 34 | # else | ||
| 35 | #define _NML_MATRIX_ROWS MATRIX_ROWS | ||
| 36 | # endif | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #ifdef TYPEHUD_MATRIX_COLS | ||
| 40 | #define _NML_MATRIX_COLS TYPEHUD_MATRIX_COLS | ||
| 41 | #else | ||
| 42 | #define _NML_MATRIX_COLS (MATRIX_COLS * _PHYSICAL_PARTS) | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #define _MATRIX_SIZE 2 | ||
| 46 | #if defined(TYPEHUD_MATRIX_ROTATE_90) || defined(TYPEHUD_MATRIX_ROTATE_270) | ||
| 47 | #define _MATRIX_WIDTH (_NML_MATRIX_ROWS * _MATRIX_SIZE + 2) | ||
| 48 | #define _MATRIX_HEIGHT (_NML_MATRIX_COLS * _MATRIX_SIZE + 2) | ||
| 49 | #else | ||
| 50 | #define _MATRIX_WIDTH (_NML_MATRIX_COLS * _MATRIX_SIZE + 2) | ||
| 51 | #define _MATRIX_HEIGHT (_NML_MATRIX_ROWS * _MATRIX_SIZE + 2) | ||
| 52 | #endif | ||
| 53 | #define _MATRIX_X 0 | ||
| 54 | #define _MATRIX_Y (_OLED_HEIGHT - _MATRIX_HEIGHT + 1) | ||
| 55 | #define _MATRIX_RPAD 2 | ||
| 56 | #define _MATRIX_PAD_WIDTH (_MATRIX_WIDTH + _MATRIX_RPAD) | ||
| 57 | |||
| 58 | #define _BAR_WIDTH 3 | ||
| 59 | #define _BAR_HEIGHT _OLED_HEIGHT | ||
| 60 | #define _BAR_X (_OLED_WIDTH - _BAR_WIDTH) | ||
| 61 | |||
| 62 | #define _AXIS_WIDTH 5 | ||
| 63 | #define _AXIS_HEIGHT _OLED_HEIGHT | ||
| 64 | #define _AXIS_TICK_WIDTH 3 | ||
| 65 | #define _AXIS_SUBTICK_WIDTH 2 | ||
| 66 | #define _AXIS_INTERVAL 3 | ||
| 67 | #define _AXIS_TICK_INTERVAL 15 | ||
| 68 | #define _AXIS_RPAD 2 | ||
| 69 | #define _AXIS_PAD_WIDTH (_AXIS_WIDTH + _AXIS_RPAD) | ||
| 70 | #define _AXIS_X (_OLED_WIDTH - _BAR_WIDTH - _AXIS_PAD_WIDTH) | ||
| 71 | |||
| 72 | #define _CARET_WIDTH 3 | ||
| 73 | #define _CARET_HEIGHT 5 | ||
| 74 | |||
| 75 | #define _GRAPH_RPAD 2 | ||
| 76 | #define _GRAPH_MAX_WIDTH (_OLED_WIDTH - _BAR_WIDTH - _AXIS_PAD_WIDTH - _CARET_WIDTH - _GRAPH_RPAD - _MATRIX_PAD_WIDTH) | ||
| 77 | #define _GRAPH_WIDTH (_GRAPH_MAX_WIDTH - 4) | ||
| 78 | #define _GRAPH_HEIGHT 31 | ||
| 79 | #define _GRAPH_REFRESH 300 | ||
| 80 | #define _GRAPH_X (_MATRIX_WIDTH + _MATRIX_RPAD) | ||
| 81 | #define _GRAPH_Y 0 | ||
| 82 | // clang-format on | ||
| 83 | |||
| 84 | void | ||
| 85 | typehud_init(void), | ||
| 86 | typehud_render(void), | ||
| 87 | typehud_process_record(keyrecord_t *record); | ||
