diff options
Diffstat (limited to 'users/drashna/oled_stuff.c')
-rw-r--r-- | users/drashna/oled_stuff.c | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/users/drashna/oled_stuff.c b/users/drashna/oled_stuff.c index 98e467d930..253c5181ee 100644 --- a/users/drashna/oled_stuff.c +++ b/users/drashna/oled_stuff.c @@ -25,7 +25,7 @@ #endif uint32_t oled_timer = 0; -static char keylog_str[KEYLOGGER_LENGTH + 1] = {"\n"}; +static char keylog_str[KEYLOGGER_LENGTH + 1] = { 0 }; static uint16_t log_timer = 0; // clang-format off @@ -57,12 +57,12 @@ void add_keylog(uint16_t keycode) { keycode = 0; } - for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) { - keylog_str[i] = keylog_str[i - 1]; + for (uint8_t i = 1; i < KEYLOGGER_LENGTH; i++) { + keylog_str[i-1] = keylog_str[i]; } if (keycode < (sizeof(code_to_name) / sizeof(char))) { - keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); + keylog_str[(KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]); } log_timer = timer_read(); @@ -92,30 +92,14 @@ void render_keylogger_status(void) { void render_default_layer_state(void) { oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false); switch (get_highest_layer(default_layer_state)) { - case _QWERTY: - oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false); - break; - case _COLEMAK: - oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false); - break; - case _DVORAK: - oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false); - break; - case _WORKMAN: - oled_write_P(PSTR(OLED_RENDER_LAYOUT_WORKMAN), false); - break; - case _NORMAN: - oled_write_P(PSTR(OLED_RENDER_LAYOUT_NORMAN), false); - break; - case _MALTRON: - oled_write_P(PSTR(OLED_RENDER_LAYOUT_MALTRON), false); - break; - case _EUCALYN: - oled_write_P(PSTR(OLED_RENDER_LAYOUT_EUCALYN), false); - break; - case _CARPLAX: - oled_write_P(PSTR(OLED_RENDER_LAYOUT_CARPLAX), false); - break; + case _QWERTY: oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false); break; + case _COLEMAK: oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false); break; + case _DVORAK: oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false); break; + case _WORKMAN: oled_write_P(PSTR(OLED_RENDER_LAYOUT_WORKMAN), false); break; + case _NORMAN: oled_write_P(PSTR(OLED_RENDER_LAYOUT_NORMAN), false); break; + case _MALTRON: oled_write_P(PSTR(OLED_RENDER_LAYOUT_MALTRON), false); break; + case _EUCALYN: oled_write_P(PSTR(OLED_RENDER_LAYOUT_EUCALYN), false); break; + case _CARPLAX: oled_write_P(PSTR(OLED_RENDER_LAYOUT_CARPLAX), false); break; } #ifdef OLED_DISPLAY_128X64 oled_advance_page(true); @@ -159,12 +143,12 @@ void render_keylock_status(uint8_t led_usb_state) { } void render_matrix_scan_rate(void) { #ifdef DEBUG_MATRIX_SCAN_RATE - char matrix_rate[5]; - uint16_t n = get_matrix_scan_rate(); + char matrix_rate[5]; + uint16_t n = get_matrix_scan_rate(); matrix_rate[4] = '\0'; matrix_rate[3] = '0' + n % 10; - matrix_rate[2] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; - matrix_rate[1] = n / 10 ? '0' + n / 10 : ' '; + matrix_rate[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + matrix_rate[1] = n / 10 ? '0' + n / 10 : ' '; matrix_rate[0] = ' '; oled_write_P(PSTR("MS:"), false); oled_write(matrix_rate, false); @@ -284,6 +268,10 @@ void render_user_status(void) { oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false); static const char PROGMEM nukem_good[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}}; oled_write_P(nukem_good[0], userspace_config.nuke_switch); +#if defined(UNICODE_ENABLE) + static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}}; + oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false); +#endif #if defined(OLED_DISPLAY_128X64) oled_advance_page(true); #endif @@ -306,34 +294,34 @@ void render_wpm(void) { char wpm_counter[4]; wpm_counter[3] = '\0'; wpm_counter[2] = '0' + n % 10; - wpm_counter[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; wpm_counter[0] = n / 10 ? '0' + n / 10 : ' '; # else char wpm_counter[6]; wpm_counter[5] = '\0'; wpm_counter[4] = '0' + n % 10; - wpm_counter[3] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + wpm_counter[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; wpm_counter[2] = n / 10 ? '0' + n / 10 : ' '; wpm_counter[1] = ' '; wpm_counter[0] = ' '; - # endif +# endif oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false); oled_write(wpm_counter, false); #endif } -#ifdef KEYBOARD_handwired_dactyl_manuform_5x6_right_trackball +#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right) extern keyboard_config_t keyboard_config; extern uint16_t dpi_array[]; void render_pointing_dpi_status(void) { - char dpi_status[6]; - uint16_t n = dpi_array[keyboard_config.dpi_config]; + char dpi_status[6]; + uint16_t n = dpi_array[keyboard_config.dpi_config]; dpi_status[5] = '\0'; dpi_status[4] = '0' + n % 10; - dpi_status[3] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; - dpi_status[2] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; - dpi_status[1] = n / 10 ? '0' + n / 10 : ' '; + dpi_status[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + dpi_status[1] = n / 10 ? '0' + n / 10 : ' '; dpi_status[0] = ' '; oled_write_P(PSTR(" DPI: "), false); oled_write(dpi_status, false); @@ -360,7 +348,7 @@ void render_status_main(void) { # else render_wpm(); # endif -# ifdef KEYBOARD_handwired_dactyl_manuform_5x6_right_trackball +# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right) render_pointing_dpi_status(); # endif oled_write_P(PSTR("\n"), false); @@ -375,6 +363,15 @@ void render_status_main(void) { render_keylogger_status(); } +__attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) { return rotation; } + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + for (uint8_t i = 0; i < (KEYLOGGER_LENGTH - 1); i++) { + add_keylog(0); + } + return oled_init_keymap(rotation); +} + void oled_task_user(void) { update_log(); @@ -385,7 +382,7 @@ void oled_task_user(void) { } else { oled_on(); } - render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) + render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) } else { render_status_secondary(); } |