aboutsummaryrefslogtreecommitdiff
path: root/users/drashna/oled_stuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/oled_stuff.c')
-rw-r--r--users/drashna/oled_stuff.c80
1 files changed, 44 insertions, 36 deletions
diff --git a/users/drashna/oled_stuff.c b/users/drashna/oled_stuff.c
index 98e467d93..b2f49a2e7 100644
--- a/users/drashna/oled_stuff.c
+++ b/users/drashna/oled_stuff.c
@@ -25,7 +25,7 @@
25#endif 25#endif
26 26
27uint32_t oled_timer = 0; 27uint32_t oled_timer = 0;
28static char keylog_str[KEYLOGGER_LENGTH + 1] = {"\n"}; 28static char keylog_str[KEYLOGGER_LENGTH + 1] = {0};
29static uint16_t log_timer = 0; 29static uint16_t log_timer = 0;
30 30
31// clang-format off 31// clang-format off
@@ -57,12 +57,12 @@ void add_keylog(uint16_t keycode) {
57 keycode = 0; 57 keycode = 0;
58 } 58 }
59 59
60 for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) { 60 for (uint8_t i = 1; i < KEYLOGGER_LENGTH; i++) {
61 keylog_str[i] = keylog_str[i - 1]; 61 keylog_str[i - 1] = keylog_str[i];
62 } 62 }
63 63
64 if (keycode < (sizeof(code_to_name) / sizeof(char))) { 64 if (keycode < (sizeof(code_to_name) / sizeof(char))) {
65 keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); 65 keylog_str[(KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]);
66 } 66 }
67 67
68 log_timer = timer_read(); 68 log_timer = timer_read();
@@ -95,27 +95,15 @@ void render_default_layer_state(void) {
95 case _QWERTY: 95 case _QWERTY:
96 oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false); 96 oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false);
97 break; 97 break;
98 case _COLEMAK_DH:
99 oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK_DH), false);
100 break;
98 case _COLEMAK: 101 case _COLEMAK:
99 oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false); 102 oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false);
100 break; 103 break;
101 case _DVORAK: 104 case _DVORAK:
102 oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false); 105 oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false);
103 break; 106 break;
104 case _WORKMAN:
105 oled_write_P(PSTR(OLED_RENDER_LAYOUT_WORKMAN), false);
106 break;
107 case _NORMAN:
108 oled_write_P(PSTR(OLED_RENDER_LAYOUT_NORMAN), false);
109 break;
110 case _MALTRON:
111 oled_write_P(PSTR(OLED_RENDER_LAYOUT_MALTRON), false);
112 break;
113 case _EUCALYN:
114 oled_write_P(PSTR(OLED_RENDER_LAYOUT_EUCALYN), false);
115 break;
116 case _CARPLAX:
117 oled_write_P(PSTR(OLED_RENDER_LAYOUT_CARPLAX), false);
118 break;
119 } 107 }
120#ifdef OLED_DISPLAY_128X64 108#ifdef OLED_DISPLAY_128X64
121 oled_advance_page(true); 109 oled_advance_page(true);
@@ -159,12 +147,12 @@ void render_keylock_status(uint8_t led_usb_state) {
159} 147}
160void render_matrix_scan_rate(void) { 148void render_matrix_scan_rate(void) {
161#ifdef DEBUG_MATRIX_SCAN_RATE 149#ifdef DEBUG_MATRIX_SCAN_RATE
162 char matrix_rate[5]; 150 char matrix_rate[5];
163 uint16_t n = get_matrix_scan_rate(); 151 uint16_t n = get_matrix_scan_rate();
164 matrix_rate[4] = '\0'; 152 matrix_rate[4] = '\0';
165 matrix_rate[3] = '0' + n % 10; 153 matrix_rate[3] = '0' + n % 10;
166 matrix_rate[2] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 154 matrix_rate[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
167 matrix_rate[1] = n / 10 ? '0' + n / 10 : ' '; 155 matrix_rate[1] = n / 10 ? '0' + n / 10 : ' ';
168 matrix_rate[0] = ' '; 156 matrix_rate[0] = ' ';
169 oled_write_P(PSTR("MS:"), false); 157 oled_write_P(PSTR("MS:"), false);
170 oled_write(matrix_rate, false); 158 oled_write(matrix_rate, false);
@@ -284,6 +272,10 @@ void render_user_status(void) {
284 oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false); 272 oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
285 static const char PROGMEM nukem_good[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}}; 273 static const char PROGMEM nukem_good[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
286 oled_write_P(nukem_good[0], userspace_config.nuke_switch); 274 oled_write_P(nukem_good[0], userspace_config.nuke_switch);
275#if defined(UNICODE_ENABLE)
276 static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
277 oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false);
278#endif
287#if defined(OLED_DISPLAY_128X64) 279#if defined(OLED_DISPLAY_128X64)
288 oled_advance_page(true); 280 oled_advance_page(true);
289#endif 281#endif
@@ -306,34 +298,34 @@ void render_wpm(void) {
306 char wpm_counter[4]; 298 char wpm_counter[4];
307 wpm_counter[3] = '\0'; 299 wpm_counter[3] = '\0';
308 wpm_counter[2] = '0' + n % 10; 300 wpm_counter[2] = '0' + n % 10;
309 wpm_counter[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 301 wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
310 wpm_counter[0] = n / 10 ? '0' + n / 10 : ' '; 302 wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
311# else 303# else
312 char wpm_counter[6]; 304 char wpm_counter[6];
313 wpm_counter[5] = '\0'; 305 wpm_counter[5] = '\0';
314 wpm_counter[4] = '0' + n % 10; 306 wpm_counter[4] = '0' + n % 10;
315 wpm_counter[3] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 307 wpm_counter[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
316 wpm_counter[2] = n / 10 ? '0' + n / 10 : ' '; 308 wpm_counter[2] = n / 10 ? '0' + n / 10 : ' ';
317 wpm_counter[1] = ' '; 309 wpm_counter[1] = ' ';
318 wpm_counter[0] = ' '; 310 wpm_counter[0] = ' ';
319 # endif 311# endif
320 oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false); 312 oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
321 oled_write(wpm_counter, false); 313 oled_write(wpm_counter, false);
322#endif 314#endif
323} 315}
324 316
325#ifdef KEYBOARD_handwired_dactyl_manuform_5x6_right_trackball 317#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
326extern keyboard_config_t keyboard_config; 318extern keyboard_config_t keyboard_config;
327extern uint16_t dpi_array[]; 319extern uint16_t dpi_array[];
328 320
329void render_pointing_dpi_status(void) { 321void render_pointing_dpi_status(void) {
330 char dpi_status[6]; 322 char dpi_status[6];
331 uint16_t n = dpi_array[keyboard_config.dpi_config]; 323 uint16_t n = dpi_array[keyboard_config.dpi_config];
332 dpi_status[5] = '\0'; 324 dpi_status[5] = '\0';
333 dpi_status[4] = '0' + n % 10; 325 dpi_status[4] = '0' + n % 10;
334 dpi_status[3] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 326 dpi_status[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
335 dpi_status[2] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 327 dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
336 dpi_status[1] = n / 10 ? '0' + n / 10 : ' '; 328 dpi_status[1] = n / 10 ? '0' + n / 10 : ' ';
337 dpi_status[0] = ' '; 329 dpi_status[0] = ' ';
338 oled_write_P(PSTR(" DPI: "), false); 330 oled_write_P(PSTR(" DPI: "), false);
339 oled_write(dpi_status, false); 331 oled_write(dpi_status, false);
@@ -348,8 +340,8 @@ void render_status_secondary(void) {
348 render_default_layer_state(); 340 render_default_layer_state();
349 render_layer_state(); 341 render_layer_state();
350 render_mod_status(get_mods() | get_oneshot_mods()); 342 render_mod_status(get_mods() | get_oneshot_mods());
351 // render_keylogger_status(); 343
352 render_keylock_status(host_keyboard_leds()); 344 // render_keylock_status(host_keyboard_leds());
353} 345}
354 346
355void render_status_main(void) { 347void render_status_main(void) {
@@ -360,7 +352,7 @@ void render_status_main(void) {
360# else 352# else
361 render_wpm(); 353 render_wpm();
362# endif 354# endif
363# ifdef KEYBOARD_handwired_dactyl_manuform_5x6_right_trackball 355# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
364 render_pointing_dpi_status(); 356 render_pointing_dpi_status();
365# endif 357# endif
366 oled_write_P(PSTR("\n"), false); 358 oled_write_P(PSTR("\n"), false);
@@ -372,7 +364,16 @@ void render_status_main(void) {
372 render_bootmagic_status(); 364 render_bootmagic_status();
373 render_user_status(); 365 render_user_status();
374 366
375 render_keylogger_status(); 367 // render_keylogger_status();
368}
369
370__attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) { return rotation; }
371
372oled_rotation_t oled_init_user(oled_rotation_t rotation) {
373 for (uint8_t i = 0; i < (KEYLOGGER_LENGTH - 1); i++) {
374 add_keylog(0);
375 }
376 return oled_init_keymap(rotation);
376} 377}
377 378
378void oled_task_user(void) { 379void oled_task_user(void) {
@@ -385,8 +386,15 @@ void oled_task_user(void) {
385 } else { 386 } else {
386 oled_on(); 387 oled_on();
387 } 388 }
389 }
390 if (is_keyboard_left()) {
388 render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) 391 render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
389 } else { 392 } else {
390 render_status_secondary(); 393 render_status_secondary();
391 } 394 }
395 if (is_keyboard_master()) {
396 render_keylogger_status();
397 } else {
398 render_keylock_status(host_keyboard_leds());
399 }
392} 400}