oled_stuff.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  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. #include "drashna.h"
  17. #ifdef CUSTOM_UNICODE_ENABLE
  18. # include "process_unicode_common.h"
  19. #endif
  20. #include <string.h>
  21. extern bool host_driver_disabled;
  22. uint32_t oled_timer = 0;
  23. char keylog_str[OLED_KEYLOGGER_LENGTH] = {0};
  24. static uint16_t log_timer = 0;
  25. static const char PROGMEM display_border[3] = {0x0, 0xFF, 0x0};
  26. deferred_token kittoken;
  27. // clang-format off
  28. static const char PROGMEM code_to_name[256] = {
  29. // 0 1 2 3 4 5 6 7 8 9 A B c D E F
  30. ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x
  31. 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
  32. '3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
  33. ']','\\', '#', ';','\'', '`', ',', '.', '/', 128,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA, // 3x
  34. 0xDB,0xDC,0xDD,0xDE,0XDF,0xFB,'P', 'S', 19, ' ', 17, 30, 16, 16, 31, 26, // 4x
  35. 27, 25, 24, 'N', '/', '*', '-', '+', 23, '1', '2', '3', '4', '5', '6', '7', // 5x
  36. '8', '9', '0', '.','\\', 'A', 0, '=', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
  37. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
  38. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
  39. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
  40. ' ', ' ', ' ', ' ', ' ', 0, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
  41. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
  42. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
  43. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
  44. 'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 24, 26, 24, // Ex
  45. 25,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D, 24, 25, 27, 26, ' ', ' ', ' ' // Fx
  46. };
  47. // clang-format on
  48. /**
  49. * @brief parses pressed keycodes and saves to buffer
  50. *
  51. * @param keycode Keycode pressed from switch matrix
  52. * @param record keyrecord_t data structure
  53. */
  54. void add_keylog(uint16_t keycode, keyrecord_t *record) {
  55. if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
  56. if (((keycode & 0xFF) == KC_BSPC) && mod_config(get_mods() | get_oneshot_mods()) & MOD_MASK_CTRL) {
  57. memset(keylog_str, ' ', OLED_KEYLOGGER_LENGTH);
  58. return;
  59. }
  60. if (record->tap.count) {
  61. keycode &= 0xFF;
  62. } else if (keycode > 0xFF) {
  63. return;
  64. }
  65. }
  66. if (keycode > 0xFF) {
  67. return;
  68. }
  69. memmove(keylog_str, keylog_str + 1, OLED_KEYLOGGER_LENGTH - 1);
  70. if (keycode < (sizeof(code_to_name) / sizeof(char))) {
  71. keylog_str[(OLED_KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]);
  72. }
  73. log_timer = timer_read();
  74. }
  75. /**
  76. * @brief Keycode handler for oled display.
  77. *
  78. * This adds pressed keys to buffer, but also resets the oled timer
  79. *
  80. * @param keycode Keycode from matrix
  81. * @param record keyrecord data struture
  82. * @return true
  83. * @return false
  84. */
  85. bool process_record_user_oled(uint16_t keycode, keyrecord_t *record) {
  86. if (record->event.pressed) {
  87. oled_timer = timer_read32();
  88. add_keylog(keycode, record);
  89. }
  90. return true;
  91. }
  92. void update_log(void) {
  93. if (timer_elapsed(log_timer) > 750) {
  94. // add_keylog(0);
  95. }
  96. }
  97. /**
  98. * @brief Renders keylogger buffer to oled
  99. *
  100. */
  101. void render_keylogger_status(void) {
  102. #ifdef OLED_DISPLAY_VERBOSE
  103. oled_set_cursor(1, 7);
  104. #endif
  105. oled_write_P(PSTR(OLED_RENDER_KEYLOGGER), false);
  106. oled_write(keylog_str, false);
  107. #ifdef OLED_DISPLAY_VERBOSE
  108. oled_advance_page(true);
  109. #endif
  110. }
  111. /**
  112. * @brief Renders default layer state (aka layout) to oled
  113. *
  114. */
  115. void render_default_layer_state(void) {
  116. #ifdef OLED_DISPLAY_VERBOSE
  117. oled_set_cursor(5, 2);
  118. #endif
  119. oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false);
  120. switch (get_highest_layer(default_layer_state)) {
  121. case _QWERTY:
  122. oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false);
  123. break;
  124. case _COLEMAK_DH:
  125. oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK_DH), false);
  126. break;
  127. case _COLEMAK:
  128. oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false);
  129. break;
  130. case _DVORAK:
  131. oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false);
  132. break;
  133. }
  134. #ifdef OLED_DISPLAY_VERBOSE
  135. oled_advance_page(true);
  136. #endif
  137. }
  138. /**
  139. * @brief Renders the active layers to the OLED
  140. *
  141. */
  142. void render_layer_state(void) {
  143. #ifdef OLED_DISPLAY_VERBOSE
  144. static const char PROGMEM tri_layer_image[4][3][18] = {
  145. {
  146. {
  147. 0x80, 0x80, 0x40, 0x40, 0x20, 0x20,
  148. 0x10, 0x10, 0x08, 0x08, 0x10, 0x10,
  149. 0x20, 0x20, 0x40, 0x40, 0x80, 0x80
  150. },
  151. {
  152. 0x88, 0x88, 0x5D, 0x5D, 0x3E, 0x3E,
  153. 0x7C, 0x7C, 0xF8, 0xF8, 0x7C, 0x7C,
  154. 0x3E, 0x3E, 0x5D, 0x5D, 0x88, 0x88
  155. },
  156. {
  157. 0x00, 0x00, 0x01, 0x01, 0x02, 0x02,
  158. 0x04, 0x04, 0x08, 0x08, 0x04, 0x04,
  159. 0x02, 0x02, 0x01, 0x01, 0x00, 0x00
  160. }
  161. },
  162. {
  163. {
  164. 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0,
  165. 0xF0, 0xF0, 0xF8, 0xF8, 0xF0, 0xF0,
  166. 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80
  167. },
  168. {
  169. 0x88, 0x88, 0x55, 0x55, 0x23, 0x23,
  170. 0x47, 0x47, 0x8F, 0x8F, 0x47, 0x47,
  171. 0x23, 0x23, 0x55, 0x55, 0x88, 0x88
  172. },
  173. {
  174. 0x00, 0x00, 0x01, 0x01, 0x02, 0x02,
  175. 0x04, 0x04, 0x08, 0x08, 0x04, 0x04,
  176. 0x02, 0x02, 0x01, 0x01, 0x00, 0x00
  177. }
  178. },
  179. {
  180. {
  181. 0x80, 0x80, 0x40, 0x40, 0x20, 0x20,
  182. 0x10, 0x10, 0x08, 0x08, 0x10, 0x10,
  183. 0x20, 0x20, 0x40, 0x40, 0x80, 0x80
  184. },
  185. {
  186. 0x88, 0x88, 0xD5, 0xD5, 0xE2, 0xE2,
  187. 0xC4, 0xC4, 0x88, 0x88, 0xC4, 0xC4,
  188. 0xE2, 0xE2, 0xD5, 0xD5, 0x88, 0x88
  189. },
  190. {
  191. 0x00, 0x00, 0x01, 0x01, 0x03, 0x03,
  192. 0x07, 0x07, 0x0F, 0x0F, 0x07, 0x07,
  193. 0x03, 0x03, 0x01, 0x01, 0x00, 0x00
  194. }
  195. },
  196. {
  197. {
  198. 0x80, 0x80, 0x40, 0xC0, 0x60, 0xA0,
  199. 0x50, 0xB0, 0x58, 0xA8, 0x50, 0xB0,
  200. 0x60, 0xA0, 0x40, 0xC0, 0x80, 0x80
  201. },
  202. {
  203. 0x88, 0x88, 0x5D, 0xD5, 0x6B, 0xB6,
  204. 0x6D, 0xD6, 0xAD, 0xDA, 0x6D, 0xD6,
  205. 0x6B, 0xB6, 0x5D, 0xD5, 0x88, 0x88
  206. },
  207. {
  208. 0x00, 0x00, 0x01, 0x01, 0x03, 0x02,
  209. 0x05, 0x06, 0x0D, 0x0A, 0x05, 0x06,
  210. 0x03, 0x02, 0x01, 0x01, 0x00, 0x00
  211. }
  212. }
  213. };
  214. uint8_t layer_is = 0;
  215. if (layer_state_is(_ADJUST)) {
  216. layer_is = 3;
  217. } else if (layer_state_is(_RAISE)) {
  218. layer_is = 1;
  219. } else if (layer_state_is(_LOWER)) {
  220. layer_is = 2;
  221. }
  222. oled_set_cursor(1, 2);
  223. oled_write_raw_P(tri_layer_image[layer_is][0], sizeof(tri_layer_image[0][0]));
  224. oled_set_cursor(5, 3);
  225. oled_write_P(PSTR("Diablo2"), layer_state_is(_DIABLOII));
  226. oled_write_P(PSTR(" "), false);
  227. oled_write_P(PSTR("Diablo3"), layer_state_is(_DIABLO));
  228. oled_advance_page(true);
  229. oled_set_cursor(1, 3);
  230. oled_write_raw_P(tri_layer_image[layer_is][1], sizeof(tri_layer_image[0][0]));
  231. oled_set_cursor(5, 4);
  232. oled_write_P(PSTR("GamePad"), layer_state_is(_GAMEPAD));
  233. oled_write_P(PSTR(" "), false);
  234. oled_write_P(PSTR("Mouse"), layer_state_is(_MOUSE));
  235. oled_advance_page(true);
  236. oled_set_cursor(1, 4);
  237. oled_write_raw_P(tri_layer_image[layer_is][2], sizeof(tri_layer_image[0][0]));
  238. #else
  239. oled_write_P(PSTR(OLED_RENDER_LAYER_NAME), false);
  240. oled_write_P(PSTR(OLED_RENDER_LAYER_LOWER), layer_state_is(_LOWER));
  241. oled_write_P(PSTR(OLED_RENDER_LAYER_RAISE), layer_state_is(_RAISE));
  242. oled_advance_page(true);
  243. #endif
  244. }
  245. /**
  246. * @brief Renders the current lock status to oled
  247. *
  248. * @param led_usb_state Current keyboard led state
  249. */
  250. void render_keylock_status(uint8_t led_usb_state) {
  251. #if defined(OLED_DISPLAY_VERBOSE)
  252. oled_set_cursor(1, 6);
  253. #endif
  254. oled_write_P(PSTR(OLED_RENDER_LOCK_NAME), false);
  255. #if !defined(OLED_DISPLAY_VERBOSE)
  256. oled_write_P(PSTR(" "), false);
  257. #endif
  258. oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK));
  259. oled_write_P(PSTR(" "), false);
  260. oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
  261. #if defined(OLED_DISPLAY_VERBOSE)
  262. oled_write_P(PSTR(" "), false);
  263. oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
  264. #endif
  265. }
  266. /**
  267. * @brief Renders the matrix scan rate to the host system
  268. *
  269. */
  270. void render_matrix_scan_rate(void) {
  271. #ifdef DEBUG_MATRIX_SCAN_RATE
  272. oled_write_P(PSTR("MS:"), false);
  273. oled_write(get_u16_str(get_matrix_scan_rate(), ' '), false);
  274. #endif
  275. }
  276. /**
  277. * @brief Renders the modifier state
  278. *
  279. * @param modifiers Modifiers to check against (real, weak, onesheot, etc;)
  280. */
  281. void render_mod_status(uint8_t modifiers) {
  282. static const char PROGMEM mod_status[5][3] = {{0xE8, 0xE9, 0}, {0xE4, 0xE5, 0}, {0xE6, 0xE7, 0}, {0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
  283. #if defined(OLED_DISPLAY_VERBOSE)
  284. oled_set_cursor(1, 5);
  285. #endif
  286. oled_write_P(PSTR(OLED_RENDER_MODS_NAME), false);
  287. #if defined(OLED_DISPLAY_VERBOSE)
  288. oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_LSHIFT)));
  289. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_LGUI)));
  290. oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_LALT)));
  291. oled_write_P(mod_status[1], (modifiers & MOD_BIT(KC_LCTL)));
  292. oled_write_P(mod_status[1], (modifiers & MOD_BIT(KC_RCTL)));
  293. oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_RALT)));
  294. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_RGUI)));
  295. oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_RSHIFT)));
  296. #else
  297. oled_write_P(mod_status[0], (modifiers & MOD_MASK_SHIFT));
  298. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_MASK_GUI));
  299. oled_write_P(PSTR(" "), false);
  300. oled_write_P(mod_status[2], (modifiers & MOD_MASK_ALT));
  301. oled_write_P(mod_status[1], (modifiers & MOD_MASK_CTRL));
  302. #endif
  303. }
  304. #ifdef SWAP_HANDS_ENABLE
  305. extern bool swap_hands;
  306. #endif
  307. void render_bootmagic_status(void) {
  308. /* Show Ctrl-Gui Swap options */
  309. static const char PROGMEM logo[][2][3] = {
  310. {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
  311. {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
  312. };
  313. bool is_bootmagic_on;
  314. #ifdef OLED_DISPLAY_VERBOSE
  315. oled_set_cursor(7, 4);
  316. is_bootmagic_on = !keymap_config.swap_lctl_lgui;
  317. #else
  318. is_bootmagic_on = keymap_config.swap_lctl_lgui;
  319. #endif
  320. #ifdef OLED_DISPLAY_VERBOSE
  321. if (keymap_config.swap_lctl_lgui)
  322. #else
  323. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NAME), false);
  324. oled_write_P(PSTR(" "), false);
  325. #endif
  326. {
  327. oled_write_P(logo[1][0], is_bootmagic_on);
  328. #ifdef OLED_DISPLAY_VERBOSE
  329. } else {
  330. #endif
  331. oled_write_P(logo[0][0], !is_bootmagic_on);
  332. }
  333. #ifndef OLED_DISPLAY_VERBOSE
  334. oled_write_P(PSTR(" "), false);
  335. oled_write_P(logo[1][1], is_bootmagic_on);
  336. oled_write_P(logo[0][1], !is_bootmagic_on);
  337. #endif
  338. oled_write_P(PSTR(" "), false);
  339. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NKRO), keymap_config.nkro);
  340. oled_write_P(PSTR(" "), false);
  341. #ifdef AUTOCORRECTION_ENABLE
  342. oled_write_P(PSTR("CRCT"), userspace_config.autocorrection);
  343. #else
  344. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui);
  345. #endif
  346. #ifdef OLED_DISPLAY_VERBOSE
  347. oled_set_cursor(7, 5);
  348. if (keymap_config.swap_lctl_lgui) {
  349. oled_write_P(logo[1][1], is_bootmagic_on);
  350. } else {
  351. oled_write_P(logo[0][1], !is_bootmagic_on);
  352. }
  353. #endif
  354. oled_write_P(PSTR(" "), false);
  355. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_ONESHOT), !is_oneshot_enabled());
  356. #ifdef SWAP_HANDS_ENABLE
  357. oled_write_P(PSTR(" "), false);
  358. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands);
  359. #endif
  360. }
  361. #if defined(POINTING_DEVICE_ENABLE)
  362. extern bool tap_toggling;
  363. #endif
  364. void render_user_status(void) {
  365. #ifdef AUDIO_ENABLE
  366. bool is_audio_on = false, is_clicky_on = false;
  367. # ifdef SPLIT_KEYBOARD
  368. is_audio_on = user_state.audio_enable;
  369. is_clicky_on = user_state.audio_clicky_enable;
  370. # else
  371. is_audio_on = is_audio_on();
  372. is_clicky_on = is_clicky_on();
  373. # endif
  374. #endif
  375. #if defined(OLED_DISPLAY_VERBOSE)
  376. oled_set_cursor(1, 6);
  377. #endif
  378. oled_write_P(PSTR(OLED_RENDER_USER_NAME), false);
  379. #if !defined(OLED_DISPLAY_VERBOSE)
  380. oled_write_P(PSTR(" "), false);
  381. #endif
  382. #if defined(RGB_MATRIX_ENABLE)
  383. oled_write_P(PSTR(OLED_RENDER_USER_ANIM), userspace_config.rgb_matrix_idle_anim);
  384. # if !defined(OLED_DISPLAY_VERBOSE)
  385. oled_write_P(PSTR(" "), false);
  386. # endif
  387. #elif defined(POINTING_DEVICE_ENABLE)
  388. static const char PROGMEM mouse_lock[3] = {0xF2, 0xF3, 0};
  389. oled_write_P(mouse_lock, tap_toggling);
  390. #endif
  391. #ifdef AUDIO_ENABLE
  392. static const char PROGMEM audio_status[2][3] = {{0xE0, 0xE1, 0}, {0xE2, 0xE3, 0}};
  393. oled_write_P(audio_status[is_audio_on], false);
  394. # ifdef AUDIO_CLICKY
  395. static const char PROGMEM audio_clicky_status[2][3] = {{0xF4, 0xF5, 0}, {0xF6, 0xF7, 0}};
  396. oled_write_P(audio_clicky_status[is_clicky_on && is_audio_on], false);
  397. # if !defined(OLED_DISPLAY_VERBOSE)
  398. oled_write_P(PSTR(" "), false);
  399. # endif
  400. # endif
  401. #endif
  402. static const char PROGMEM rgb_layer_status[2][3] = {{0xEE, 0xEF, 0}, {0xF0, 0xF1, 0}};
  403. oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
  404. static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
  405. oled_write_P(cat_mode[0], host_driver_disabled);
  406. #if defined(CUSTOM_UNICODE_ENABLE)
  407. static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
  408. oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false);
  409. #endif
  410. if (userspace_config.nuke_switch) {
  411. #if !defined(OLED_DISPLAY_VERBOSE)
  412. oled_write_P(PSTR(" "), false);
  413. #endif
  414. static const char PROGMEM nukem_good[2] = {0xFA, 0};
  415. oled_write_P(nukem_good, false);
  416. #if !defined(OLED_DISPLAY_VERBOSE)
  417. oled_advance_page(true);
  418. #endif
  419. }
  420. #if defined(OLED_DISPLAY_VERBOSE)
  421. oled_advance_page(true);
  422. #endif
  423. }
  424. void render_wpm(uint8_t padding) {
  425. #ifdef WPM_ENABLE
  426. oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
  427. if (padding) {
  428. for (uint8_t n = padding; n > 0; n--) {
  429. oled_write_P(PSTR(" "), false);
  430. }
  431. }
  432. oled_write(get_u8_str(get_current_wpm(), ' '), false);
  433. #endif
  434. }
  435. #if defined(KEYBOARD_handwired_tractyl_manuform) || defined(KEYBOARD_bastardkb_charybdis)
  436. extern kb_config_data_t kb_config;
  437. void render_pointing_dpi_status(uint8_t padding) {
  438. oled_write_P(PSTR("CPI:"), false);
  439. if (padding) {
  440. for (uint8_t n = padding - 1; n > 0; n--) {
  441. oled_write_P(PSTR(" "), false);
  442. }
  443. }
  444. oled_write(get_u16_str(kb_config.device_cpi, ' '), false);
  445. }
  446. #endif
  447. __attribute__((weak)) void oled_driver_render_logo_right(void) {
  448. #if defined(OLED_DISPLAY_VERBOSE)
  449. oled_set_cursor(0, 2);
  450. render_default_layer_state();
  451. #else
  452. render_default_layer_state();
  453. #endif
  454. }
  455. // WPM-responsive animation stuff here
  456. #define OLED_SLEEP_FRAMES 2
  457. #define OLED_SLEEP_SPEED 10 // below this wpm value your animation will idle
  458. #define OLED_WAKE_FRAMES 2 // uncomment if >1
  459. #define OLED_WAKE_SPEED OLED_SLEEP_SPEED // below this wpm value your animation will idle
  460. #define OLED_KAKI_FRAMES 3
  461. #define OLED_KAKI_SPEED 40 // above this wpm value typing animation to triggere
  462. #define OLED_RTOGI_FRAMES 2
  463. //#define OLED_LTOGI_FRAMES 2
  464. //#define ANIM_FRAME_DURATION 500 // how long each frame lasts in ms
  465. // #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing
  466. #define OLED_ANIM_SIZE 32 // number of bytes in array, minimize for adequate firmware size, max is 1024
  467. #define OLED_ANIM_ROWS 4
  468. #define OLED_ANIM_MAX_FRAMES 3
  469. #if (OLED_SLEEP_FRAMES > OLED_ANIM_MAX_FRAMES) || (OLED_WAKE_FRAMES > OLED_ANIM_MAX_FRAMES) || (OLED_KAKI_FRAMES > OLED_ANIM_MAX_FRAMES) || (OLED_RTOGI_FRAMES > OLED_ANIM_MAX_FRAMES)
  470. # error frame size too large
  471. #endif
  472. static uint8_t animation_frame = 0;
  473. static uint8_t animation_type = 0;
  474. void render_kitty(void) {
  475. // Images credit j-inc(/James Incandenza) and pixelbenny.
  476. // Credit to obosob for initial animation approach.
  477. // heavily modified by drashna because he's a glutton for punishment
  478. // clang-format off
  479. static const char PROGMEM animation[4][OLED_ANIM_MAX_FRAMES][OLED_ANIM_ROWS][OLED_ANIM_SIZE] = {
  480. // sleep frames
  481. {
  482. {
  483. {
  484. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08,
  485. 0xa8, 0x48, 0xa8, 0x18, 0x08, 0x00, 0x00, 0x00,
  486. 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
  487. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  488. },
  489. {
  490. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03,
  491. 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x80,
  492. 0x44, 0x84, 0x06, 0x05, 0x04, 0x80, 0x40, 0x20,
  493. 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  494. },
  495. {
  496. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20,
  497. 0x18, 0x04, 0x04, 0x02, 0x7a, 0x86, 0x01, 0x80,
  498. 0x80, 0x01, 0x03, 0x05, 0x07, 0x01, 0x00, 0x00,
  499. 0x80, 0x83, 0x45, 0xfa, 0x3c, 0xe0, 0x00, 0x00
  500. },
  501. {
  502. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x08,
  503. 0x10, 0x10, 0x10, 0x10, 0x10, 0x33, 0x24, 0x28,
  504. 0x28, 0x29, 0x29, 0x29, 0x3a, 0x18, 0x1c, 0x39,
  505. 0x24, 0x24, 0x3a, 0x2d, 0x26, 0x31, 0x1f, 0x00
  506. }
  507. },
  508. {
  509. {
  510. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  511. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  512. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  513. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  514. },
  515. {
  516. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  517. 0x22, 0x22, 0x3a, 0x2a, 0x26, 0x22, 0x80, 0xc0,
  518. 0x80, 0x00, 0x24, 0x34, 0x2c, 0xe4, 0x60, 0x10,
  519. 0x70, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  520. },
  521. {
  522. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x38,
  523. 0x04, 0x02, 0x02, 0x01, 0x79, 0x87, 0x01, 0x80,
  524. 0x81, 0x83, 0x05, 0x05, 0x03, 0x01, 0x00, 0x00,
  525. 0x80, 0x43, 0x05, 0xfa, 0x3c, 0xe0, 0x00, 0x00
  526. },
  527. {
  528. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x08,
  529. 0x10, 0x10, 0x10, 0x10, 0x10, 0x33, 0x24, 0x28,
  530. 0x28, 0x28, 0x29, 0x29, 0x3a, 0x18, 0x1c, 0x39,
  531. 0x24, 0x24, 0x3a, 0x2d, 0x26, 0x31, 0x1f, 0x00
  532. }
  533. }
  534. },
  535. // wake frames
  536. {
  537. {
  538. {
  539. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  540. 0x00, 0x00, 0xc0, 0x30, 0x08, 0x10, 0x60, 0x80,
  541. 0x00, 0x80, 0x60, 0x10, 0x08, 0x30, 0xc0, 0x00,
  542. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  543. },
  544. {
  545. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  546. 0x00, 0x7f, 0x80, 0x40, 0x40, 0x5c, 0x00, 0x01,
  547. 0x41, 0x01, 0x00, 0x5c, 0x40, 0x40, 0x80, 0x7f,
  548. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  549. },
  550. {
  551. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  552. 0x40, 0x40, 0x80, 0xe1, 0x12, 0x0a, 0x06, 0x00,
  553. 0x80, 0x00, 0x06, 0x0a, 0x12, 0xe1, 0x80, 0x40,
  554. 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  555. },
  556. {
  557. 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1f, 0x14,
  558. 0x14, 0x10, 0x10, 0x11, 0x1f, 0x10, 0x10, 0x18,
  559. 0x0f, 0x18, 0x10, 0x10, 0x1f, 0x11, 0x10, 0x10,
  560. 0x14, 0x14, 0x1f, 0x1c, 0x14, 0x14, 0x14, 0x08
  561. }
  562. },
  563. {
  564. {
  565. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  566. 0x00, 0x00, 0xc0, 0x30, 0x08, 0x10, 0x60, 0x80,
  567. 0x00, 0x80, 0x60, 0x10, 0x08, 0x30, 0xc0, 0x00,
  568. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  569. },
  570. {
  571. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  572. 0x00, 0x7f, 0x90, 0x12, 0x0a, 0x02, 0xf4, 0x09,
  573. 0x0d, 0xf1, 0x04, 0x02, 0x0a, 0x12, 0x90, 0x7f,
  574. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  575. },
  576. {
  577. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  578. 0x40, 0x40, 0x80, 0xe1, 0x12, 0x0a, 0x06, 0x01,
  579. 0x81, 0x00, 0x06, 0x0a, 0x12, 0xe1, 0x80, 0x40,
  580. 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  581. },
  582. {
  583. 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1f, 0x14,
  584. 0x14, 0x10, 0x10, 0x11, 0x1f, 0x10, 0x10, 0x18,
  585. 0x0f, 0x18, 0x10, 0x10, 0x1f, 0x11, 0x10, 0x10,
  586. 0x14, 0x14, 0x1f, 0x1c, 0x14, 0x14, 0x14, 0x08
  587. }
  588. }
  589. },
  590. // kaki frames
  591. {
  592. {
  593. {
  594. 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0x40,
  595. 0x80, 0x80, 0x80, 0x00, 0xfc, 0x84, 0x08, 0x08,
  596. 0x10, 0x20, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00,
  597. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  598. },
  599. {
  600. 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1e, 0x60,
  601. 0x80, 0x00, 0x00, 0x91, 0xa1, 0x80, 0x00, 0x00,
  602. 0x22, 0x84, 0x40, 0x50, 0x48, 0xc1, 0x3e, 0x00,
  603. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  604. },
  605. {
  606. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  607. 0x40, 0x41, 0x82, 0xe2, 0x12, 0x0a, 0x06, 0x00,
  608. 0x80, 0x88, 0x4f, 0x02, 0x22, 0xe2, 0x9f, 0x40,
  609. 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  610. },
  611. {
  612. 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1f, 0x14,
  613. 0x14, 0x10, 0x10, 0x11, 0x1f, 0x10, 0x10, 0x18,
  614. 0x0f, 0x18, 0x14, 0x10, 0x10, 0x10, 0x10, 0x10,
  615. 0x14, 0x14, 0x1f, 0x1a, 0x0a, 0x0a, 0x04, 0x00
  616. }
  617. },
  618. {
  619. {
  620. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  621. 0x00, 0xf0, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80,
  622. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  623. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  624. },
  625. {
  626. 0x00, 0x00, 0x06, 0x1a, 0x22, 0xc2, 0x04, 0x04,
  627. 0x04, 0x07, 0x00, 0xc0, 0x20, 0x10, 0x80, 0x80,
  628. 0x01, 0x01, 0x02, 0xfc, 0xfe, 0x02, 0x3c, 0x20,
  629. 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  630. },
  631. {
  632. 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0d, 0x8d,
  633. 0x55, 0x50, 0x94, 0xf0, 0x10, 0x09, 0x08, 0x00,
  634. 0x80, 0x00, 0x06, 0x09, 0x1b, 0xee, 0x00, 0x00,
  635. 0x00, 0x00, 0x81, 0xfe, 0x00, 0x00, 0x00, 0x00
  636. },
  637. {
  638. 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1f, 0x14,
  639. 0x14, 0x10, 0x10, 0x11, 0x1f, 0x10, 0x10, 0x18,
  640. 0x0f, 0x18, 0x10, 0x10, 0x1f, 0x19, 0x18, 0x1c,
  641. 0x14, 0x16, 0x15, 0x14, 0x14, 0x14, 0x14, 0x08
  642. }
  643. },
  644. {
  645. {
  646. 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x80, 0x00,
  647. 0x00, 0x00, 0x00, 0x00, 0xe0, 0x10, 0x20, 0x40,
  648. 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  649. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  650. },
  651. {
  652. 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x01,
  653. 0x02, 0x04, 0x04, 0x03, 0x80, 0x40, 0x40, 0x20,
  654. 0x00, 0x01, 0x02, 0x8c, 0x70, 0x00, 0x00, 0x00,
  655. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  656. },
  657. {
  658. 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0d, 0x8d,
  659. 0x55, 0x50, 0x94, 0xf0, 0x10, 0x0a, 0x0e, 0x1d,
  660. 0x95, 0x24, 0x24, 0x27, 0x13, 0xe1, 0x01, 0x01,
  661. 0x01, 0x01, 0x02, 0xfc, 0x00, 0x00, 0x00, 0x00
  662. },
  663. {
  664. 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1f, 0x14,
  665. 0x14, 0x10, 0x10, 0x11, 0x1f, 0x10, 0x10, 0x18,
  666. 0x0f, 0x18, 0x10, 0x10, 0x1f, 0x19, 0x18, 0x1c,
  667. 0x14, 0x14, 0x17, 0x14, 0x14, 0x14, 0x14, 0x08
  668. }
  669. }
  670. },
  671. // rtogi frames
  672. {
  673. {
  674. {
  675. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  676. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  677. 0x00, 0xc0, 0x20, 0x10, 0x10, 0x08, 0x04, 0x02,
  678. 0x01, 0x0f, 0x90, 0x10, 0x20, 0xf0, 0xf8, 0xf8
  679. },
  680. {
  681. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  682. 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08,
  683. 0x48, 0x47, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00,
  684. 0x08, 0x88, 0xc7, 0xc4, 0x62, 0x23, 0x11, 0x3f
  685. },
  686. {
  687. 0x80, 0x40, 0x20, 0x10, 0x88, 0xcc, 0x43, 0x80,
  688. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xc0,
  689. 0x80, 0x80, 0xc0, 0xe1, 0xfe, 0xb8, 0x88, 0x0c,
  690. 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  691. },
  692. {
  693. 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
  694. 0x01, 0x01, 0x01, 0x06, 0x04, 0x04, 0x04, 0x04,
  695. 0x05, 0x04, 0x04, 0x04, 0x07, 0x07, 0x07, 0x03,
  696. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  697. }
  698. },
  699. {
  700. {
  701. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  702. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  703. 0x00, 0xc0, 0x20, 0x10, 0x10, 0x08, 0x04, 0x02,
  704. 0x01, 0x1f, 0xa0, 0x20, 0x40, 0x80, 0x00, 0xf0
  705. },
  706. {
  707. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  708. 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08,
  709. 0x48, 0x47, 0x88, 0x00, 0x00, 0x00, 0x00, 0x24,
  710. 0x24, 0x28, 0x6b, 0x40, 0xa0, 0x99, 0x86, 0xff
  711. },
  712. {
  713. 0x0f, 0x11, 0x22, 0x44, 0x48, 0x4c, 0x43, 0x80,
  714. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xc0,
  715. 0x80, 0x80, 0xc0, 0xe1, 0xfe, 0xb8, 0x88, 0x0c,
  716. 0x04, 0x06, 0x06, 0x06, 0x0e, 0x0e, 0x06, 0x01
  717. },
  718. {
  719. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  720. 0x01, 0x01, 0x01, 0x06, 0x04, 0x04, 0x04, 0x04,
  721. 0x05, 0x04, 0x04, 0x04, 0x07, 0x07, 0x07, 0x03,
  722. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  723. }
  724. }
  725. }
  726. };
  727. // clang-format on
  728. for (uint8_t i = 0; i < 4; i++) {
  729. oled_set_cursor(1, i + 2);
  730. oled_write_raw_P(animation[animation_type][animation_frame][i], OLED_ANIM_SIZE);
  731. }
  732. }
  733. uint32_t kitty_animation_phases(uint32_t triger_time, void *cb_arg) {
  734. uint32_t anim_frame_duration = 500;
  735. // can't change animation frame duration here, otherwise, it gets stuck.
  736. // weirdly, it seems to work fine if it's in keymap.c but not here.
  737. // Should move this block to the deferred execution?
  738. #ifdef POINTING_DEVICE_ENABLE
  739. if (tap_toggling) {
  740. animation_frame = (animation_frame + 1) % OLED_RTOGI_FRAMES;
  741. animation_type = 3;
  742. anim_frame_duration = 300;
  743. } else
  744. #endif
  745. {
  746. if (get_current_wpm() <= OLED_SLEEP_SPEED) {
  747. animation_frame = (animation_frame + 1) % OLED_SLEEP_FRAMES;
  748. animation_type = 0;
  749. anim_frame_duration = 500;
  750. } else if (get_current_wpm() > OLED_WAKE_SPEED) {
  751. animation_frame = (animation_frame + 1) % OLED_WAKE_FRAMES;
  752. animation_type = 1;
  753. anim_frame_duration = 800;
  754. } else if (get_current_wpm() >= OLED_KAKI_SPEED) {
  755. animation_frame = (animation_frame + 1) % OLED_KAKI_FRAMES;
  756. animation_type = 2;
  757. anim_frame_duration = 500;
  758. }
  759. }
  760. return anim_frame_duration;
  761. }
  762. void oled_driver_render_logo_left(void) {
  763. #if defined(OLED_DISPLAY_VERBOSE)
  764. oled_set_cursor(0, 2);
  765. render_kitty();
  766. # if defined(KEYBOARD_handwired_tractyl_manuform)
  767. oled_set_cursor(7, 0);
  768. oled_write_P(PSTR("Tractyl"), true);
  769. # elif defined(KEYBOARD_bastardkb_charybdis)
  770. oled_set_cursor(6, 0);
  771. oled_write_P(PSTR("Charybdis"), true);
  772. # else
  773. oled_set_cursor(8, 0);
  774. oled_write_P(PSTR("Left"), true);
  775. # endif
  776. oled_set_cursor(7, 2);
  777. # if defined(DEBUG_MATRIX_SCAN_RATE)
  778. render_matrix_scan_rate();
  779. # elif defined(WPM_ENABLE)
  780. render_wpm(1);
  781. # endif
  782. oled_set_cursor(7, 3);
  783. # if defined(KEYBOARD_handwired_tractyl_manuform)
  784. render_pointing_dpi_status(0);
  785. # elif defined(KEYBOARD_bastardkb_charybdis)
  786. render_pointing_dpi_status(1);
  787. # endif
  788. oled_set_cursor(0, 6);
  789. #else
  790. render_default_layer_state();
  791. #endif
  792. }
  793. void render_status_secondary(void) {
  794. # if defined(KEYBOARD_handwired_tractyl_manuform)
  795. oled_set_cursor(7, 0);
  796. oled_write_P(PSTR("Manuform"), true);
  797. # elif defined(KEYBOARD_bastardkb_charybdis)
  798. oled_set_cursor(6, 0);
  799. oled_write_P(PSTR("Charybdis"), true);
  800. # else
  801. oled_set_cursor(8, 0);
  802. oled_write_P(PSTR("Right"), true);
  803. # endif
  804. oled_driver_render_logo_right();
  805. /* Show Keyboard Layout */
  806. render_layer_state();
  807. render_mod_status(get_mods() | get_oneshot_mods());
  808. #if !defined(OLED_DISPLAY_VERBOSE) && defined(WPM_ENABLE) && !defined(CONVERT_TO_PROTON_C)
  809. render_wpm(2);
  810. #endif
  811. render_keylock_status(host_keyboard_leds());
  812. }
  813. void render_status_main(void) {
  814. oled_driver_render_logo_left();
  815. /* Show Keyboard Layout */
  816. render_bootmagic_status();
  817. render_user_status();
  818. // render_keylogger_status();
  819. }
  820. __attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) { return rotation; }
  821. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  822. if (is_keyboard_master()) {
  823. memset(keylog_str, ' ', OLED_KEYLOGGER_LENGTH);
  824. }
  825. kittoken = defer_exec(3000, kitty_animation_phases, NULL);
  826. oled_clear();
  827. oled_render();
  828. return oled_init_keymap(rotation);
  829. }
  830. bool oled_task_user(void) {
  831. update_log();
  832. if (is_keyboard_master()) {
  833. #ifndef OLED_DISPLAY_TEST
  834. if (timer_elapsed32(oled_timer) > 30000) {
  835. oled_off();
  836. return false;
  837. } else
  838. #endif
  839. {
  840. oled_on();
  841. }
  842. }
  843. #if defined(OLED_DISPLAY_VERBOSE)
  844. static const char PROGMEM header_image[] = {
  845. 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,
  846. 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
  847. };
  848. static const char PROGMEM footer_image[] = {
  849. 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
  850. };
  851. oled_write_raw_P(header_image, sizeof(header_image));
  852. oled_set_cursor(0, 1);
  853. #endif
  854. #ifndef OLED_DISPLAY_TEST
  855. if (is_keyboard_left()) {
  856. #endif
  857. render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
  858. #ifndef OLED_DISPLAY_TEST
  859. } else {
  860. render_status_secondary();
  861. }
  862. #endif
  863. #if defined(OLED_DISPLAY_128X128)
  864. if (is_keyboard_left()) {
  865. render_keylogger_status();
  866. }
  867. #endif
  868. #if defined(OLED_DISPLAY_VERBOSE)
  869. uint8_t num_of_rows;
  870. # if defined(OLED_DISPLAY_128X128)
  871. num_of_rows = 15;
  872. # else
  873. num_of_rows = 7;
  874. # endif
  875. for (uint8_t i= 1; i < num_of_rows; i++) {
  876. oled_set_cursor(0, i);
  877. oled_write_raw_P(display_border, sizeof(display_border));
  878. oled_set_cursor(21, i);
  879. oled_write_raw_P(display_border, sizeof(display_border));
  880. }
  881. oled_set_cursor(0, num_of_rows);
  882. oled_write_raw_P(footer_image, sizeof(footer_image));
  883. #endif
  884. return false;
  885. }