aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordogspace <43654839+dogspace@users.noreply.github.com>2021-08-30 14:42:04 -0400
committerGitHub <noreply@github.com>2021-08-30 11:42:04 -0700
commit27aebba1b1eadedf2ce25efc081aef3bdbbaab7a (patch)
tree105f7e14a7063a1afb31b261f5b3b2baee61bc4e
parentc9283f4c1f073da0072638e78b3d5bf5619a89f4 (diff)
downloadqmk_firmware-27aebba1b1eadedf2ce25efc081aef3bdbbaab7a.tar.gz
qmk_firmware-27aebba1b1eadedf2ce25efc081aef3bdbbaab7a.zip
[Keymap] Add new snailmap keymap to nullbitsco/nibble keyboard (#14024)
Co-authored-by: Ryan <fauxpark@gmail.com>
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/snailmap/keymap.c542
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/snailmap/readme.md36
-rw-r--r--keyboards/nullbitsco/nibble/keymaps/snailmap/rules.mk5
3 files changed, 583 insertions, 0 deletions
diff --git a/keyboards/nullbitsco/nibble/keymaps/snailmap/keymap.c b/keyboards/nullbitsco/nibble/keymaps/snailmap/keymap.c
new file mode 100644
index 000000000..614394bb5
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/snailmap/keymap.c
@@ -0,0 +1,542 @@
1/* Copyright 2021 dogspace <https://github.com/dogspace>
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
19enum custom_keycodes {
20 KC_CUST = SAFE_RANGE,
21};
22
23enum layer_names {
24 _MA,
25 _L1,
26 _L2,
27 _L3
28};
29
30// NOTE: Default keymap layers were designed for ANSI split-space layout http://www.keyboard-layout-editor.com/#/gists/f28bd5ff4e62f69e89896df3a59671c6
31const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
32 [_MA] = LAYOUT_ansi(
33 KC_ESC, 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,
34 KC_MUTE, 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, LCTL(KC_F),
35 KC_CAPS, MO(_L2), 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_CALC,
36 TG(_L2), KC_LSFT, 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_WHOM,
37 MO(_L3), KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_L1), LCTL(KC_C), LCTL(KC_V), KC_LEFT, KC_DOWN, KC_RGHT
38 ),
39 [_L1] = LAYOUT_ansi(
40 KC_GRAVE, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
41 RGB_TOG, _______, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_UP, _______, _______, _______, _______, _______, _______,
42 _______, LCTL(KC_Z), KC_LCTL, KC_LSFT, _______, _______, _______, KC_HOME, KC_LEFT, KC_DOWN, KC_RIGHT, KC_END, _______, _______, _______,
43 _______, _______, _______, _______, _______, _______, _______, _______, KC_PGDN, _______, _______, LCTL(KC_SLSH), _______, _______, _______,
44 _______, _______, _______, _______, _______, _______, LCTL(KC_X), _______, _______, _______, _______
45 ),
46 [_L2] = LAYOUT_ansi(
47 KC_GRAVE, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
48 RGB_TOG, _______, _______, _______, _______, _______, _______, KC_PAST, KC_7, KC_8, KC_9, _______, _______, _______, _______, _______,
49 _______, _______, _______, _______, _______, _______, _______, KC_PPLS, KC_4, KC_5, KC_6, _______, _______, _______, _______,
50 _______, _______, _______, _______, _______, _______, _______, KC_PMNS, KC_1, KC_2, KC_3, _______, _______, _______, _______,
51 _______, _______, _______, _______, KC_0, KC_PSLS, _______, _______, _______, _______, _______
52 ),
53 [_L3] = LAYOUT_ansi(
54 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______,
55 RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
56 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
57 KC_SYSREQ, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
58 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
59 )
60};
61
62#ifdef OLED_DRIVER_ENABLE
63/*=========================================== OLED CONFIGURATION ===========================================*/
64bool oled_horizontal = true; // OLED rotation (true = horizontal, false = vertical)
65bool ansi_layout = true; // ANSI or ISO layout (true = ANSI, false = ISO)
66bool split_space = true; // Split spacebar (true = split spacebar, false = 6.25u or 7u spacebar)
67bool three_mods_left = true; // Left mods layout (true = 3x 1.25u keys, false = 2x 1.5u keys)
68bool three_mods_right = false; // Right mods layout (true = 3x 1u keys, false = 2x 1.5u keys)
69bool graph_direction = true; // Graph movement (true = right to left, false = left to right)
70float graph_top_wpm = 100.0; // Minimum WPM required to reach the top of the graph
71int graph_refresh = 1000; // In milliseconds, determines the graph-line frequency
72int icon_med_wpm = 50; // WPM required to display the medium snail
73int icon_fast_wpm = 72; // WPM required to display the fast snail
74// Layer names: Should be exactly 5 characters in length if vertical display, or 6 characters if horizontal
75#define MA_LAYER_NAME "QWERTY" // Layer _MA name
76#define L1_LAYER_NAME "ARROWS" // Layer _L1 name
77#define L2_LAYER_NAME "NUMPAD" // Layer _L2 name
78#define L3_LAYER_NAME "FUNCTN" // Layer _L3 name
79/*================================================================================================================*/
80bool first_loop = true;
81int timer = 0;
82int wpm_limit = 20;
83int max_wpm = -1;
84int wpm_icon = -1;
85int graph_lines[64];
86
87// Set OLED rotation
88oled_rotation_t oled_init_user(oled_rotation_t rotation) {
89 if (oled_horizontal) {
90 return OLED_ROTATION_180;
91 } else {
92 return OLED_ROTATION_90;
93 }
94}
95
96// Toggles pixel on/off, converts horizontal coordinates to vertical equivalent if necessary
97static void write_pixel(int x, int y, bool onoff) {
98 if (oled_horizontal) {
99 oled_write_pixel(x, y, onoff);
100 } else {
101 oled_write_pixel(y, 127 - x, onoff);
102 }
103}
104
105// Draw static background image to OLED (keyboard with no bottom row)
106static void render_background(void) {
107 if (oled_horizontal) {
108 static const char PROGMEM oled_keymap_horizontal[] = {
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
112 0x84, 0x80, 0x80, 0x80, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04,
113 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00,
114 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
115 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00,
116 0x80, 0x04, 0x04, 0x04, 0x04, 0x84, 0x84, 0x84, 0x84, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00,
117 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
120 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10,
121 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
122 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
123 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
124 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
128 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
129 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
130 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02,
131 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
132 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
138 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
141 };
142 oled_write_raw_P(oled_keymap_horizontal, sizeof(oled_keymap_horizontal));
143 } else {
144 static const char PROGMEM oled_keymap_vertical[] = {
145 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
146 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00,
148 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
150 0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
152 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
154 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
156 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00,
158 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
159 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
160 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
161 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
162 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
163 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00,
164 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
166 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
168 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
177 };
178 oled_write_raw_P(oled_keymap_vertical, sizeof(oled_keymap_vertical));
179 }
180}
181
182// Location of OLED keyboard's top left pixel, relative to the display
183static const int keymap_template[2] = {41, 0};
184// Location of key highlights top left pixels, relative to keymap_template {X, Y, Key length in px}
185static int keymap_coords[MATRIX_ROWS][MATRIX_COLS][3] = {
186 { {12, 15, 1}, {5, 0, 1}, {10, 0, 1}, {15, 0, 1}, {20, 0, 1}, {25, 0, 1}, {30, 0, 1}, {35, 0, 1}, {40, 0, 1}, {45, 0, 1}, {50, 0, 1}, {55, 0, 1}, {60, 0, 1}, {65, 0, 1}, {70, 0, 8}, {82, 0, 1} },
187 { {0, 5, 1}, {5, 5, 5}, {14, 5, 1}, {19, 5, 1}, {24, 5, 1}, {29, 5, 1}, {34, 5, 1}, {39, 5, 1}, {44, 5, 1}, {49, 5, 1}, {54, 5, 1}, {59, 5, 1}, {64, 5, 1}, {69, 5, 1}, {74, 5, 4}, {82, 5, 1} },
188 { {0, 10, 1}, {5, 10, 6}, {15, 10, 1}, {20, 10, 1}, {25, 10, 1}, {30, 10, 1}, {35, 10, 1}, {40, 10, 1}, {45, 10, 1}, {50, 10, 1}, {55, 10, 1}, {60, 10, 1}, {65, 10, 1}, {0, 0, 0}, {70, 10, 8}, {82, 10, 1} },
189 { {0, 15, 1}, {5, 15, 8}, {17, 15, 1}, {22, 15, 1}, {27, 15, 1}, {32, 15, 1}, {37, 15, 1}, {42, 15, 1}, {47, 15, 1}, {52, 15, 1}, {57, 15, 1}, {62, 15, 1}, {67, 15, 6}, {0, 0, 0}, {77, 15, 1}, {82, 15, 1} },
190 { {0, 20, 1}, {5, 20, 2}, {11, 20, 2}, {17, 20, 2}, {0, 0, 0}, {0, 0, 0}, {23, 20, 12}, {0, 0, 0}, {0, 0, 0}, {39, 20, 3}, {56, 20, 4}, {64, 20, 4}, {72, 20, 1}, {0, 0, 0}, {77, 20, 1}, {82, 20, 1} }
191};
192
193// Draw the bottom row of the keyboard (based on OLED config variables), update coordinates
194static void render_fn_row(void) {
195 // Update locations of spacebar and modifier key highlights
196 if ((split_space == false) && (three_mods_left == false)) {
197 keymap_coords[4][1][2] = 3;
198 keymap_coords[4][2][0] = 12;
199 keymap_coords[4][2][2] = 3;
200 keymap_coords[4][3][0] = 0;
201 keymap_coords[4][3][1] = 0;
202 keymap_coords[4][3][2] = 0;
203 keymap_coords[4][6][0] = 19;
204 keymap_coords[4][6][2] = 34;
205 } else if ((split_space == false) && (three_mods_left == true)) {
206 keymap_coords[4][6][2] = 30;
207 }
208 if ((split_space == false) && (three_mods_right == true)) {
209 keymap_coords[4][9][0] = 57;
210 keymap_coords[4][9][2] = 1;
211 keymap_coords[4][10][0] = 62;
212 keymap_coords[4][10][2] = 1;
213 keymap_coords[4][11][0] = 67;
214 keymap_coords[4][11][2] = 1;
215 }
216 // Draw modifiers
217 for (int i = 0; i < 16; i++) {
218 if (keymap_coords[4][i][2] != 0) {
219 for (int p = 0; p < keymap_coords[4][i][2]; p++) {
220 int x = keymap_template[0] + keymap_coords[4][i][0] + 2 + p;
221 write_pixel(x, 22, true);
222 }
223 }
224 }
225 // Draw second line for split spacebar
226 if (split_space == true) {
227 for (int i = 0; i < 6; i++) {
228 int x = keymap_template[0] + 46 + 2 + i;
229 write_pixel(x, 22, true);
230 }
231 }
232}
233
234// Update OLED keyboard with ISO layout, update coordinates
235static void render_iso(void) {
236 for (int i = 0; i < 6; i++) {
237 // Turn off ANSI enter
238 write_pixel(keymap_template[0] + 73 + i, keymap_template[1] + 12, false);
239 if (i < 4) {
240 // Turn off part of ANSI left shift
241 write_pixel(keymap_template[0] + 10 + i, keymap_template[1] + 17, false);
242 // Draw vertical line for ISO enter
243 write_pixel(keymap_template[0] + 79, keymap_template[1] + 8 + i, true);
244 }
245 }
246 // Update locations of shift and grave key highlights
247 keymap_coords[3][1][2] = 3;
248 keymap_coords[1][14][0] = 70;
249 keymap_coords[1][14][1] = 10;
250 keymap_coords[1][14][2] = 1;
251}
252
253// Toggles pixels surrounding key
254static void render_keymap(uint8_t key_row, uint8_t key_col, bool onoff) {
255 int length = keymap_coords[key_row][key_col][2] + 4;
256 int left = keymap_coords[key_row][key_col][0] + keymap_template[0];
257 int top = keymap_coords[key_row][key_col][1] + keymap_template[1];
258 int right = left + length - 1;
259 int bottom = top + 4;
260
261 // Special case 1 - Draw enter key on ISO layout, return
262 if ((ansi_layout == false) && (key_row == 2) && (key_col == 14)) {
263 for (int i = 0; i < 10; i++) {
264 write_pixel(keymap_template[0] + 81, keymap_template[1] + 5 + i, onoff);
265 if (i < 5) {
266 write_pixel(keymap_template[0] + 74, keymap_template[1] + 5 + i, onoff);
267 }
268 if (i < 6) {
269 write_pixel(keymap_template[0] + 75, keymap_template[1] + 9 + i, onoff);
270 }
271 if (i < 7) {
272 write_pixel(keymap_template[0] + 75 + i, keymap_template[1] + 5, onoff);
273 write_pixel(keymap_template[0] + 75 + i, keymap_template[1] + 14, onoff);
274 }
275 }
276 return;
277 }
278 // Draw top and bottom walls (horizontal for <length>px)
279 for (int x = 0; x < length; x++) {
280 write_pixel(left + x, top, onoff);
281 write_pixel(left + x, bottom, onoff);
282 }
283 // Draw left and right walls (vertical for 5px)
284 for (int y = 0; y < 5; y++) {
285 write_pixel(left, top + y, onoff);
286 write_pixel(right, top + y, onoff);
287 }
288 // Special case 2 - Draw right spacebar on split-space layout
289 if ((split_space == true) && (key_row == 4) && (key_col == 6)) {
290 int start = keymap_template[0] + 46;
291 int stop = keymap_template[0] + 55;
292 for (int x = start; x < stop; x++) {
293 write_pixel(x, top, onoff);
294 write_pixel(x, bottom, onoff);
295 }
296 for (int y = 0; y < 5; y++) {
297 write_pixel(start, top + y, onoff);
298 write_pixel(stop, top + y, onoff);
299 }
300 }
301}
302
303// Write active layer name
304static void render_layer_state(void) {
305 if (oled_horizontal) {
306 oled_set_cursor(0, 0);
307 } else {
308 oled_set_cursor(0, 15);
309 }
310 switch (get_highest_layer(layer_state)) {
311 case _MA:
312 oled_write_P(PSTR(MA_LAYER_NAME), false);
313 break;
314 case _L1:
315 oled_write_P(PSTR(L1_LAYER_NAME), false);
316 break;
317 case _L2:
318 oled_write_P(PSTR(L2_LAYER_NAME), false);
319 break;
320 case _L3:
321 oled_write_P(PSTR(L3_LAYER_NAME), false);
322 break;
323 default:
324 oled_write("ERROR", false);
325 break;
326 }
327}
328
329// Update WPM counters
330static void render_wpm_counters(int current_wpm) {
331 int cursorposition_cur = 2;
332 int cursorposition_max = 1;
333 if (oled_horizontal == false) {
334 cursorposition_cur = 13;
335 cursorposition_max = 14;
336 }
337
338 char wpm_counter[4];
339 wpm_counter[3] = '\0';
340 wpm_counter[2] = '0' + current_wpm % 10;
341 wpm_counter[1] = '0' + (current_wpm / 10) % 10;
342 wpm_counter[0] = '0' + (current_wpm / 100) % 10;
343 oled_set_cursor(0, cursorposition_cur);
344 oled_write(wpm_counter, false);
345
346 if (current_wpm > max_wpm) {
347 max_wpm = current_wpm;
348 wpm_limit = max_wpm + 20;
349 oled_set_cursor(0, cursorposition_max);
350 oled_write(wpm_counter, false);
351 }
352}
353
354// Update WPM snail icon
355static void render_wpm_icon(int current_wpm) {
356 // wpm_icon is used to prevent unnecessary redraw
357 if ((current_wpm < icon_med_wpm) && (wpm_icon != 0)) {
358 wpm_icon = 0;
359 } else if ((current_wpm >= icon_med_wpm) && (current_wpm < icon_fast_wpm) && (wpm_icon != 1)) {
360 wpm_icon = 1;
361 } else if ((current_wpm >= icon_fast_wpm) && (wpm_icon != 2)) {
362 wpm_icon = 2;
363 } else {
364 return;
365 }
366 static const char PROGMEM snails[][2][24] = {
367 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0xA0, 0x20, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x50, 0x88, 0x04, 0x00, 0x00},
368 {0x40, 0x60, 0x50, 0x4E, 0x51, 0x64, 0x4A, 0x51, 0x54, 0x49, 0x41, 0x62, 0x54, 0x49, 0x46, 0x41, 0x40, 0x30, 0x09, 0x04, 0x02, 0x01, 0x00, 0x00}},
369 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x04, 0x98, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00},
370 {0x60, 0x50, 0x54, 0x4A, 0x51, 0x64, 0x4A, 0x51, 0x55, 0x49, 0x41, 0x62, 0x54, 0x49, 0x46, 0x41, 0x21, 0x10, 0x0A, 0x08, 0x05, 0x02, 0x00, 0x00}},
371 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x10, 0x10, 0x10, 0x20, 0x40, 0x40, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00},
372 {0x60, 0x58, 0x54, 0x62, 0x49, 0x54, 0x52, 0x51, 0x55, 0x49, 0x62, 0x52, 0x4D, 0x45, 0x46, 0x22, 0x21, 0x11, 0x10, 0x0A, 0x08, 0x05, 0x02, 0x00}}
373 };
374 if (oled_horizontal) {
375 oled_set_cursor(3, 1);
376 oled_write_raw_P(snails[wpm_icon][0], sizeof(snails[wpm_icon][0]));
377 oled_set_cursor(3, 2);
378 oled_write_raw_P(snails[wpm_icon][1], sizeof(snails[wpm_icon][1]));
379 } else {
380 oled_set_cursor(0, 11);
381 oled_write_raw_P(snails[wpm_icon][0], sizeof(snails[wpm_icon][0]));
382 oled_set_cursor(0, 12);
383 oled_write_raw_P(snails[wpm_icon][1], sizeof(snails[wpm_icon][1]));
384 }
385}
386
387// Update WPM graph
388static void render_wpm_graph(int current_wpm) {
389 int line_height = ((current_wpm / graph_top_wpm) * 7);
390 if (line_height > 7) {
391 line_height = 7;
392 }
393 // Count graph line pixels, return if nothing to draw
394 int pixel_count = line_height;
395 for (int i = 0; i < 63; i++) {
396 pixel_count += graph_lines[i];
397 }
398 if (pixel_count == 0) {
399 return;
400 }
401 // Shift array elements left or right depending on graph_direction, append new graph line
402 if (graph_direction) {
403 for (int i = 0; i < 63; i++) {
404 graph_lines[i] = graph_lines[i + 1];
405 }
406 graph_lines[63] = line_height;
407 } else {
408 for (int i = 63; i > 0; i--) {
409 graph_lines[i] = graph_lines[i - 1];
410 }
411 graph_lines[0] = line_height;
412 }
413 // Draw all graph lines (left to right, bottom to top)
414 int draw_count, arrpos;
415 for (int x = 1; x <= 127; x += 2) {
416 arrpos = x / 2;
417 draw_count = graph_lines[arrpos];
418 for (int y = 31; y >= 25; y--) {
419 if (draw_count > 0) {
420 write_pixel(x, y, true);
421 draw_count--;
422 } else {
423 write_pixel(x, y, false);
424 }
425 }
426 }
427}
428
429// Call OLED functions
430void oled_task_user(void) {
431 // Draw OLED keyboard, prevent redraw
432 if (first_loop) {
433 render_background();
434 render_fn_row();
435 if (ansi_layout == false) {
436 render_iso();
437 }
438 first_loop = false;
439 }
440 // Get current WPM, subtract 25% for accuracy and prevent large jumps caused by simultaneous keypresses
441 int current_wpm = get_current_wpm();
442 // Note: This will most likely be removed once QMK's WPM calculation is updated
443 current_wpm -= current_wpm >> 2;
444 if (current_wpm > wpm_limit) {
445 current_wpm = max_wpm;
446 set_current_wpm(max_wpm);
447 }
448 // Write active layer name to display
449 render_layer_state();
450 // Update WPM counters
451 render_wpm_counters(current_wpm);
452 // Update WPM snail icon
453 render_wpm_icon(current_wpm);
454 // Update WPM graph every graph_refresh milliseconds
455 if (timer_elapsed(timer) > graph_refresh) {
456 render_wpm_graph(current_wpm);
457 timer = timer_read();
458 }
459}
460#endif
461
462// Called by QMK during key processing
463bool process_record_user(uint16_t keycode, keyrecord_t *record) {
464 // Forwards keystrokes from an external input device over UART/TRRS
465 process_record_remote_kb(keycode, record);
466
467 #ifdef OLED_DRIVER_ENABLE
468 // Toggle pixels surrounding key
469 render_keymap(record->event.key.row, record->event.key.col, record->event.pressed);
470 #endif
471
472 return true;
473}
474
475// Rotary encoder - RGB and OLED settings
476void change_RGB(bool clockwise) {
477 // While on any layer except default: // Rotary = RGB Mode
478 bool shift = get_mods() & MOD_MASK_SHIFT; // Rotary + Shift = OLED Brightness
479 bool ctrl = get_mods() & MOD_MASK_CTRL; // Rotary + Ctrl = RGB Brightness
480 bool gui = get_mods() & MOD_MASK_GUI; // Rotary + Gui = RGB Saturation
481 bool alt = get_mods() & MOD_MASK_ALT; // Rotary + Alt = RGB Hue
482
483 if (clockwise) {
484 if (shift) {
485 int new_brightness = oled_get_brightness() + 10;
486 if (new_brightness < 255) {
487 oled_set_brightness(new_brightness);
488 } else {
489 oled_set_brightness(255);
490 }
491 } else if (ctrl) {
492 rgblight_increase_val();
493 } else if (gui) {
494 rgblight_increase_sat();
495 } else if (alt) {
496 rgblight_increase_hue();
497 } else {
498 rgblight_step();
499 }
500 } else {
501 if (shift) {
502 int new_brightness = oled_get_brightness() - 10;
503 if (new_brightness > 0) {
504 oled_set_brightness(new_brightness);
505 } else {
506 oled_set_brightness(0);
507 }
508 } else if (ctrl) {
509 rgblight_decrease_val();
510 } else if (gui) {
511 rgblight_decrease_sat();
512 } else if (alt) {
513 rgblight_decrease_hue();
514 } else {
515 rgblight_step_reverse();
516 }
517 }
518}
519
520// Rotary encoder behavior - Change volume on default layer, RGB/OLED on other layers
521bool encoder_update_user(uint8_t index, bool clockwise) {
522 if (layer_state_is(0)) {
523 if (clockwise) {
524 tap_code(KC_VOLU);
525 } else {
526 tap_code(KC_VOLD);
527 }
528 } else {
529 change_RGB(clockwise);
530 }
531 return true;
532}
533
534// Initialize remote keyboard, if connected
535void matrix_init_user(void) {
536 matrix_init_remote_kb();
537}
538
539// Scan and parse keystrokes from remote keyboard, if connected
540void matrix_scan_user(void) {
541 matrix_scan_remote_kb();
542} \ No newline at end of file
diff --git a/keyboards/nullbitsco/nibble/keymaps/snailmap/readme.md b/keyboards/nullbitsco/nibble/keymaps/snailmap/readme.md
new file mode 100644
index 000000000..5ea93b01a
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/snailmap/readme.md
@@ -0,0 +1,36 @@
1
2# SnailMap
3
4![KeySnail](https://i.imgur.com/yEQJyI2h.png)
5
6## :snail: Display
7
8- Mini keyboard that highlights the currently pressed keys
9- Snail icon that changes based on the current WPM
10- Current and max WPM counters
11- Active layer name
12- WPM graph
13
14## :gear: Customization
15
16The `OLED configuration variables` can be used to easily customize the display
17
18```
19oled_horizontal - Horizontal or vertical orientation
20ansi_layout - ANSI or ISO layout
21split_space - Bottom row spacebar
22three_mods_left - Left modifier keys
23three_mods_right - Right modifier keys
24graph_direction - Graph movement direction
25graph_refresh - Frequency of graph lines
26graph_top_wpm - WPM required to reach the top of the graph
27icon_med_wpm - WPM required to display the medium snail
28icon_fast_wpm - WPM required to display the fast snail
29MA_LAYER_NAME - Layer 0 display name
30L1_LAYER_NAME - Layer 1 display name
31L2_LAYER_NAME - Layer 2 display name
32L3_LAYER_NAME - Layer 3 display name
33```
34___
35
36###### *Keymap created by* [dogspace](https://github.com/dogspace)
diff --git a/keyboards/nullbitsco/nibble/keymaps/snailmap/rules.mk b/keyboards/nullbitsco/nibble/keymaps/snailmap/rules.mk
new file mode 100644
index 000000000..ee2a59497
--- /dev/null
+++ b/keyboards/nullbitsco/nibble/keymaps/snailmap/rules.mk
@@ -0,0 +1,5 @@
1OLED_DRIVER_ENABLE = yes
2WPM_ENABLE = yes
3SPACE_CADET_ENABLE = no
4GRAVE_ESC_ENABLE = no
5MAGIC_ENABLE = no \ No newline at end of file