aboutsummaryrefslogtreecommitdiff
path: root/users/drashna/oled/oled_stuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/oled/oled_stuff.c')
-rw-r--r--users/drashna/oled/oled_stuff.c410
1 files changed, 291 insertions, 119 deletions
diff --git a/users/drashna/oled/oled_stuff.c b/users/drashna/oled/oled_stuff.c
index eeca010de..c850c5336 100644
--- a/users/drashna/oled/oled_stuff.c
+++ b/users/drashna/oled/oled_stuff.c
@@ -1,4 +1,5 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2021 John Ezra - wpm graph
2 * 3 *
3 * This program is free software: you can redistribute it and/or modify 4 * 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 * it under the terms of the GNU General Public License as published by
@@ -15,17 +16,17 @@
15 */ 16 */
16 17
17#include "drashna.h" 18#include "drashna.h"
18#ifdef CUSTOM_UNICODE_ENABLE 19#ifdef UNICODE_COMMON_ENABLE
19# include "process_unicode_common.h" 20# include "process_unicode_common.h"
20#endif 21#endif
21#include <string.h> 22#include <string.h>
22 23
23extern bool host_driver_disabled; 24extern bool host_driver_disabled;
24 25
25uint32_t oled_timer = 0; 26uint32_t oled_timer = 0;
26char keylog_str[OLED_KEYLOGGER_LENGTH] = {0}; 27char keylog_str[OLED_KEYLOGGER_LENGTH] = {0};
27static uint16_t log_timer = 0; 28static uint16_t log_timer = 0;
28static const char PROGMEM display_border[3] = {0x0, 0xFF, 0x0}; 29static const char PROGMEM display_border[3] = {0x0, 0xFF, 0x0};
29 30
30deferred_token kittoken; 31deferred_token kittoken;
31 32
@@ -112,7 +113,7 @@ void update_log(void) {
112 */ 113 */
113void render_keylogger_status(void) { 114void render_keylogger_status(void) {
114#ifdef OLED_DISPLAY_VERBOSE 115#ifdef OLED_DISPLAY_VERBOSE
115 oled_set_cursor(1, 7); 116 oled_set_cursor(1, 6);
116#endif 117#endif
117 oled_write_P(PSTR(OLED_RENDER_KEYLOGGER), false); 118 oled_write_P(PSTR(OLED_RENDER_KEYLOGGER), false);
118 oled_write(keylog_str, false); 119 oled_write(keylog_str, false);
@@ -127,7 +128,7 @@ void render_keylogger_status(void) {
127 */ 128 */
128void render_default_layer_state(void) { 129void render_default_layer_state(void) {
129#ifdef OLED_DISPLAY_VERBOSE 130#ifdef OLED_DISPLAY_VERBOSE
130 oled_set_cursor(5, 2); 131 oled_set_cursor(1, 1);
131#endif 132#endif
132 oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false); 133 oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false);
133 switch (get_highest_layer(default_layer_state)) { 134 switch (get_highest_layer(default_layer_state)) {
@@ -155,111 +156,166 @@ void render_default_layer_state(void) {
155 */ 156 */
156void render_layer_state(void) { 157void render_layer_state(void) {
157#ifdef OLED_DISPLAY_VERBOSE 158#ifdef OLED_DISPLAY_VERBOSE
158 static const char PROGMEM tri_layer_image[4][3][18] = { 159 // clang-format off
160 static const char PROGMEM tri_layer_image[][3][24] = {
161 // base
159 { 162 {
160 { 163 {
161 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 164 0x00, 0x00, 0x00, 0x80, 0x80, 0x40,
162 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 165 0x40, 0x20, 0x20, 0x10, 0x10, 0x08,
163 0x20, 0x20, 0x40, 0x40, 0x80, 0x80 166 0x08, 0x10, 0x10, 0x20, 0x20, 0x40,
167 0x40, 0x80, 0x80, 0x00, 0x00, 0x00
164 }, 168 },
165 { 169 {
166 0x88, 0x88, 0x5D, 0x5D, 0x3E, 0x3E, 170 0x00, 0x00, 0x00, 0x88, 0x88, 0x5D,
167 0x7C, 0x7C, 0xF8, 0xF8, 0x7C, 0x7C, 171 0x5D, 0x3E, 0x3E, 0x7C, 0x7C, 0xF8,
168 0x3E, 0x3E, 0x5D, 0x5D, 0x88, 0x88 172 0xF8, 0x7C, 0x7C, 0x3E, 0x3E, 0x5D,
173 0x5D, 0x88, 0x88, 0x00, 0x00, 0x00
169 }, 174 },
170 { 175 {
171 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 176 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
172 0x04, 0x04, 0x08, 0x08, 0x04, 0x04, 177 0x01, 0x02, 0x02, 0x04, 0x04, 0x08,
173 0x02, 0x02, 0x01, 0x01, 0x00, 0x00 178 0x08, 0x04, 0x04, 0x02, 0x02, 0x01,
179 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
174 } 180 }
175 }, 181 },
182 // raise
176 { 183 {
177 { 184 {
178 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 185 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0,
179 0xF0, 0xF0, 0xF8, 0xF8, 0xF0, 0xF0, 186 0xC0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF8,
180 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80 187 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0,
188 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00
181 }, 189 },
182 { 190 {
183 0x88, 0x88, 0x55, 0x55, 0x23, 0x23, 191 0x00, 0x00, 0x00, 0x88, 0x88, 0x55,
184 0x47, 0x47, 0x8F, 0x8F, 0x47, 0x47, 192 0x55, 0x23, 0x23, 0x47, 0x47, 0x8F,
185 0x23, 0x23, 0x55, 0x55, 0x88, 0x88 193 0x8F, 0x47, 0x47, 0x23, 0x23, 0x55,
194 0x55, 0x88, 0x88, 0x00, 0x00, 0x00
186 }, 195 },
187 { 196 {
188 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 197 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
189 0x04, 0x04, 0x08, 0x08, 0x04, 0x04, 198 0x01, 0x02, 0x02, 0x04, 0x04, 0x08,
190 0x02, 0x02, 0x01, 0x01, 0x00, 0x00 199 0x08, 0x04, 0x04, 0x02, 0x02, 0x01,
200 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
191 } 201 }
192 }, 202 },
203 // lower
193 { 204 {
194 { 205 {
195 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 206 0x00, 0x00, 0x00, 0x80, 0x80, 0x40,
196 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 207 0x40, 0x20, 0x20, 0x10, 0x10, 0x08,
197 0x20, 0x20, 0x40, 0x40, 0x80, 0x80 208 0x08, 0x10, 0x10, 0x20, 0x20, 0x40,
209 0x40, 0x80, 0x80, 0x00, 0x00, 0x00
198 }, 210 },
199 { 211 {
200 0x88, 0x88, 0xD5, 0xD5, 0xE2, 0xE2, 212 0x00, 0x00, 0x00, 0x88, 0x88, 0xD5,
201 0xC4, 0xC4, 0x88, 0x88, 0xC4, 0xC4, 213 0xD5, 0xE2, 0xE2, 0xC4, 0xC4, 0x88,
202 0xE2, 0xE2, 0xD5, 0xD5, 0x88, 0x88 214 0x88, 0xC4, 0xC4, 0xE2, 0xE2, 0xD5,
215 0xD5, 0x88, 0x88, 0x00, 0x00, 0x00
203 }, 216 },
204 { 217 {
205 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 218 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
206 0x07, 0x07, 0x0F, 0x0F, 0x07, 0x07, 219 0x01, 0x03, 0x03, 0x07, 0x07, 0x0F,
207 0x03, 0x03, 0x01, 0x01, 0x00, 0x00 220 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01,
221 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
208 } 222 }
209 }, 223 },
224 // adjust
210 { 225 {
211 { 226 {
212 0x80, 0x80, 0x40, 0xC0, 0x60, 0xA0, 227 0x00, 0x00, 0x00, 0x80, 0x80, 0x40,
213 0x50, 0xB0, 0x58, 0xA8, 0x50, 0xB0, 228 0xC0, 0x60, 0xA0, 0x50, 0xB0, 0x58,
214 0x60, 0xA0, 0x40, 0xC0, 0x80, 0x80 229 0xA8, 0x50, 0xB0, 0x60, 0xA0, 0x40,
230 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00
215 }, 231 },
216 { 232 {
217 0x88, 0x88, 0x5D, 0xD5, 0x6B, 0xB6, 233 0x00, 0x00, 0x00, 0x88, 0x88, 0x5D,
218 0x6D, 0xD6, 0xAD, 0xDA, 0x6D, 0xD6, 234 0xD5, 0x6B, 0xB6, 0x6D, 0xD6, 0xAD,
219 0x6B, 0xB6, 0x5D, 0xD5, 0x88, 0x88 235 0xDA, 0x6D, 0xD6, 0x6B, 0xB6, 0x5D,
236 0xD5, 0x88, 0x88, 0x00, 0x00, 0x00
220 }, 237 },
221 { 238 {
222 0x00, 0x00, 0x01, 0x01, 0x03, 0x02, 239 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
223 0x05, 0x06, 0x0D, 0x0A, 0x05, 0x06, 240 0x01, 0x03, 0x02, 0x05, 0x06, 0x0D,
224 0x03, 0x02, 0x01, 0x01, 0x00, 0x00 241 0x0A, 0x05, 0x06, 0x03, 0x02, 0x01,
242 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
225 } 243 }
244 },
245 // blank
246 {
247 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
248 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
249 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
250 },
251 // better gamepad
252 {
253 { 0, 0, 0,192,224,224,112,240,240,240,240,144,144,240,240,240,240,112,224,224,192, 0, 0, 0 },
254 { 128,248,255,255,255,254,252,230,195,195,230,255,255,254,247,227,246,253,254,255,255,255,248,128 },
255 { 7, 15, 15, 15, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, 15, 7 }
256
257 },
258 // mouse
259 {
260 { 0, 0, 0, 0, 0, 0, 0, 0,192, 32, 32, 32,160, 32, 32, 32,192, 0, 0, 0, 0, 0, 0, 0 },
261 { 0, 0, 0, 0, 0, 0, 0,240, 15, 0, 0, 0, 3, 0, 0, 0, 15,240, 0, 0, 0, 0, 0, 0 },
262 { 0, 0, 0, 0, 0, 0, 0, 3, 6, 4, 4, 4, 4, 4, 4, 4, 6, 3, 0, 0, 0, 0, 0, 0 }
226 } 263 }
227 }; 264 };
228 265
229 uint8_t layer_is = 0; 266
267 // clang-format on
268 uint8_t layer_is[4] = { 0, 4, 4, 4};
230 if (layer_state_is(_ADJUST)) { 269 if (layer_state_is(_ADJUST)) {
231 layer_is = 3; 270 layer_is[0] = 3;
232 } else if (layer_state_is(_RAISE)) { 271 } else if (layer_state_is(_RAISE)) {
233 layer_is = 1; 272 layer_is[0] = 1;
234 } else if (layer_state_is(_LOWER)) { 273 } else if (layer_state_is(_LOWER)) {
235 layer_is = 2; 274 layer_is[0] = 2;
275 }
276
277 if (layer_state_is(_MOUSE)) {
278 layer_is[1] = 6;
236 } 279 }
280 if (layer_state_is(_GAMEPAD)) {
281 layer_is[2] = 5;
282 }
283
237 284
238 oled_set_cursor(1, 2); 285 oled_set_cursor(1, 2);
239 oled_write_raw_P(tri_layer_image[layer_is][0], sizeof(tri_layer_image[0][0])); 286 oled_write_raw_P(tri_layer_image[layer_is[0]][0], sizeof(tri_layer_image[0][0]));
240 oled_set_cursor(5, 3); 287 oled_set_cursor(5, 2);
288 oled_write_raw_P(tri_layer_image[layer_is[1]][0], sizeof(tri_layer_image[0][0]));
289 oled_set_cursor(9, 2);
290 oled_write_raw_P(tri_layer_image[layer_is[2]][0], sizeof(tri_layer_image[0][0]));
291 oled_set_cursor(14, 2);
241 oled_write_P(PSTR("Diablo2"), layer_state_is(_DIABLOII)); 292 oled_write_P(PSTR("Diablo2"), layer_state_is(_DIABLOII));
242 oled_write_P(PSTR(" "), false);
243 oled_write_P(PSTR("Diablo3"), layer_state_is(_DIABLO));
244 oled_advance_page(true); 293 oled_advance_page(true);
245 294
246 oled_set_cursor(1, 3); 295 oled_set_cursor(1, 3);
247 oled_write_raw_P(tri_layer_image[layer_is][1], sizeof(tri_layer_image[0][0])); 296 oled_write_raw_P(tri_layer_image[layer_is[0]][1], sizeof(tri_layer_image[0][0]));
248 oled_set_cursor(5, 4); 297 oled_set_cursor(5, 3);
249 oled_write_P(PSTR("GamePad"), layer_state_is(_GAMEPAD)); 298 oled_write_raw_P(tri_layer_image[layer_is[1]][1], sizeof(tri_layer_image[0][0]));
250 oled_write_P(PSTR(" "), false); 299 oled_set_cursor(9, 3);
251 oled_write_P(PSTR("Mouse"), layer_state_is(_MOUSE)); 300 oled_write_raw_P(tri_layer_image[layer_is[2]][1], sizeof(tri_layer_image[0][0]));
301 oled_set_cursor(14, 3);
302 oled_write_P(PSTR("Diablo3"), layer_state_is(_DIABLO));
252 oled_advance_page(true); 303 oled_advance_page(true);
253 304
254 oled_set_cursor(1, 4); 305 oled_set_cursor(1, 4);
255 oled_write_raw_P(tri_layer_image[layer_is][2], sizeof(tri_layer_image[0][0])); 306 oled_write_raw_P(tri_layer_image[layer_is[0]][2], sizeof(tri_layer_image[0][0]));
256 307 oled_set_cursor(5, 4);
308 oled_write_raw_P(tri_layer_image[layer_is[1]][2], sizeof(tri_layer_image[0][0]));
309 oled_set_cursor(9, 4);
310 oled_write_raw_P(tri_layer_image[layer_is[2]][2], sizeof(tri_layer_image[0][0]));
311 oled_set_cursor(14, 4);
312 oled_write_P(PSTR("Media"), layer_state_is(_MEDIA));
257#else 313#else
258 oled_write_P(PSTR(OLED_RENDER_LAYER_NAME), false); 314 oled_write_P(PSTR(OLED_RENDER_LAYER_NAME), false);
259 oled_write_P(PSTR(OLED_RENDER_LAYER_LOWER), layer_state_is(_LOWER)); 315 oled_write_P(PSTR(OLED_RENDER_LAYER_LOWER), layer_state_is(_LOWER));
260 oled_write_P(PSTR(OLED_RENDER_LAYER_RAISE), layer_state_is(_RAISE)); 316 oled_write_P(PSTR(OLED_RENDER_LAYER_RAISE), layer_state_is(_RAISE));
261 oled_advance_page(true);
262#endif 317#endif
318 oled_advance_page(true);
263} 319}
264 320
265/** 321/**
@@ -288,9 +344,14 @@ void render_keylock_status(uint8_t led_usb_state) {
288 * @brief Renders the matrix scan rate to the host system 344 * @brief Renders the matrix scan rate to the host system
289 * 345 *
290 */ 346 */
291void render_matrix_scan_rate(void) { 347void render_matrix_scan_rate(uint8_t padding) {
292#ifdef DEBUG_MATRIX_SCAN_RATE 348#ifdef DEBUG_MATRIX_SCAN_RATE
293 oled_write_P(PSTR("MS:"), false); 349 oled_write_P(PSTR("MS:"), false);
350 if (padding) {
351 for (uint8_t n = padding; n > 0; n--) {
352 oled_write_P(PSTR(" "), false);
353 }
354 }
294 oled_write(get_u16_str(get_matrix_scan_rate(), ' '), false); 355 oled_write(get_u16_str(get_matrix_scan_rate(), ' '), false);
295#endif 356#endif
296} 357}
@@ -337,7 +398,7 @@ void render_bootmagic_status(void) {
337 398
338 bool is_bootmagic_on; 399 bool is_bootmagic_on;
339#ifdef OLED_DISPLAY_VERBOSE 400#ifdef OLED_DISPLAY_VERBOSE
340 oled_set_cursor(7, 4); 401 oled_set_cursor(7, 3);
341 is_bootmagic_on = !keymap_config.swap_lctl_lgui; 402 is_bootmagic_on = !keymap_config.swap_lctl_lgui;
342#else 403#else
343 is_bootmagic_on = keymap_config.swap_lctl_lgui; 404 is_bootmagic_on = keymap_config.swap_lctl_lgui;
@@ -366,11 +427,12 @@ void render_bootmagic_status(void) {
366 oled_write_P(PSTR(" "), false); 427 oled_write_P(PSTR(" "), false);
367#ifdef AUTOCORRECTION_ENABLE 428#ifdef AUTOCORRECTION_ENABLE
368 oled_write_P(PSTR("CRCT"), userspace_config.autocorrection); 429 oled_write_P(PSTR("CRCT"), userspace_config.autocorrection);
430 oled_write_P(PSTR(" "), false);
369#else 431#else
370 oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui); 432 oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui);
371#endif 433#endif
372#ifdef OLED_DISPLAY_VERBOSE 434#ifdef OLED_DISPLAY_VERBOSE
373 oled_set_cursor(7, 5); 435 oled_set_cursor(7, 4);
374 if (keymap_config.swap_lctl_lgui) { 436 if (keymap_config.swap_lctl_lgui) {
375 oled_write_P(logo[1][1], is_bootmagic_on); 437 oled_write_P(logo[1][1], is_bootmagic_on);
376 } else { 438 } else {
@@ -382,6 +444,7 @@ void render_bootmagic_status(void) {
382#ifdef SWAP_HANDS_ENABLE 444#ifdef SWAP_HANDS_ENABLE
383 oled_write_P(PSTR(" "), false); 445 oled_write_P(PSTR(" "), false);
384 oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands); 446 oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands);
447 oled_write_P(PSTR(" "), false);
385#endif 448#endif
386} 449}
387 450
@@ -402,7 +465,7 @@ void render_user_status(void) {
402# endif 465# endif
403#endif 466#endif
404#if defined(OLED_DISPLAY_VERBOSE) 467#if defined(OLED_DISPLAY_VERBOSE)
405 oled_set_cursor(1, 6); 468 oled_set_cursor(1, 5);
406#endif 469#endif
407 oled_write_P(PSTR(OLED_RENDER_USER_NAME), false); 470 oled_write_P(PSTR(OLED_RENDER_USER_NAME), false);
408#if !defined(OLED_DISPLAY_VERBOSE) 471#if !defined(OLED_DISPLAY_VERBOSE)
@@ -434,9 +497,9 @@ void render_user_status(void) {
434 oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false); 497 oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
435 static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}}; 498 static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
436 oled_write_P(cat_mode[0], host_driver_disabled); 499 oled_write_P(cat_mode[0], host_driver_disabled);
437#if defined(CUSTOM_UNICODE_ENABLE) 500#if defined(UNICODE_COMMON_ENABLE)
438 static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}}; 501 static const char PROGMEM uc_mod_status[5][3] = {{0xEC, 0xED, 0}, {0x20, 0x20, 0}, {0x20, 0x20, 0}, {0x20, 0x20, 0}, {0xEA, 0xEB, 0}};
439 oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false); 502 oled_write_P(uc_mod_status[get_unicode_input_mode()], false);
440#endif 503#endif
441 if (userspace_config.nuke_switch) { 504 if (userspace_config.nuke_switch) {
442#if !defined(OLED_DISPLAY_VERBOSE) 505#if !defined(OLED_DISPLAY_VERBOSE)
@@ -466,9 +529,69 @@ void render_wpm(uint8_t padding) {
466#endif 529#endif
467} 530}
468 531
469#if defined(KEYBOARD_handwired_tractyl_manuform) || defined(KEYBOARD_bastardkb_charybdis) 532//============= USER CONFIG PARAMS ===============
470extern kb_config_data_t kb_config; 533// wpm graph originally designed by john-ezra
471void render_pointing_dpi_status(uint8_t padding) { 534
535// for 128x128:
536// max_lines_graph = 54;
537// vertical_offset = 64;
538// for 128x64:
539// max_lines_graph = 64;
540// vertical_offset = 0;
541
542void render_wpm_graph(uint8_t max_lines_graph, uint8_t vertical_offset) {
543 static uint16_t timer = 0;
544 static uint8_t x = OLED_DISPLAY_HEIGHT - 1;
545 uint8_t currwpm = get_current_wpm();
546 float max_wpm = OLED_WPM_GRAPH_MAX_WPM;
547
548 if (timer_elapsed(timer) > OLED_WPM_GRAPH_REFRESH_INTERVAL) { // check if it's been long enough before refreshing graph
549 x = (max_lines_graph - 1) - ((currwpm / max_wpm) * (max_lines_graph - 1)); // main calculation to plot graph line
550 for (uint8_t i = 0; i <= OLED_WPM_GRAPH_GRAPH_LINE_THICKNESS - 1; i++) { // first draw actual value line
551 oled_write_pixel(3, x + i + vertical_offset, true);
552 }
553# ifdef OLED_WPM_GRAPH_VERTICAL_LINE
554 static uint8_t vert_count = 0;
555 if (vert_count == OLED_WPM_GRAPH_VERTCAL_LINE_INTERVAL) {
556 vert_count = 0;
557 while (x <= (max_lines_graph - 1)) {
558 oled_write_pixel(3, x + vertical_offset, true);
559 x++;
560 }
561 } else {
562 for (uint8_t i = (max_lines_graph - 1); i > x; i--) {
563 if (i % OLED_WPM_GRAPH_AREA_FILL_INTERVAL == 0) {
564 oled_write_pixel(3, i + vertical_offset, true);
565 }
566 }
567 vert_count++;
568 }
569# else
570 for (int i = (max_lines_graph - 1); i > x; i--) {
571 if (i % OLED_WPM_GRAPH_AREA_FILL_INTERVAL == 0) {
572 oled_write_pixel(3, i + vertical_offset, true);
573 }
574 }
575# endif
576 oled_pan(false); // then move the entire graph one pixel to the right
577 static const char PROGMEM display_border[3] = {0x0, 0xFF, 0x0};
578 for (uint8_t i = 0; i < 7; i++) {
579 oled_set_cursor(0, i + 8);
580 oled_write_raw_P(display_border, sizeof(display_border));
581 oled_set_cursor(21, i + 8);
582 oled_write_raw_P(display_border, sizeof(display_border));
583 }
584 static const char PROGMEM footer_image[] = {0, 3, 4, 8, 16, 32, 64, 128, 128, 128, 128, 128, 128, 128, 192, 224, 240, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 240, 224, 192, 128, 128, 128, 128, 128, 128, 128, 64, 32, 16, 8, 4, 3, 0};
585 oled_set_cursor(0, 15);
586
587 oled_write_raw_P(footer_image, sizeof(footer_image));
588
589 timer = timer_read(); // refresh the timer for the next iteration
590 }
591}
592
593#if defined(POINTING_DEVICE_ENABLE)
594void render_pointing_dpi_status(uint16_t cpi, uint8_t padding) {
472 oled_write_P(PSTR("CPI:"), false); 595 oled_write_P(PSTR("CPI:"), false);
473 if (padding) { 596 if (padding) {
474 for (uint8_t n = padding - 1; n > 0; n--) { 597 for (uint8_t n = padding - 1; n > 0; n--) {
@@ -476,17 +599,15 @@ void render_pointing_dpi_status(uint8_t padding) {
476 } 599 }
477 } 600 }
478 601
479 oled_write(get_u16_str(kb_config.device_cpi, ' '), false); 602 oled_write(get_u16_str(cpi, ' '), false);
480} 603}
481#endif 604#endif
482 605
483__attribute__((weak)) void oled_driver_render_logo_right(void) { 606__attribute__((weak)) void oled_driver_render_logo_right(void) {
484#if defined(OLED_DISPLAY_VERBOSE) 607#if defined(OLED_DISPLAY_VERBOSE)
485 oled_set_cursor(0, 2); 608 oled_set_cursor(0, 1);
486 render_default_layer_state();
487#else
488 render_default_layer_state();
489#endif 609#endif
610 render_default_layer_state();
490} 611}
491 612
492// WPM-responsive animation stuff here 613// WPM-responsive animation stuff here
@@ -511,8 +632,8 @@ __attribute__((weak)) void oled_driver_render_logo_right(void) {
511# error frame size too large 632# error frame size too large
512#endif 633#endif
513 634
514static uint8_t animation_frame = 0; 635static uint8_t animation_frame = 0;
515static uint8_t animation_type = 0; 636static uint8_t animation_type = 0;
516 637
517void render_kitty(void) { 638void render_kitty(void) {
518 // Images credit j-inc(/James Incandenza) and pixelbenny. 639 // Images credit j-inc(/James Incandenza) and pixelbenny.
@@ -771,28 +892,28 @@ void render_kitty(void) {
771 // clang-format on 892 // clang-format on
772 893
773 for (uint8_t i = 0; i < 4; i++) { 894 for (uint8_t i = 0; i < 4; i++) {
774 oled_set_cursor(1, i + 2); 895 oled_set_cursor(1, i + 1);
775 oled_write_raw_P(animation[animation_type][animation_frame][i], OLED_ANIM_SIZE); 896 oled_write_raw_P(animation[animation_type][animation_frame][i], OLED_ANIM_SIZE);
776 } 897 }
777} 898}
778 899
779uint32_t kitty_animation_phases(uint32_t triger_time, void *cb_arg) { 900uint32_t kitty_animation_phases(uint32_t triger_time, void *cb_arg) {
780 uint32_t anim_frame_duration = 500; 901 static uint32_t anim_frame_duration = 500;
781 // can't change animation frame duration here, otherwise, it gets stuck.
782 // weirdly, it seems to work fine if it's in keymap.c but not here.
783 // Should move this block to the deferred execution?
784#ifdef POINTING_DEVICE_ENABLE 902#ifdef POINTING_DEVICE_ENABLE
785 if (tap_toggling) { 903 if (tap_toggling) {
786 animation_frame = (animation_frame + 1) % OLED_RTOGI_FRAMES; 904 animation_frame = (animation_frame + 1) % OLED_RTOGI_FRAMES;
787 animation_type = 3; 905 animation_type = 3;
788 anim_frame_duration = 300; 906 anim_frame_duration = 300;
789 } else 907 } else
790#endif 908#endif
791 { 909 {
910#ifdef WPM_ENABLE
792 if (get_current_wpm() <= OLED_SLEEP_SPEED) { 911 if (get_current_wpm() <= OLED_SLEEP_SPEED) {
912#endif
793 animation_frame = (animation_frame + 1) % OLED_SLEEP_FRAMES; 913 animation_frame = (animation_frame + 1) % OLED_SLEEP_FRAMES;
794 animation_type = 0; 914 animation_type = 0;
795 anim_frame_duration = 500; 915 anim_frame_duration = 500;
916#ifdef WPM_ENABLE
796 } else if (get_current_wpm() > OLED_WAKE_SPEED) { 917 } else if (get_current_wpm() > OLED_WAKE_SPEED) {
797 animation_frame = (animation_frame + 1) % OLED_WAKE_FRAMES; 918 animation_frame = (animation_frame + 1) % OLED_WAKE_FRAMES;
798 animation_type = 1; 919 animation_type = 1;
@@ -802,13 +923,14 @@ uint32_t kitty_animation_phases(uint32_t triger_time, void *cb_arg) {
802 animation_type = 2; 923 animation_type = 2;
803 anim_frame_duration = 500; 924 anim_frame_duration = 500;
804 } 925 }
926#endif
805 } 927 }
806 return anim_frame_duration; 928 return anim_frame_duration;
807} 929}
808 930
809void oled_driver_render_logo_left(void) { 931void oled_driver_render_logo_left(void) {
810#if defined(OLED_DISPLAY_VERBOSE) 932#if defined(OLED_DISPLAY_VERBOSE)
811 oled_set_cursor(0, 2); 933 oled_set_cursor(0, 1);
812 render_kitty(); 934 render_kitty();
813 935
814# if defined(KEYBOARD_handwired_tractyl_manuform) 936# if defined(KEYBOARD_handwired_tractyl_manuform)
@@ -817,39 +939,82 @@ void oled_driver_render_logo_left(void) {
817# elif defined(KEYBOARD_bastardkb_charybdis) 939# elif defined(KEYBOARD_bastardkb_charybdis)
818 oled_set_cursor(6, 0); 940 oled_set_cursor(6, 0);
819 oled_write_P(PSTR("Charybdis"), true); 941 oled_write_P(PSTR("Charybdis"), true);
942# elif defined(KEYBOARD_splitkb_kyria)
943 oled_set_cursor(7, 0);
944 oled_write_P(PSTR("SplitKB"), true);
820# else 945# else
821 oled_set_cursor(8, 0); 946 oled_set_cursor(8, 0);
822 oled_write_P(PSTR("Left"), true); 947 oled_write_P(PSTR("Left"), true);
823# endif 948# endif
824 oled_set_cursor(7, 2); 949 oled_set_cursor(7, 1);
825# if defined(DEBUG_MATRIX_SCAN_RATE) 950# if defined(WPM_ENABLE)
826 render_matrix_scan_rate();
827# elif defined(WPM_ENABLE)
828 render_wpm(1); 951 render_wpm(1);
952# elif defined(DEBUG_MATRIX_SCAN_RATE)
953 render_matrix_scan_rate(2);
829# endif 954# endif
830 oled_set_cursor(7, 3); 955 oled_set_cursor(7, 2);
831# if defined(KEYBOARD_handwired_tractyl_manuform) 956# if defined(KEYBOARD_bastardkb_charybdis)
832 render_pointing_dpi_status(0); 957 render_pointing_dpi_status(charybdis_get_pointer_sniping_enabled() ? charybdis_get_pointer_sniping_dpi() : charybdis_get_pointer_default_dpi(), 1);
833# elif defined(KEYBOARD_bastardkb_charybdis) 958
834 render_pointing_dpi_status(1); 959// credit and thanks to jaspertandy on discord for these images
960 static const char PROGMEM mouse_logo[3][2][16] = {
961 // mouse icon
962 {
963 { 0, 0, 0, 252, 2, 2, 2, 58, 2, 2, 2, 252, 0, 0, 0, 0 },
964 { 0, 0, 63, 96, 64, 64, 64, 64, 64, 64, 64, 96, 63, 0, 0, 0 }
965 },
966 // crosshair icon
967 {
968 { 128, 240, 136, 228, 146, 138, 202, 127, 202, 138, 146, 228, 136, 240, 128, 0 },
969 { 0, 7, 8, 19, 36, 40, 41, 127, 41, 40, 36, 19, 8, 7, 0, 0 }
970 },
971 // dragscroll icon
972 {
973 { 0, 0, 112, 136, 156, 2, 15, 1, 15, 2, 140, 68, 56, 0, 0, 0 },
974 { 0, 0, 2, 6, 15, 28, 60, 124, 60, 28, 15, 6, 2, 0, 0, 0 }
975 }
976 };
977
978
979 uint8_t image_index = 0;
980# ifdef OLED_DISPLAY_TEST
981 image_index = animation_frame;
982# else
983 if (charybdis_get_pointer_sniping_enabled()) {
984 image_index = 1;
985 } else if (charybdis_get_pointer_dragscroll_enabled()) {
986 image_index = 2;
987 }
988# endif
989
990 oled_set_cursor(17, 1);
991 oled_write_raw_P(mouse_logo[image_index][0], 16);
992 oled_set_cursor(17, 2);
993 oled_write_raw_P(mouse_logo[image_index][1], 16);
994# elif defined(WPM_ENABLE) && defined(DEBUG_MATRIX_SCAN_RATE)
995 render_matrix_scan_rate(2);
835# endif 996# endif
836 oled_set_cursor(0, 6); 997
998 oled_set_cursor(0, 5);
837#else 999#else
838 render_default_layer_state(); 1000 render_default_layer_state();
839#endif 1001#endif
840} 1002}
841 1003
842void render_status_secondary(void) { 1004void render_status_right(void) {
843# if defined(KEYBOARD_handwired_tractyl_manuform) 1005#if defined(KEYBOARD_handwired_tractyl_manuform)
844 oled_set_cursor(7, 0); 1006 oled_set_cursor(7, 0);
845 oled_write_P(PSTR("Manuform"), true); 1007 oled_write_P(PSTR("Manuform"), true);
846# elif defined(KEYBOARD_bastardkb_charybdis) 1008#elif defined(KEYBOARD_bastardkb_charybdis)
847 oled_set_cursor(6, 0); 1009 oled_set_cursor(6, 0);
848 oled_write_P(PSTR("Charybdis"), true); 1010 oled_write_P(PSTR("Charybdis"), true);
849# else 1011#elif defined(KEYBOARD_splitkb_kyria)
1012 oled_set_cursor(8, 0);
1013 oled_write_P(PSTR("Kyria"), true);
1014#else
850 oled_set_cursor(8, 0); 1015 oled_set_cursor(8, 0);
851 oled_write_P(PSTR("Right"), true); 1016 oled_write_P(PSTR("Right"), true);
852# endif 1017#endif
853 oled_driver_render_logo_right(); 1018 oled_driver_render_logo_right();
854 /* Show Keyboard Layout */ 1019 /* Show Keyboard Layout */
855 render_layer_state(); 1020 render_layer_state();
@@ -860,16 +1025,18 @@ void render_status_secondary(void) {
860 render_keylock_status(host_keyboard_leds()); 1025 render_keylock_status(host_keyboard_leds());
861} 1026}
862 1027
863void render_status_main(void) { 1028void render_status_left(void) {
864 oled_driver_render_logo_left(); 1029 oled_driver_render_logo_left();
865 1030
866 /* Show Keyboard Layout */ 1031 /* Show Keyboard Layout */
867 render_bootmagic_status(); 1032 render_bootmagic_status();
868 render_user_status(); 1033 render_user_status();
869 1034
870 // render_keylogger_status(); 1035 render_keylogger_status();
871} 1036}
872 1037
1038__attribute__((weak)) void oled_render_large_display(void) {}
1039
873__attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) { return rotation; } 1040__attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) { return rotation; }
874 1041
875oled_rotation_t oled_init_user(oled_rotation_t rotation) { 1042oled_rotation_t oled_init_user(oled_rotation_t rotation) {
@@ -884,12 +1051,14 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
884 return oled_init_keymap(rotation); 1051 return oled_init_keymap(rotation);
885} 1052}
886 1053
1054__attribute__((weak)) bool oled_task_keymap(void) { return true; }
1055
887bool oled_task_user(void) { 1056bool oled_task_user(void) {
888 update_log(); 1057 update_log();
889 1058
890 if (is_keyboard_master()) { 1059 if (is_keyboard_master()) {
891#ifndef OLED_DISPLAY_TEST 1060#ifndef OLED_DISPLAY_TEST
892 if (timer_elapsed32(oled_timer) > 30000) { 1061 if (timer_elapsed32(oled_timer) > 60000) {
893 oled_off(); 1062 oled_off();
894 return false; 1063 return false;
895 } else 1064 } else
@@ -898,14 +1067,23 @@ bool oled_task_user(void) {
898 oled_on(); 1067 oled_on();
899 } 1068 }
900 } 1069 }
1070
1071 if (!oled_task_keymap()) {
1072 return false;
1073 }
1074
1075#if defined(OLED_DISPLAY_128X128)
1076 oled_set_cursor(0, 7);
1077 oled_render_large_display();
1078#endif
1079
901#if defined(OLED_DISPLAY_VERBOSE) 1080#if defined(OLED_DISPLAY_VERBOSE)
902 static const char PROGMEM header_image[] = { 1081 static const char PROGMEM header_image[] = {
903 0,192, 32, 16, 8, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 7, 15, 31, 63,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,127, 63, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 8, 16, 32,192, 0, 1082 0, 192, 32, 16, 8, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 7, 15, 31, 63, 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 63, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 8, 16, 32, 192, 0,
904 0,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0 1083 // 0,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0
905 }; 1084 };
906 static const char PROGMEM footer_image[] = { 1085 static const char PROGMEM footer_image[] = {0, 3, 4, 8, 16, 32, 64, 128, 128, 128, 128, 128, 128, 128, 192, 224, 240, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 240, 224, 192, 128, 128, 128, 128, 128, 128, 128, 64, 32, 16, 8, 4, 3, 0};
907 0, 3, 4, 8, 16, 32, 64,128,128,128,128,128,128,128,192,224,240,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,240,224,192,128,128,128,128,128,128,128, 64, 32, 16, 8, 4, 3, 0 1086 oled_set_cursor(0, 0);
908 };
909 oled_write_raw_P(header_image, sizeof(header_image)); 1087 oled_write_raw_P(header_image, sizeof(header_image));
910 oled_set_cursor(0, 1); 1088 oled_set_cursor(0, 1);
911#endif 1089#endif
@@ -913,16 +1091,10 @@ bool oled_task_user(void) {
913#ifndef OLED_DISPLAY_TEST 1091#ifndef OLED_DISPLAY_TEST
914 if (is_keyboard_left()) { 1092 if (is_keyboard_left()) {
915#endif 1093#endif
916 render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) 1094 render_status_left();
917#ifndef OLED_DISPLAY_TEST 1095#ifndef OLED_DISPLAY_TEST
918 } else { 1096 } else {
919 render_status_secondary(); 1097 render_status_right();
920 }
921#endif
922
923#if defined(OLED_DISPLAY_128X128)
924 if (is_keyboard_left()) {
925 render_keylogger_status();
926 } 1098 }
927#endif 1099#endif
928 1100
@@ -933,7 +1105,7 @@ bool oled_task_user(void) {
933# else 1105# else
934 num_of_rows = 7; 1106 num_of_rows = 7;
935# endif 1107# endif
936 for (uint8_t i= 1; i < num_of_rows; i++) { 1108 for (uint8_t i = 1; i < num_of_rows; i++) {
937 oled_set_cursor(0, i); 1109 oled_set_cursor(0, i);
938 oled_write_raw_P(display_border, sizeof(display_border)); 1110 oled_write_raw_P(display_border, sizeof(display_border));
939 oled_set_cursor(21, i); 1111 oled_set_cursor(21, i);