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.c83
1 files changed, 40 insertions, 43 deletions
diff --git a/users/drashna/oled_stuff.c b/users/drashna/oled_stuff.c
index 98e467d93..253c5181e 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();
@@ -92,30 +92,14 @@ void render_keylogger_status(void) {
92void render_default_layer_state(void) { 92void render_default_layer_state(void) {
93 oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false); 93 oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false);
94 switch (get_highest_layer(default_layer_state)) { 94 switch (get_highest_layer(default_layer_state)) {
95 case _QWERTY: 95 case _QWERTY: oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false); break;
96 oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false); 96 case _COLEMAK: oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false); break;
97 break; 97 case _DVORAK: oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false); break;
98 case _COLEMAK: 98 case _WORKMAN: oled_write_P(PSTR(OLED_RENDER_LAYOUT_WORKMAN), false); break;
99 oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false); 99 case _NORMAN: oled_write_P(PSTR(OLED_RENDER_LAYOUT_NORMAN), false); break;
100 break; 100 case _MALTRON: oled_write_P(PSTR(OLED_RENDER_LAYOUT_MALTRON), false); break;
101 case _DVORAK: 101 case _EUCALYN: oled_write_P(PSTR(OLED_RENDER_LAYOUT_EUCALYN), false); break;
102 oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false); 102 case _CARPLAX: oled_write_P(PSTR(OLED_RENDER_LAYOUT_CARPLAX), false); break;
103 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 } 103 }
120#ifdef OLED_DISPLAY_128X64 104#ifdef OLED_DISPLAY_128X64
121 oled_advance_page(true); 105 oled_advance_page(true);
@@ -159,12 +143,12 @@ void render_keylock_status(uint8_t led_usb_state) {
159} 143}
160void render_matrix_scan_rate(void) { 144void render_matrix_scan_rate(void) {
161#ifdef DEBUG_MATRIX_SCAN_RATE 145#ifdef DEBUG_MATRIX_SCAN_RATE
162 char matrix_rate[5]; 146 char matrix_rate[5];
163 uint16_t n = get_matrix_scan_rate(); 147 uint16_t n = get_matrix_scan_rate();
164 matrix_rate[4] = '\0'; 148 matrix_rate[4] = '\0';
165 matrix_rate[3] = '0' + n % 10; 149 matrix_rate[3] = '0' + n % 10;
166 matrix_rate[2] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 150 matrix_rate[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
167 matrix_rate[1] = n / 10 ? '0' + n / 10 : ' '; 151 matrix_rate[1] = n / 10 ? '0' + n / 10 : ' ';
168 matrix_rate[0] = ' '; 152 matrix_rate[0] = ' ';
169 oled_write_P(PSTR("MS:"), false); 153 oled_write_P(PSTR("MS:"), false);
170 oled_write(matrix_rate, false); 154 oled_write(matrix_rate, false);
@@ -284,6 +268,10 @@ void render_user_status(void) {
284 oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false); 268 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}}; 269 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); 270 oled_write_P(nukem_good[0], userspace_config.nuke_switch);
271#if defined(UNICODE_ENABLE)
272 static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
273 oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false);
274#endif
287#if defined(OLED_DISPLAY_128X64) 275#if defined(OLED_DISPLAY_128X64)
288 oled_advance_page(true); 276 oled_advance_page(true);
289#endif 277#endif
@@ -306,34 +294,34 @@ void render_wpm(void) {
306 char wpm_counter[4]; 294 char wpm_counter[4];
307 wpm_counter[3] = '\0'; 295 wpm_counter[3] = '\0';
308 wpm_counter[2] = '0' + n % 10; 296 wpm_counter[2] = '0' + n % 10;
309 wpm_counter[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 297 wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
310 wpm_counter[0] = n / 10 ? '0' + n / 10 : ' '; 298 wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
311# else 299# else
312 char wpm_counter[6]; 300 char wpm_counter[6];
313 wpm_counter[5] = '\0'; 301 wpm_counter[5] = '\0';
314 wpm_counter[4] = '0' + n % 10; 302 wpm_counter[4] = '0' + n % 10;
315 wpm_counter[3] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 303 wpm_counter[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
316 wpm_counter[2] = n / 10 ? '0' + n / 10 : ' '; 304 wpm_counter[2] = n / 10 ? '0' + n / 10 : ' ';
317 wpm_counter[1] = ' '; 305 wpm_counter[1] = ' ';
318 wpm_counter[0] = ' '; 306 wpm_counter[0] = ' ';
319 # endif 307# endif
320 oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false); 308 oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
321 oled_write(wpm_counter, false); 309 oled_write(wpm_counter, false);
322#endif 310#endif
323} 311}
324 312
325#ifdef KEYBOARD_handwired_dactyl_manuform_5x6_right_trackball 313#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
326extern keyboard_config_t keyboard_config; 314extern keyboard_config_t keyboard_config;
327extern uint16_t dpi_array[]; 315extern uint16_t dpi_array[];
328 316
329void render_pointing_dpi_status(void) { 317void render_pointing_dpi_status(void) {
330 char dpi_status[6]; 318 char dpi_status[6];
331 uint16_t n = dpi_array[keyboard_config.dpi_config]; 319 uint16_t n = dpi_array[keyboard_config.dpi_config];
332 dpi_status[5] = '\0'; 320 dpi_status[5] = '\0';
333 dpi_status[4] = '0' + n % 10; 321 dpi_status[4] = '0' + n % 10;
334 dpi_status[3] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 322 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' : ' '; 323 dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
336 dpi_status[1] = n / 10 ? '0' + n / 10 : ' '; 324 dpi_status[1] = n / 10 ? '0' + n / 10 : ' ';
337 dpi_status[0] = ' '; 325 dpi_status[0] = ' ';
338 oled_write_P(PSTR(" DPI: "), false); 326 oled_write_P(PSTR(" DPI: "), false);
339 oled_write(dpi_status, false); 327 oled_write(dpi_status, false);
@@ -360,7 +348,7 @@ void render_status_main(void) {
360# else 348# else
361 render_wpm(); 349 render_wpm();
362# endif 350# endif
363# ifdef KEYBOARD_handwired_dactyl_manuform_5x6_right_trackball 351# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
364 render_pointing_dpi_status(); 352 render_pointing_dpi_status();
365# endif 353# endif
366 oled_write_P(PSTR("\n"), false); 354 oled_write_P(PSTR("\n"), false);
@@ -375,6 +363,15 @@ void render_status_main(void) {
375 render_keylogger_status(); 363 render_keylogger_status();
376} 364}
377 365
366__attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) { return rotation; }
367
368oled_rotation_t oled_init_user(oled_rotation_t rotation) {
369 for (uint8_t i = 0; i < (KEYLOGGER_LENGTH - 1); i++) {
370 add_keylog(0);
371 }
372 return oled_init_keymap(rotation);
373}
374
378void oled_task_user(void) { 375void oled_task_user(void) {
379 update_log(); 376 update_log();
380 377
@@ -385,7 +382,7 @@ void oled_task_user(void) {
385 } else { 382 } else {
386 oled_on(); 383 oled_on();
387 } 384 }
388 render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) 385 render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
389 } else { 386 } else {
390 render_status_secondary(); 387 render_status_secondary();
391 } 388 }