oled_stuff.c 40 KB

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