oled_stuff.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  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. 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(uint8_t col, uint8_t line) {
  110. #ifdef OLED_DISPLAY_VERBOSE
  111. oled_set_cursor(col, line);
  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(uint8_t col, uint8_t line) {
  124. #ifdef OLED_DISPLAY_VERBOSE
  125. oled_set_cursor(col, line);
  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(uint8_t col, uint8_t line) {
  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(col, line);
  273. oled_write_raw_P(tri_layer_image[layer_is[0]][0], sizeof(tri_layer_image[0][0]));
  274. oled_set_cursor(col + 4, line);
  275. oled_write_raw_P(tri_layer_image[layer_is[1]][0], sizeof(tri_layer_image[0][0]));
  276. oled_set_cursor(col + 8, line);
  277. oled_write_raw_P(tri_layer_image[layer_is[2]][0], sizeof(tri_layer_image[0][0]));
  278. oled_set_cursor(col + 13, line);
  279. oled_write_P(PSTR("Diablo2"), layer_state_is(_DIABLOII));
  280. oled_advance_page(true);
  281. oled_set_cursor(col, line + 1);
  282. oled_write_raw_P(tri_layer_image[layer_is[0]][1], sizeof(tri_layer_image[0][0]));
  283. oled_set_cursor(col + 4, line + 1);
  284. oled_write_raw_P(tri_layer_image[layer_is[1]][1], sizeof(tri_layer_image[0][0]));
  285. oled_set_cursor(col + 8, line + 1);
  286. oled_write_raw_P(tri_layer_image[layer_is[2]][1], sizeof(tri_layer_image[0][0]));
  287. oled_set_cursor(col + 13, line + 1);
  288. oled_write_P(PSTR("Diablo3"), layer_state_is(_DIABLO));
  289. oled_advance_page(true);
  290. oled_set_cursor(col, line + 2);
  291. oled_write_raw_P(tri_layer_image[layer_is[0]][2], sizeof(tri_layer_image[0][0]));
  292. oled_set_cursor(col + 4, line + 2);
  293. oled_write_raw_P(tri_layer_image[layer_is[1]][2], sizeof(tri_layer_image[0][0]));
  294. oled_set_cursor(col + 8, line + 2);
  295. oled_write_raw_P(tri_layer_image[layer_is[2]][2], sizeof(tri_layer_image[0][0]));
  296. oled_set_cursor(col + 13, line + 2);
  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, uint8_t col, uint8_t line) {
  311. #if defined(OLED_DISPLAY_VERBOSE)
  312. oled_set_cursor(col, line);
  313. #endif
  314. #ifdef CAPS_WORD_ENABLE
  315. led_usb_state.caps_lock |= is_caps_word_on();
  316. #endif
  317. oled_write_P(PSTR(OLED_RENDER_LOCK_NAME), false);
  318. #if !defined(OLED_DISPLAY_VERBOSE)
  319. oled_write_P(PSTR(" "), false);
  320. #endif
  321. oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state.num_lock);
  322. oled_write_P(PSTR(" "), false);
  323. oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state.caps_lock);
  324. #if defined(OLED_DISPLAY_VERBOSE)
  325. oled_write_P(PSTR(" "), false);
  326. oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state.scroll_lock);
  327. #endif
  328. }
  329. /**
  330. * @brief Renders the matrix scan rate to the host system
  331. *
  332. */
  333. void render_matrix_scan_rate(uint8_t padding, uint8_t col, uint8_t line) {
  334. #ifdef DEBUG_MATRIX_SCAN_RATE
  335. oled_set_cursor(col, line);
  336. oled_write_P(PSTR("MS:"), false);
  337. if (padding) {
  338. for (uint8_t n = padding; n > 0; n--) {
  339. oled_write_P(PSTR(" "), false);
  340. }
  341. }
  342. oled_write(get_u16_str(get_matrix_scan_rate(), ' '), false);
  343. #endif
  344. }
  345. /**
  346. * @brief Renders the modifier state
  347. *
  348. * @param modifiers Modifiers to check against (real, weak, onesheot, etc;)
  349. */
  350. void render_mod_status(uint8_t modifiers, uint8_t col, uint8_t line) {
  351. static const char PROGMEM mod_status[5][3] = {{0xE8, 0xE9, 0}, {0xE4, 0xE5, 0}, {0xE6, 0xE7, 0}, {0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
  352. #if defined(OLED_DISPLAY_VERBOSE)
  353. oled_set_cursor(col, line);
  354. #endif
  355. oled_write_P(PSTR(OLED_RENDER_MODS_NAME), false);
  356. #if defined(OLED_DISPLAY_VERBOSE)
  357. oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_LSHIFT)));
  358. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_LGUI)));
  359. oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_LALT)));
  360. oled_write_P(mod_status[1], (modifiers & MOD_BIT(KC_LCTL)));
  361. oled_write_P(mod_status[1], (modifiers & MOD_BIT(KC_RCTL)));
  362. oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_RALT)));
  363. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_RGUI)));
  364. oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_RSHIFT)));
  365. #else
  366. oled_write_P(mod_status[0], (modifiers & MOD_MASK_SHIFT));
  367. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_MASK_GUI));
  368. oled_write_P(PSTR(" "), false);
  369. oled_write_P(mod_status[2], (modifiers & MOD_MASK_ALT));
  370. oled_write_P(mod_status[1], (modifiers & MOD_MASK_CTRL));
  371. #endif
  372. }
  373. #ifdef SWAP_HANDS_ENABLE
  374. extern bool swap_hands;
  375. #endif
  376. void render_bootmagic_status(uint8_t col, uint8_t line) {
  377. /* Show Ctrl-Gui Swap options */
  378. static const char PROGMEM logo[][2][3] = {
  379. {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
  380. {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
  381. };
  382. bool is_bootmagic_on;
  383. #ifdef OLED_DISPLAY_VERBOSE
  384. oled_set_cursor(col, line);
  385. // oled_set_cursor(7, 3);
  386. is_bootmagic_on = !keymap_config.swap_lctl_lgui;
  387. #else
  388. is_bootmagic_on = keymap_config.swap_lctl_lgui;
  389. #endif
  390. #ifdef OLED_DISPLAY_VERBOSE
  391. if (keymap_config.swap_lctl_lgui)
  392. #else
  393. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NAME), false);
  394. oled_write_P(PSTR(" "), false);
  395. #endif
  396. {
  397. oled_write_P(logo[1][0], is_bootmagic_on);
  398. #ifdef OLED_DISPLAY_VERBOSE
  399. } else {
  400. #endif
  401. oled_write_P(logo[0][0], !is_bootmagic_on);
  402. }
  403. #ifndef OLED_DISPLAY_VERBOSE
  404. oled_write_P(logo[1][1], is_bootmagic_on);
  405. oled_write_P(logo[0][1], !is_bootmagic_on);
  406. #endif
  407. oled_write_P(PSTR(" "), false);
  408. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NKRO), keymap_config.nkro);
  409. oled_write_P(PSTR(" "), false);
  410. #if defined(AUTOCORRECTION_ENABLE) || defined(AUTOCORRECT_ENABLE)
  411. oled_write_P(PSTR("CRCT"), autocorrect_is_enabled());
  412. oled_write_P(PSTR(" "), false);
  413. #else
  414. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui);
  415. #endif
  416. #ifdef OLED_DISPLAY_VERBOSE
  417. oled_set_cursor(col, line + 1);
  418. if (keymap_config.swap_lctl_lgui) {
  419. oled_write_P(logo[1][1], is_bootmagic_on);
  420. } else {
  421. oled_write_P(logo[0][1], !is_bootmagic_on);
  422. }
  423. #endif
  424. oled_write_P(PSTR(" "), false);
  425. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_ONESHOT), is_oneshot_enabled());
  426. #ifdef SWAP_HANDS_ENABLE
  427. oled_write_P(PSTR(" "), false);
  428. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands);
  429. oled_write_P(PSTR(" "), false);
  430. #endif
  431. }
  432. #if defined(CUSTOM_POINTING_DEVICE)
  433. extern bool tap_toggling;
  434. #endif
  435. void render_user_status(uint8_t col, uint8_t line) {
  436. #ifdef AUDIO_ENABLE
  437. bool is_audio_on = false, l_is_clicky_on = false;
  438. # ifdef SPLIT_KEYBOARD
  439. is_audio_on = user_state.audio_enable;
  440. # ifdef AUDIO_CLICKY
  441. l_is_clicky_on = user_state.audio_clicky_enable;
  442. # endif
  443. # else
  444. is_audio_on = is_audio_on();
  445. # ifdef AUDIO_CLICKY
  446. l_is_clicky_on = is_clicky_on();
  447. # endif
  448. # endif
  449. #endif
  450. #if defined(OLED_DISPLAY_VERBOSE)
  451. oled_set_cursor(col, line);
  452. #endif
  453. oled_write_P(PSTR(OLED_RENDER_USER_NAME), false);
  454. #if !defined(OLED_DISPLAY_VERBOSE)
  455. oled_write_P(PSTR(" "), false);
  456. #endif
  457. #if defined(RGB_MATRIX_ENABLE)
  458. oled_write_P(PSTR(OLED_RENDER_USER_ANIM), userspace_config.rgb_matrix_idle_anim);
  459. # if !defined(OLED_DISPLAY_VERBOSE)
  460. oled_write_P(PSTR(" "), false);
  461. # endif
  462. #elif defined(CUSTOM_POINTING_DEVICE)
  463. static const char PROGMEM mouse_lock[3] = {0xF2, 0xF3, 0};
  464. oled_write_P(mouse_lock, tap_toggling);
  465. #endif
  466. #ifdef AUDIO_ENABLE
  467. static const char PROGMEM audio_status[2][3] = {{0xE0, 0xE1, 0}, {0xE2, 0xE3, 0}};
  468. oled_write_P(audio_status[is_audio_on], false);
  469. # ifdef AUDIO_CLICKY
  470. static const char PROGMEM audio_clicky_status[2][3] = {{0xF4, 0xF5, 0}, {0xF6, 0xF7, 0}};
  471. oled_write_P(audio_clicky_status[l_is_clicky_on && is_audio_on], false);
  472. # if !defined(OLED_DISPLAY_VERBOSE)
  473. oled_write_P(PSTR(" "), false);
  474. # endif
  475. # endif
  476. #endif
  477. static const char PROGMEM rgb_layer_status[2][3] = {{0xEE, 0xEF, 0}, {0xF0, 0xF1, 0}};
  478. oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
  479. static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
  480. oled_write_P(cat_mode[0], host_driver_disabled);
  481. #if defined(UNICODE_COMMON_ENABLE)
  482. static const char PROGMEM uc_mod_status[5][3] = {{0xEC, 0xED, 0}, {0x20, 0x20, 0}, {0x20, 0x20, 0}, {0x20, 0x20, 0}, {0xEA, 0xEB, 0}};
  483. oled_write_P(uc_mod_status[get_unicode_input_mode()], false);
  484. #endif
  485. if (userspace_config.nuke_switch) {
  486. #if !defined(OLED_DISPLAY_VERBOSE)
  487. oled_write_P(PSTR(" "), false);
  488. #endif
  489. static const char PROGMEM nukem_good[2] = {0xFA, 0};
  490. oled_write_P(nukem_good, false);
  491. #if !defined(OLED_DISPLAY_VERBOSE)
  492. oled_advance_page(true);
  493. #endif
  494. }
  495. #if defined(OLED_DISPLAY_VERBOSE)
  496. oled_advance_page(true);
  497. #endif
  498. }
  499. void render_rgb_hsv(uint8_t col, uint8_t line) {
  500. oled_set_cursor(col, line);
  501. oled_write_P(PSTR("HSV: "), false);
  502. #ifdef RGB_MATRIX_ENABLE
  503. oled_write(get_u8_str(rgb_matrix_get_hue(), ' '), false);
  504. oled_write_P(PSTR(", "), false);
  505. oled_write(get_u8_str(rgb_matrix_get_sat(), ' '), false);
  506. oled_write_P(PSTR(", "), false);
  507. oled_write(get_u8_str(rgb_matrix_get_val(), ' '), false);
  508. #elif RGBLIGHT_ENABLE
  509. oled_write(get_u8_str(rgblight_get_hue(), ' '), false);
  510. oled_write_P(PSTR(", "), false);
  511. oled_write(get_u8_str(rgblight_get_sat(), ' '), false);
  512. oled_write_P(PSTR(", "), false);
  513. oled_write(get_u8_str(rgblight_get_val(), ' '), false);
  514. #endif
  515. }
  516. void render_wpm(uint8_t padding, uint8_t col, uint8_t line) {
  517. #ifdef WPM_ENABLE
  518. oled_set_cursor(col, line);
  519. oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
  520. if (padding) {
  521. for (uint8_t n = padding; n > 0; n--) {
  522. oled_write_P(PSTR(" "), false);
  523. }
  524. }
  525. oled_write(get_u8_str(get_current_wpm(), ' '), false);
  526. #endif
  527. }
  528. //============= USER CONFIG PARAMS ===============
  529. // wpm graph originally designed by john-ezra
  530. // for 128x128:
  531. // max_lines_graph = 54;
  532. // vertical_offset = 64;
  533. // for 128x64:
  534. // max_lines_graph = 64;
  535. // vertical_offset = 0;
  536. void render_wpm_graph(uint8_t max_lines_graph, uint8_t vertical_offset) {
  537. #ifdef WPM_ENABLE
  538. static uint16_t timer = 0;
  539. static uint8_t x = OLED_DISPLAY_HEIGHT - 1;
  540. uint8_t currwpm = get_current_wpm();
  541. float max_wpm = OLED_WPM_GRAPH_MAX_WPM;
  542. if (timer_elapsed(timer) > OLED_WPM_GRAPH_REFRESH_INTERVAL) { // check if it's been long enough before refreshing graph
  543. x = (max_lines_graph - 1) - ((currwpm / max_wpm) * (max_lines_graph - 1)); // main calculation to plot graph line
  544. for (uint8_t i = 0; i <= OLED_WPM_GRAPH_GRAPH_LINE_THICKNESS - 1; i++) { // first draw actual value line
  545. oled_write_pixel(3, x + i + vertical_offset, true);
  546. }
  547. # ifdef OLED_WPM_GRAPH_VERTICAL_LINE
  548. static uint8_t vert_count = 0;
  549. if (vert_count == OLED_WPM_GRAPH_VERTCAL_LINE_INTERVAL) {
  550. vert_count = 0;
  551. while (x <= (max_lines_graph - 1)) {
  552. oled_write_pixel(3, x + vertical_offset, true);
  553. x++;
  554. }
  555. } else {
  556. for (uint8_t i = (max_lines_graph - 1); i > x; i--) {
  557. if (i % OLED_WPM_GRAPH_AREA_FILL_INTERVAL == 0) {
  558. oled_write_pixel(3, i + vertical_offset, true);
  559. }
  560. }
  561. vert_count++;
  562. }
  563. # else
  564. for (int i = (max_lines_graph - 1); i > x; i--) {
  565. if (i % OLED_WPM_GRAPH_AREA_FILL_INTERVAL == 0) {
  566. oled_write_pixel(3, i + vertical_offset, true);
  567. }
  568. }
  569. # endif
  570. # include <math.h>
  571. uint8_t y_start = ceil(vertical_offset / 8);
  572. uint8_t y_length = y_start + ceil(max_lines_graph / 8);
  573. oled_pan_section(false, y_start, y_length, 3, 125); // then move the entire graph one pixel to the right
  574. timer = timer_read(); // refresh the timer for the next iteration
  575. }
  576. #endif
  577. }
  578. #if defined(POINTING_DEVICE_ENABLE)
  579. void render_pointing_dpi_status(uint16_t cpi, uint8_t padding, uint8_t col, uint8_t line) {
  580. oled_set_cursor(col, line);
  581. oled_write_P(PSTR("CPI:"), false);
  582. if (padding) {
  583. for (uint8_t n = padding - 1; n > 0; n--) {
  584. oled_write_P(PSTR(" "), false);
  585. }
  586. }
  587. oled_write(get_u16_str(cpi, ' '), false);
  588. }
  589. #endif
  590. // WPM-responsive animation stuff here
  591. #define OLED_SLEEP_FRAMES 2
  592. #define OLED_SLEEP_SPEED 10 // below this wpm value your animation will idle
  593. #define OLED_WAKE_FRAMES 2 // uncomment if >1
  594. #define OLED_WAKE_SPEED OLED_SLEEP_SPEED // below this wpm value your animation will idle
  595. #define OLED_KAKI_FRAMES 3
  596. #define OLED_KAKI_SPEED 40 // above this wpm value typing animation to triggere
  597. #define OLED_RTOGI_FRAMES 2
  598. //#define OLED_LTOGI_FRAMES 2
  599. //#define ANIM_FRAME_DURATION 500 // how long each frame lasts in ms
  600. // #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing
  601. #define OLED_ANIM_SIZE 36
  602. #define OLED_ANIM_ROWS 4
  603. #define OLED_ANIM_MAX_FRAMES 3
  604. #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)
  605. # error frame size too large
  606. #endif
  607. static uint8_t animation_frame = 0;
  608. static uint8_t animation_type = 0;
  609. void render_kitty(uint8_t col, uint8_t line) {
  610. // Images credit j-inc(/James Incandenza) and pixelbenny.
  611. // Credit to obosob for initial animation approach.
  612. // heavily modified by drashna because he's a glutton for punishment
  613. // clang-format off
  614. static const char PROGMEM animation[4][OLED_ANIM_MAX_FRAMES][OLED_ANIM_ROWS][OLED_ANIM_SIZE] = {
  615. // sleep frames
  616. {
  617. {
  618. { 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 },
  619. { 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 },
  620. { 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 },
  621. { 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 }
  622. },
  623. {
  624. { 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 },
  625. { 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 },
  626. { 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 },
  627. { 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 }
  628. }
  629. },
  630. // wake frames
  631. {
  632. {
  633. { 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 },
  634. { 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 },
  635. { 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 },
  636. { 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 }
  637. },
  638. {
  639. { 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 },
  640. { 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 },
  641. { 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 },
  642. { 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 }
  643. }
  644. },
  645. // kaki frames
  646. {
  647. {
  648. { 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 },
  649. { 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 },
  650. { 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 },
  651. { 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 }
  652. },
  653. {
  654. { 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 },
  655. { 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 },
  656. { 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 },
  657. { 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 }
  658. },
  659. {
  660. { 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 },
  661. { 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 },
  662. { 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 },
  663. { 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 }
  664. }
  665. },
  666. // rtogi frames
  667. {
  668. {
  669. { 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 },
  670. { 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 },
  671. { 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 },
  672. { 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 }
  673. },
  674. {
  675. { 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 },
  676. { 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 },
  677. { 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 },
  678. { 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 }
  679. }
  680. }
  681. };
  682. // clang-format on
  683. for (uint8_t i = 0; i < 4; i++) {
  684. oled_set_cursor(col, line + i);
  685. oled_write_raw_P(animation[animation_type][animation_frame][i], OLED_ANIM_SIZE);
  686. }
  687. }
  688. void render_unicode_mode(uint8_t col, uint8_t line) {
  689. #ifdef CUSTOM_UNICODE_ENABLE
  690. oled_set_cursor(col, line);
  691. oled_write_ln_P(PSTR("Unicode:"), false);
  692. switch (typing_mode) {
  693. case UCTM_WIDE:
  694. oled_write_P(PSTR(" Wide"), false);
  695. break;
  696. case UCTM_SCRIPT:
  697. oled_write_P(PSTR(" Script"), false);
  698. break;
  699. case UCTM_BLOCKS:
  700. oled_write_P(PSTR(" Blocks"), false);
  701. break;
  702. case UCTM_REGIONAL:
  703. oled_write_P(PSTR(" Regional"), false);
  704. break;
  705. case UCTM_AUSSIE:
  706. oled_write_P(PSTR(" Aussie"), false);
  707. break;
  708. case UCTM_ZALGO:
  709. oled_write_P(PSTR(" Zalgo"), false);
  710. break;
  711. case UCTM_NO_MODE:
  712. oled_write_P(PSTR(" Normal"), false);
  713. break;
  714. default:
  715. oled_write_P(PSTR(" Unknown"), false);
  716. break;
  717. }
  718. #endif
  719. }
  720. uint32_t kitty_animation_phases(uint32_t triger_time, void *cb_arg) {
  721. static uint32_t anim_frame_duration = 500;
  722. #ifdef CUSTOM_POINTING_DEVICE
  723. if (tap_toggling) {
  724. animation_frame = (animation_frame + 1) % OLED_RTOGI_FRAMES;
  725. animation_type = 3;
  726. anim_frame_duration = 300;
  727. } else
  728. #endif
  729. {
  730. #ifdef WPM_ENABLE
  731. if (get_current_wpm() <= OLED_SLEEP_SPEED) {
  732. #endif
  733. animation_frame = (animation_frame + 1) % OLED_SLEEP_FRAMES;
  734. animation_type = 0;
  735. anim_frame_duration = 500;
  736. #ifdef WPM_ENABLE
  737. } else if (get_current_wpm() > OLED_WAKE_SPEED) {
  738. animation_frame = (animation_frame + 1) % OLED_WAKE_FRAMES;
  739. animation_type = 1;
  740. anim_frame_duration = 800;
  741. } else if (get_current_wpm() >= OLED_KAKI_SPEED) {
  742. animation_frame = (animation_frame + 1) % OLED_KAKI_FRAMES;
  743. animation_type = 2;
  744. anim_frame_duration = 500;
  745. }
  746. #endif
  747. }
  748. return anim_frame_duration;
  749. }
  750. void render_mouse_mode(uint8_t col, uint8_t line) {
  751. #if (defined(KEYBOARD_bastardkb_charybdis) || defined(KEYBOARD_handwired_tractyl_manuform)) && defined(POINTING_DEVICE_ENABLE)
  752. // credit and thanks to jaspertandy on discord for these images
  753. static const char PROGMEM mouse_logo[3][2][16] = {// mouse icon
  754. {{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}},
  755. // crosshair icon
  756. {{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}},
  757. // dragscroll icon
  758. {{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}}};
  759. uint8_t image_index = 0;
  760. # ifdef OLED_DISPLAY_TEST
  761. image_index = animation_frame;
  762. # else
  763. if (charybdis_get_pointer_sniping_enabled()) {
  764. image_index = 1;
  765. } else if (charybdis_get_pointer_dragscroll_enabled()) {
  766. image_index = 2;
  767. }
  768. # endif
  769. oled_set_cursor(col, line);
  770. oled_write_raw_P(mouse_logo[image_index][0], 16);
  771. oled_set_cursor(col, line + 1);
  772. oled_write_raw_P(mouse_logo[image_index][1], 16);
  773. #endif
  774. }
  775. void render_status_right(void) {
  776. #if defined(KEYBOARD_handwired_tractyl_manuform)
  777. oled_set_cursor(7, 0);
  778. oled_write_P(PSTR("Manuform"), true);
  779. #elif defined(KEYBOARD_bastardkb_charybdis)
  780. oled_set_cursor(6, 0);
  781. oled_write_P(PSTR("Charybdis"), true);
  782. #elif defined(KEYBOARD_splitkb_kyria)
  783. oled_set_cursor(8, 0);
  784. oled_write_P(PSTR("Kyria"), true);
  785. #else
  786. oled_set_cursor(8, 0);
  787. oled_write_P(PSTR("Right"), true);
  788. #endif
  789. #if defined(OLED_DISPLAY_VERBOSE)
  790. render_default_layer_state(1, 1);
  791. #else
  792. render_default_layer_state(0, 0);
  793. #endif
  794. /* Show Keyboard Layout */
  795. render_layer_state(1, 2);
  796. render_mod_status(get_mods() | get_oneshot_mods(), 1, 5);
  797. #if !defined(OLED_DISPLAY_VERBOSE) && defined(WPM_ENABLE) && !defined(STM32F303xC)
  798. render_wpm(2);
  799. #endif
  800. render_keylock_status(host_keyboard_led_state(), 1, 6);
  801. }
  802. void render_status_left(void) {
  803. #if defined(OLED_DISPLAY_VERBOSE)
  804. render_kitty(0, 1);
  805. # if defined(KEYBOARD_handwired_tractyl_manuform)
  806. oled_set_cursor(7, 0);
  807. oled_write_P(PSTR("Tractyl"), true);
  808. # elif defined(KEYBOARD_bastardkb_charybdis)
  809. oled_set_cursor(6, 0);
  810. oled_write_P(PSTR("Charybdis"), true);
  811. # elif defined(KEYBOARD_splitkb_kyria)
  812. oled_set_cursor(7, 0);
  813. oled_write_P(PSTR("SplitKB"), true);
  814. # elif defined(KEYBOARD_handwired_fingerpunch_rockon)
  815. oled_set_cursor(7, 0);
  816. oled_write_P(PSTR("Rock On"), true);
  817. # else
  818. oled_set_cursor(8, 0);
  819. oled_write_P(PSTR("Left"), true);
  820. # endif
  821. # if defined(WPM_ENABLE)
  822. render_wpm(1, 7, 1);
  823. # elif defined(DEBUG_MATRIX_SCAN_RATE)
  824. render_matrix_scan_rate(1, 7, 1);
  825. # endif
  826. # if (defined(KEYBOARD_bastardkb_charybdis) || defined(KEYBOARD_handwired_tractyl_manuform)) && defined(POINTING_DEVICE_ENABLE)
  827. render_pointing_dpi_status(charybdis_get_pointer_sniping_enabled() ? charybdis_get_pointer_sniping_dpi() : charybdis_get_pointer_default_dpi(), 1, 7, 2);
  828. render_mouse_mode(17, 1);
  829. # elif defined(WPM_ENABLE) && defined(DEBUG_MATRIX_SCAN_RATE)
  830. render_matrix_scan_rate(1, 7, 2);
  831. # endif
  832. /* Show Keyboard Layout */
  833. render_bootmagic_status(7, 3);
  834. render_user_status(1, 5);
  835. render_keylogger_status(1, 6);
  836. #else
  837. render_default_layer_state(0, 0);
  838. /* Show Keyboard Layout */
  839. render_bootmagic_status(7, 3);
  840. render_user_status(1, 5);
  841. render_keylogger_status(1, 6);
  842. #endif
  843. }
  844. __attribute__((weak)) void oled_render_large_display(bool side) {
  845. if (!side) {
  846. render_unicode_mode(1, 14);
  847. }
  848. }
  849. __attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) {
  850. return rotation;
  851. }
  852. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  853. if (is_keyboard_master()) {
  854. memset(keylog_str, ' ', OLED_KEYLOGGER_LENGTH);
  855. }
  856. kittoken = defer_exec(3000, kitty_animation_phases, NULL);
  857. oled_clear();
  858. oled_render();
  859. return oled_init_keymap(rotation);
  860. }
  861. __attribute__((weak)) bool oled_task_keymap(void) {
  862. return true;
  863. }
  864. bool oled_task_user(void) {
  865. if (is_keyboard_master()) {
  866. #ifndef OLED_DISPLAY_TEST
  867. if (timer_elapsed32(oled_timer) > 60000) {
  868. oled_off();
  869. return false;
  870. } else
  871. #endif
  872. {
  873. oled_on();
  874. }
  875. }
  876. if (!oled_task_keymap()) {
  877. return false;
  878. }
  879. #if defined(OLED_DISPLAY_VERBOSE)
  880. static const char PROGMEM header_image[] = {
  881. 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,
  882. // 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
  883. };
  884. oled_write_raw_P(header_image, sizeof(header_image));
  885. #endif
  886. #ifndef OLED_DISPLAY_TEST
  887. if (is_keyboard_left()) {
  888. #endif
  889. render_status_left();
  890. #if defined(OLED_DISPLAY_128X128)
  891. oled_render_large_display(true);
  892. #endif
  893. #ifndef OLED_DISPLAY_TEST
  894. } else {
  895. render_status_right();
  896. # if defined(OLED_DISPLAY_128X128)
  897. oled_render_large_display(false);
  898. # endif
  899. }
  900. #endif
  901. #if defined(OLED_DISPLAY_VERBOSE)
  902. uint8_t num_of_rows;
  903. # if defined(OLED_DISPLAY_128X128)
  904. num_of_rows = 15;
  905. # else
  906. num_of_rows = 7;
  907. # endif
  908. for (uint8_t i = 1; i < num_of_rows; i++) {
  909. oled_set_cursor(0, i);
  910. oled_write_raw_P(display_border, sizeof(display_border));
  911. oled_set_cursor(21, i);
  912. oled_write_raw_P(display_border, sizeof(display_border));
  913. }
  914. 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};
  915. oled_set_cursor(0, num_of_rows);
  916. oled_write_raw_P(footer_image, sizeof(footer_image));
  917. #endif
  918. return false;
  919. }