oled_stuff.c 43 KB

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