oled_stuff.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  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. #include <string.h>
  26. bool is_oled_enabled = true;
  27. extern bool host_driver_disabled;
  28. uint32_t oled_timer = 0;
  29. char keylog_str[OLED_KEYLOGGER_LENGTH] = {0};
  30. static uint16_t log_timer = 0;
  31. #ifdef OLED_DISPLAY_VERBOSE
  32. const char PROGMEM display_border[3] = {0x0, 0xFF, 0x0};
  33. #endif
  34. deferred_token kittoken;
  35. // clang-format off
  36. static const char PROGMEM code_to_name[256] = {
  37. // 0 1 2 3 4 5 6 7 8 9 A B c D E F
  38. ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x
  39. 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
  40. '3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
  41. ']','\\', '#', ';','\'', '`', ',', '.', '/', 128,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA, // 3x
  42. 0xDB,0xDC,0xDD,0xDE,0XDF,0xFB,'P', 'S', 19, ' ', 17, 30, 16, 16, 31, 26, // 4x
  43. 27, 25, 24, 'N', '/', '*', '-', '+', 23, '1', '2', '3', '4', '5', '6', '7', // 5x
  44. '8', '9', '0', '.','\\', 'A', 0, '=', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
  45. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
  46. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
  47. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
  48. ' ', ' ', ' ', ' ', ' ', 0, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
  49. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
  50. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
  51. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
  52. 'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 24, 26, 24, // Ex
  53. 25,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D, 24, 25, 27, 26, ' ', ' ', ' ' // Fx
  54. };
  55. // clang-format on
  56. /**
  57. * @brief parses pressed keycodes and saves to buffer
  58. *
  59. * @param keycode Keycode pressed from switch matrix
  60. * @param record keyrecord_t data structure
  61. */
  62. void add_keylog(uint16_t keycode, keyrecord_t *record) {
  63. if (keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) {
  64. keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode);
  65. } else if (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) {
  66. keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode);
  67. } else if (keycode >= QK_MODS && keycode <= QK_MODS_MAX) {
  68. keycode = QK_MODS_GET_BASIC_KEYCODE(keycode);
  69. }
  70. if ((keycode == KC_BSPC) && mod_config(get_mods() | get_oneshot_mods()) & MOD_MASK_CTRL) {
  71. memset(keylog_str, ' ', OLED_KEYLOGGER_LENGTH);
  72. return;
  73. }
  74. if (record->tap.count) {
  75. keycode &= 0xFF;
  76. } else if (keycode > 0xFF) {
  77. return;
  78. }
  79. memmove(keylog_str, keylog_str + 1, OLED_KEYLOGGER_LENGTH - 1);
  80. if (keycode < ARRAY_SIZE(code_to_name)) {
  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_LSFT)));
  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_RSFT)));
  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(PSTR(" "), false);
  405. oled_write_P(logo[1][1], is_bootmagic_on);
  406. oled_write_P(logo[0][1], !is_bootmagic_on);
  407. #endif
  408. oled_write_P(PSTR(" "), false);
  409. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NKRO), keymap_config.nkro);
  410. oled_write_P(PSTR(" "), false);
  411. #if defined(AUTOCORRECT_ENABLE)
  412. oled_write_P(PSTR("CRCT"), autocorrect_is_enabled());
  413. oled_write_P(PSTR(" "), false);
  414. #else
  415. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui);
  416. #endif
  417. #ifdef OLED_DISPLAY_VERBOSE
  418. oled_set_cursor(col, line + 1);
  419. if (keymap_config.swap_lctl_lgui) {
  420. oled_write_P(logo[1][1], is_bootmagic_on);
  421. } else {
  422. oled_write_P(logo[0][1], !is_bootmagic_on);
  423. }
  424. #endif
  425. oled_write_P(PSTR(" "), false);
  426. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_ONESHOT), is_oneshot_enabled());
  427. #ifdef SWAP_HANDS_ENABLE
  428. oled_write_P(PSTR(" "), false);
  429. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands);
  430. oled_write_P(PSTR(" "), false);
  431. #endif
  432. }
  433. void render_user_status(uint8_t col, uint8_t line) {
  434. #ifdef AUDIO_ENABLE
  435. bool is_audio_on = false, l_is_clicky_on = false;
  436. # ifdef SPLIT_KEYBOARD
  437. is_audio_on = user_state.audio_enable;
  438. # ifdef AUDIO_CLICKY
  439. l_is_clicky_on = user_state.audio_clicky_enable;
  440. # endif
  441. # else
  442. is_audio_on = is_audio_on();
  443. # ifdef AUDIO_CLICKY
  444. l_is_clicky_on = is_clicky_on();
  445. # endif
  446. # endif
  447. #endif
  448. #if defined(OLED_DISPLAY_VERBOSE)
  449. oled_set_cursor(col, line);
  450. #endif
  451. oled_write_P(PSTR(OLED_RENDER_USER_NAME), false);
  452. #if !defined(OLED_DISPLAY_VERBOSE)
  453. oled_write_P(PSTR(" "), false);
  454. #endif
  455. #if defined(RGB_MATRIX_ENABLE)
  456. oled_write_P(PSTR(OLED_RENDER_USER_ANIM), userspace_config.rgb_matrix_idle_anim);
  457. # if !defined(OLED_DISPLAY_VERBOSE)
  458. oled_write_P(PSTR(" "), false);
  459. # endif
  460. #elif defined(POINTING_DEVICE_ENABLE) && defined(POINTING_DEVICE_AUTO_MOUSE_ENABLE)
  461. static const char PROGMEM mouse_lock[3] = {0xF2, 0xF3, 0};
  462. oled_write_P(mouse_lock, get_auto_mouse_toggle());
  463. #endif
  464. #ifdef AUDIO_ENABLE
  465. static const char PROGMEM audio_status[2][3] = {{0xE0, 0xE1, 0}, {0xE2, 0xE3, 0}};
  466. oled_write_P(audio_status[is_audio_on], false);
  467. # ifdef AUDIO_CLICKY
  468. static const char PROGMEM audio_clicky_status[2][3] = {{0xF4, 0xF5, 0}, {0xF6, 0xF7, 0}};
  469. oled_write_P(audio_clicky_status[l_is_clicky_on && is_audio_on], false);
  470. # if !defined(OLED_DISPLAY_VERBOSE)
  471. oled_write_P(PSTR(" "), false);
  472. # endif
  473. # endif
  474. #endif
  475. static const char PROGMEM rgb_layer_status[2][3] = {{0xEE, 0xEF, 0}, {0xF0, 0xF1, 0}};
  476. oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
  477. static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
  478. oled_write_P(cat_mode[0], host_driver_disabled);
  479. #if defined(UNICODE_COMMON_ENABLE)
  480. static const char PROGMEM uc_mod_status[5][3] = {{0xEC, 0xED, 0}, {0x20, 0x20, 0}, {0x20, 0x20, 0}, {0x20, 0x20, 0}, {0xEA, 0xEB, 0}};
  481. oled_write_P(uc_mod_status[get_unicode_input_mode()], false);
  482. #endif
  483. if (userspace_config.nuke_switch) {
  484. #if !defined(OLED_DISPLAY_VERBOSE)
  485. oled_write_P(PSTR(" "), false);
  486. #endif
  487. static const char PROGMEM nukem_good[2] = {0xFA, 0};
  488. oled_write_P(nukem_good, false);
  489. #if !defined(OLED_DISPLAY_VERBOSE)
  490. oled_advance_page(true);
  491. #endif
  492. }
  493. #if defined(OLED_DISPLAY_VERBOSE)
  494. oled_advance_page(true);
  495. #endif
  496. }
  497. void render_rgb_hsv(uint8_t col, uint8_t line) {
  498. oled_set_cursor(col, line);
  499. oled_write_P(PSTR("HSV: "), false);
  500. #ifdef RGB_MATRIX_ENABLE
  501. oled_write(get_u8_str(rgb_matrix_get_hue(), ' '), false);
  502. oled_write_P(PSTR(", "), false);
  503. oled_write(get_u8_str(rgb_matrix_get_sat(), ' '), false);
  504. oled_write_P(PSTR(", "), false);
  505. oled_write(get_u8_str(rgb_matrix_get_val(), ' '), false);
  506. #elif RGBLIGHT_ENABLE
  507. oled_write(get_u8_str(rgblight_get_hue(), ' '), false);
  508. oled_write_P(PSTR(", "), false);
  509. oled_write(get_u8_str(rgblight_get_sat(), ' '), false);
  510. oled_write_P(PSTR(", "), false);
  511. oled_write(get_u8_str(rgblight_get_val(), ' '), false);
  512. #endif
  513. }
  514. void render_wpm(uint8_t padding, uint8_t col, uint8_t line) {
  515. #ifdef WPM_ENABLE
  516. oled_set_cursor(col, line);
  517. oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
  518. if (padding) {
  519. for (uint8_t n = padding; n > 0; n--) {
  520. oled_write_P(PSTR(" "), false);
  521. }
  522. }
  523. oled_write(get_u8_str(get_current_wpm(), ' '), false);
  524. #endif
  525. }
  526. //============= USER CONFIG PARAMS ===============
  527. // wpm graph originally designed by john-ezra
  528. // for 128x128:
  529. // max_lines_graph = 54;
  530. // vertical_offset = 64;
  531. // for 128x64:
  532. // max_lines_graph = 64;
  533. // vertical_offset = 0;
  534. void render_wpm_graph(uint8_t max_lines_graph, uint8_t vertical_offset) {
  535. #ifdef WPM_ENABLE
  536. static uint16_t timer = 0;
  537. static uint8_t x = OLED_DISPLAY_HEIGHT - 1;
  538. uint8_t currwpm = get_current_wpm();
  539. float max_wpm = OLED_WPM_GRAPH_MAX_WPM;
  540. if (timer_elapsed(timer) > OLED_WPM_GRAPH_REFRESH_INTERVAL) { // check if it's been long enough before refreshing graph
  541. x = (max_lines_graph - 1) - ((currwpm / max_wpm) * (max_lines_graph - 1)); // main calculation to plot graph line
  542. for (uint8_t i = 0; i <= OLED_WPM_GRAPH_GRAPH_LINE_THICKNESS - 1; i++) { // first draw actual value line
  543. oled_write_pixel(3, x + i + vertical_offset, true);
  544. }
  545. # ifdef OLED_WPM_GRAPH_VERTICAL_LINE
  546. static uint8_t vert_count = 0;
  547. if (vert_count == OLED_WPM_GRAPH_VERTCAL_LINE_INTERVAL) {
  548. vert_count = 0;
  549. while (x <= (max_lines_graph - 1)) {
  550. oled_write_pixel(3, x + vertical_offset, true);
  551. x++;
  552. }
  553. } else {
  554. for (uint8_t i = (max_lines_graph - 1); i > x; i--) {
  555. if (i % OLED_WPM_GRAPH_AREA_FILL_INTERVAL == 0) {
  556. oled_write_pixel(3, i + vertical_offset, true);
  557. }
  558. }
  559. vert_count++;
  560. }
  561. # else
  562. for (int i = (max_lines_graph - 1); i > x; i--) {
  563. if (i % OLED_WPM_GRAPH_AREA_FILL_INTERVAL == 0) {
  564. oled_write_pixel(3, i + vertical_offset, true);
  565. }
  566. }
  567. # endif
  568. # include <math.h>
  569. uint8_t y_start = ceil(vertical_offset / 8);
  570. uint8_t y_length = y_start + ceil(max_lines_graph / 8);
  571. oled_pan_section(false, y_start, y_length, 3, 125); // then move the entire graph one pixel to the right
  572. timer = timer_read(); // refresh the timer for the next iteration
  573. }
  574. #endif
  575. }
  576. #if defined(POINTING_DEVICE_ENABLE)
  577. void render_pointing_dpi_status(uint16_t cpi, uint8_t padding, uint8_t col, uint8_t line) {
  578. oled_set_cursor(col, line);
  579. oled_write_P(PSTR("CPI:"), false);
  580. if (padding) {
  581. for (uint8_t n = padding - 1; n > 0; n--) {
  582. oled_write_P(PSTR(" "), false);
  583. }
  584. }
  585. oled_write(get_u16_str(cpi, ' '), false);
  586. }
  587. #endif
  588. // WPM-responsive animation stuff here
  589. #define OLED_SLEEP_FRAMES 2
  590. #define OLED_SLEEP_SPEED 10 // below this wpm value your animation will idle
  591. #define OLED_WAKE_FRAMES 2 // uncomment if >1
  592. #define OLED_WAKE_SPEED OLED_SLEEP_SPEED // below this wpm value your animation will idle
  593. #define OLED_KAKI_FRAMES 3
  594. #define OLED_KAKI_SPEED 40 // above this wpm value typing animation to triggere
  595. #define OLED_RTOGI_FRAMES 2
  596. //#define OLED_LTOGI_FRAMES 2
  597. //#define ANIM_FRAME_DURATION 500 // how long each frame lasts in ms
  598. // #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing
  599. #define OLED_ANIM_SIZE 36
  600. #define OLED_ANIM_ROWS 4
  601. #define OLED_ANIM_MAX_FRAMES 3
  602. #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)
  603. # error frame size too large
  604. #endif
  605. static uint8_t animation_frame = 0;
  606. static uint8_t animation_type = 0;
  607. void render_kitty(uint8_t col, uint8_t line) {
  608. // Images credit j-inc(/James Incandenza) and pixelbenny.
  609. // Credit to obosob for initial animation approach.
  610. // heavily modified by drashna because he's a glutton for punishment
  611. // clang-format off
  612. static const char PROGMEM animation[4][OLED_ANIM_MAX_FRAMES][OLED_ANIM_ROWS][OLED_ANIM_SIZE] = {
  613. // sleep frames
  614. {
  615. {
  616. { 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 },
  617. { 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 },
  618. { 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 },
  619. { 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 }
  620. },
  621. {
  622. { 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 },
  623. { 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 },
  624. { 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 },
  625. { 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 }
  626. }
  627. },
  628. // wake frames
  629. {
  630. {
  631. { 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 },
  632. { 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 },
  633. { 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 },
  634. { 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 }
  635. },
  636. {
  637. { 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 },
  638. { 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 },
  639. { 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 },
  640. { 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 }
  641. }
  642. },
  643. // kaki frames
  644. {
  645. {
  646. { 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 },
  647. { 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 },
  648. { 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 },
  649. { 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 }
  650. },
  651. {
  652. { 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 },
  653. { 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 },
  654. { 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 },
  655. { 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 }
  656. },
  657. {
  658. { 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 },
  659. { 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 },
  660. { 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 },
  661. { 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 }
  662. }
  663. },
  664. // rtogi frames
  665. {
  666. {
  667. { 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 },
  668. { 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 },
  669. { 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 },
  670. { 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 }
  671. },
  672. {
  673. { 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 },
  674. { 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 },
  675. { 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 },
  676. { 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 }
  677. }
  678. }
  679. };
  680. // clang-format on
  681. for (uint8_t i = 0; i < 4; i++) {
  682. oled_set_cursor(col, line + i);
  683. oled_write_raw_P(animation[animation_type][animation_frame][i], OLED_ANIM_SIZE);
  684. }
  685. }
  686. void render_unicode_mode(uint8_t col, uint8_t line) {
  687. #ifdef CUSTOM_UNICODE_ENABLE
  688. oled_set_cursor(col, line);
  689. oled_write_P(PSTR("Unicode:"), false);
  690. oled_write_P(unicode_mode_str[unicode_typing_mode], false);
  691. #endif
  692. }
  693. uint32_t kitty_animation_phases(uint32_t triger_time, void *cb_arg) {
  694. static uint32_t anim_frame_duration = 500;
  695. #if defined(POINTING_DEVICE_ENABLE) && defined(POINTING_DEVICE_AUTO_MOUSE_ENABLE)
  696. if (get_auto_mouse_toggle()) {
  697. animation_frame = (animation_frame + 1) % OLED_RTOGI_FRAMES;
  698. animation_type = 3;
  699. anim_frame_duration = 300;
  700. } else
  701. #endif
  702. {
  703. #ifdef WPM_ENABLE
  704. if (get_current_wpm() <= OLED_SLEEP_SPEED) {
  705. #endif
  706. animation_frame = (animation_frame + 1) % OLED_SLEEP_FRAMES;
  707. animation_type = 0;
  708. anim_frame_duration = 500;
  709. #ifdef WPM_ENABLE
  710. } else if (get_current_wpm() > OLED_WAKE_SPEED) {
  711. animation_frame = (animation_frame + 1) % OLED_WAKE_FRAMES;
  712. animation_type = 1;
  713. anim_frame_duration = 800;
  714. } else if (get_current_wpm() >= OLED_KAKI_SPEED) {
  715. animation_frame = (animation_frame + 1) % OLED_KAKI_FRAMES;
  716. animation_type = 2;
  717. anim_frame_duration = 500;
  718. }
  719. #endif
  720. }
  721. return anim_frame_duration;
  722. }
  723. void render_mouse_mode(uint8_t col, uint8_t line) {
  724. #if (defined(KEYBOARD_bastardkb_charybdis) || defined(KEYBOARD_handwired_tractyl_manuform)) && defined(POINTING_DEVICE_ENABLE)
  725. // credit and thanks to jaspertandy on discord for these images
  726. static const char PROGMEM mouse_logo[3][2][16] = {// mouse icon
  727. {{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}},
  728. // crosshair icon
  729. {{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}},
  730. // dragscroll icon
  731. {{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}}};
  732. uint8_t image_index = 0;
  733. # ifdef OLED_DISPLAY_TEST
  734. image_index = animation_frame;
  735. # else
  736. if (charybdis_get_pointer_sniping_enabled()) {
  737. image_index = 1;
  738. } else if (charybdis_get_pointer_dragscroll_enabled()) {
  739. image_index = 2;
  740. }
  741. # endif
  742. oled_set_cursor(col, line);
  743. oled_write_raw_P(mouse_logo[image_index][0], 16);
  744. oled_set_cursor(col, line + 1);
  745. oled_write_raw_P(mouse_logo[image_index][1], 16);
  746. #endif
  747. }
  748. void render_status_right(void) {
  749. #if defined(KEYBOARD_handwired_tractyl_manuform)
  750. oled_set_cursor(7, 0);
  751. oled_write_P(PSTR("Manuform"), true);
  752. #elif defined(KEYBOARD_bastardkb_charybdis)
  753. oled_set_cursor(6, 0);
  754. oled_write_P(PSTR("Charybdis"), true);
  755. #elif defined(KEYBOARD_splitkb_kyria)
  756. oled_set_cursor(8, 0);
  757. oled_write_P(PSTR("Kyria"), true);
  758. #else
  759. oled_set_cursor(8, 0);
  760. oled_write_P(PSTR("Right"), true);
  761. #endif
  762. #if defined(OLED_DISPLAY_VERBOSE)
  763. render_default_layer_state(1, 1);
  764. #else
  765. render_default_layer_state(0, 0);
  766. #endif
  767. /* Show Keyboard Layout */
  768. render_layer_state(1, 2);
  769. render_mod_status(get_mods() | get_oneshot_mods(), 1, 5);
  770. #if !defined(OLED_DISPLAY_VERBOSE) && defined(WPM_ENABLE) && !defined(STM32F303xC)
  771. render_wpm(2, 7, 1);
  772. #endif
  773. render_keylock_status(host_keyboard_led_state(), 1, 6);
  774. }
  775. void render_status_left(void) {
  776. #if defined(OLED_DISPLAY_VERBOSE)
  777. render_kitty(0, 1);
  778. # if defined(KEYBOARD_handwired_tractyl_manuform)
  779. oled_set_cursor(7, 0);
  780. oled_write_P(PSTR("Tractyl"), true);
  781. # elif defined(KEYBOARD_bastardkb_charybdis)
  782. oled_set_cursor(6, 0);
  783. oled_write_P(PSTR("Charybdis"), true);
  784. # elif defined(KEYBOARD_splitkb_kyria)
  785. oled_set_cursor(7, 0);
  786. oled_write_P(PSTR("SplitKB"), true);
  787. # elif defined(KEYBOARD_handwired_fingerpunch_rockon)
  788. oled_set_cursor(7, 0);
  789. oled_write_P(PSTR("Rock On"), true);
  790. # else
  791. oled_set_cursor(8, 0);
  792. oled_write_P(PSTR("Left"), true);
  793. # endif
  794. # if defined(WPM_ENABLE)
  795. render_wpm(1, 7, 1);
  796. # elif defined(DEBUG_MATRIX_SCAN_RATE)
  797. render_matrix_scan_rate(1, 7, 1);
  798. # endif
  799. # if (defined(KEYBOARD_bastardkb_charybdis) || defined(KEYBOARD_handwired_tractyl_manuform)) && defined(POINTING_DEVICE_ENABLE)
  800. render_pointing_dpi_status(charybdis_get_pointer_sniping_enabled() ? charybdis_get_pointer_sniping_dpi() : charybdis_get_pointer_default_dpi(), 1, 7, 2);
  801. render_mouse_mode(17, 1);
  802. # elif defined(WPM_ENABLE) && defined(DEBUG_MATRIX_SCAN_RATE)
  803. render_matrix_scan_rate(1, 7, 2);
  804. # endif
  805. /* Show Keyboard Layout */
  806. render_bootmagic_status(7, 3);
  807. render_user_status(1, 5);
  808. render_keylogger_status(1, 6);
  809. #else
  810. render_default_layer_state(0, 0);
  811. /* Show Keyboard Layout */
  812. render_bootmagic_status(7, 3);
  813. render_user_status(1, 5);
  814. render_keylogger_status(1, 6);
  815. #endif
  816. }
  817. __attribute__((weak)) void oled_render_large_display(bool side) {
  818. if (!side) {
  819. render_unicode_mode(1, 14);
  820. }
  821. }
  822. __attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) {
  823. return rotation;
  824. }
  825. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  826. if (is_keyboard_master()) {
  827. memset(keylog_str, ' ', OLED_KEYLOGGER_LENGTH);
  828. }
  829. kittoken = defer_exec(3000, kitty_animation_phases, NULL);
  830. oled_clear();
  831. oled_render();
  832. return oled_init_keymap(rotation);
  833. }
  834. __attribute__((weak)) bool oled_task_keymap(void) {
  835. return true;
  836. }
  837. bool oled_task_user(void) {
  838. #ifndef OLED_DISPLAY_TEST
  839. if (!is_oled_enabled) {
  840. oled_off();
  841. return false;
  842. } else
  843. #endif
  844. {
  845. oled_on();
  846. }
  847. if (!oled_task_keymap()) {
  848. return false;
  849. }
  850. #if defined(OLED_DISPLAY_VERBOSE)
  851. static const char PROGMEM header_image[] = {
  852. 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,
  853. // 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
  854. };
  855. oled_write_raw_P(header_image, sizeof(header_image));
  856. #endif
  857. #ifndef OLED_DISPLAY_TEST
  858. if (is_keyboard_left()) {
  859. #endif
  860. render_status_left();
  861. #if defined(OLED_DISPLAY_128X128)
  862. oled_render_large_display(true);
  863. #endif
  864. #ifndef OLED_DISPLAY_TEST
  865. } else {
  866. render_status_right();
  867. # if defined(OLED_DISPLAY_128X128)
  868. oled_render_large_display(false);
  869. # endif
  870. }
  871. #endif
  872. #if defined(OLED_DISPLAY_VERBOSE)
  873. uint8_t num_of_rows;
  874. # if defined(OLED_DISPLAY_128X128)
  875. num_of_rows = 15;
  876. # else
  877. num_of_rows = 7;
  878. # endif
  879. for (uint8_t i = 1; i < num_of_rows; i++) {
  880. oled_set_cursor(0, i);
  881. oled_write_raw_P(display_border, sizeof(display_border));
  882. oled_set_cursor(21, i);
  883. oled_write_raw_P(display_border, sizeof(display_border));
  884. }
  885. 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};
  886. oled_set_cursor(0, num_of_rows);
  887. oled_write_raw_P(footer_image, sizeof(footer_image));
  888. #endif
  889. return false;
  890. }
  891. extern bool oled_initialized;
  892. __attribute__((weak)) void matrix_scan_oled(void) {
  893. is_oled_enabled = !(timer_elapsed32(oled_timer) > 60000);
  894. }