oled_stuff.c 40 KB

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