Advertisement
Guest User

Untitled

a guest
Mar 13th, 2020
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.92 KB | None | 0 0
  1. // [OLED Configuration] ---------------------------------------------//
  2.  
  3. // Draw
  4. static const char PROGMEM skeeb_logo[] = {
  5. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  6. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  7. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
  8. 0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0};
  9.  
  10. static const char PROGMEM oled_header[] = {
  11. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  12. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  13. 0xc0,0};
  14.  
  15. static const char PROGMEM oled_layer_keylog_separator[] = {
  16. 0xc8,0xff,0};
  17.  
  18. static const char PROGMEM oled_layer_line_end[] = {
  19. 0xd4,0};
  20.  
  21. static const char PROGMEM oled_layer_keylog_bottom[] = {
  22. 0xc1,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc3,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc2,0};
  23.  
  24. static const char PROGMEM oled_line_start[] = {
  25. 0xc0,0};
  26.  
  27. static const char PROGMEM oled_mods_bottom[] = {
  28. 0xc1,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc7,0xc2,0};
  29.  
  30. static const char PROGMEM oled_footer[] = {
  31. 0xc4,0xc5,0xc5,0xc9,0xca,0xca,0xca,0xca,0xca,0xca,0xca,0xca,0xca,0xca,0xca,0xca,0xca,0xcb,0xc5,0xc5,0xc6,0};
  32.  
  33. void render_skeeb_logo(void) {
  34. static const char PROGMEM skeeb_logo[] = {
  35. 0x00, 0xc0, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03,
  36. 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  37. 0xff, 0xff, 0xff, 0x81, 0x81, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x19, 0x19, 0xff, 0xff, 0x01,
  38. 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x19, 0x19, 0x99, 0x99, 0x99,
  39. 0x99, 0x99, 0x99, 0x01, 0x01, 0xff, 0xff, 0x81, 0x81, 0x7f, 0x7f, 0xff, 0xff, 0x7f, 0x7f, 0x81,
  40. 0x81, 0xff, 0xff, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0xf9, 0xf9, 0xff, 0xff, 0xff,
  41. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07,
  42. 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0xc0, 0x00,
  43. 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  44. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
  45. 0x0f, 0x0f, 0x0f, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x0f, 0x0f, 0x08,
  46. 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0f, 0x0f, 0x08, 0x08, 0x0f, 0x0f, 0x0f,
  47. 0x0f, 0x0f, 0x0f, 0x08, 0x08, 0x0f, 0x0f, 0x0f, 0x0f, 0x0e, 0x0e, 0x09, 0x09, 0x0e, 0x0e, 0x0f,
  48. 0x0f, 0x0f, 0x0f, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0f, 0x0f, 0x0f,
  49. 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  50. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
  51. 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  52. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  53. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  54. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x10,
  55. 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  56. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  57. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  58. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
  59. 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  60. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  61. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  62. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0xe0, 0x20, 0x20, 0xe0, 0x00, 0x00, 0x00,
  63. 0x00, 0x00, 0xe0, 0x20, 0x20, 0xe0, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  64. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  65. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  66. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
  67. 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  68. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  69. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  70. 0xe0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3f, 0x00, 0x00, 0xf9, 0x01, 0x01, 0xf9, 0x00, 0x00, 0xf8,
  71. 0x00, 0x00, 0xf9, 0x01, 0x01, 0xf9, 0x00, 0x00, 0x3f, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe0, 0x00,
  72. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  73. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  74. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
  75. 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  77. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  78. 0xff, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xff, 0x01, 0x01, 0xf1, 0x10, 0x10, 0x1f, 0x00, 0x00, 0x3f,
  79. 0x00, 0x00, 0x1f, 0x10, 0x10, 0xf3, 0x02, 0x02, 0xf2, 0x12, 0x12, 0x1e, 0x00, 0x00, 0xff, 0x00,
  80. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  81. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  82. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
  83. 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  84. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  85. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  86. 0x0f, 0x00, 0x00, 0x0f, 0x08, 0x08, 0x0f, 0x00, 0x00, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0f,
  87. 0x00, 0x00, 0x0f, 0x01, 0x01, 0x09, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0f, 0x00, 0x00, 0x0f, 0x00,
  88. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  89. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  90. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
  91. 0x00, 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xe0,
  92. 0xf0, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8,
  93. 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8,
  94. 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8,
  95. 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8,
  96. 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8,
  97. 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0,
  98. 0xe0, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x03, 0x00,0
  99. };
  100. oled_write_raw_P(skeeb_logo, sizeof(skeeb_logo));
  101. }
  102.  
  103. // Mods Status
  104. void render_mod_status(uint8_t modifiers) {
  105. oled_write_P(PSTR(" "), false);
  106. oled_write_P(PSTR("-"), false);
  107. oled_write_P(PSTR("SHF"), (modifiers & MOD_MASK_SHIFT));
  108. oled_write_P(PSTR("-"), false);
  109. oled_write_P(PSTR("CTR"), (modifiers & MOD_MASK_CTRL));
  110. oled_write_P(PSTR("-"), false);
  111. oled_write_P(PSTR("WIN"), (modifiers & MOD_MASK_GUI));
  112. oled_write_P(PSTR("-"), false);
  113. oled_write_P(PSTR("ALT"), (modifiers & MOD_MASK_ALT));
  114. oled_write_P(PSTR("-"), false);
  115. oled_write_P(PSTR(" "), false);
  116. }
  117.  
  118. // Layer State
  119. void render_layer_state(void){
  120. switch (get_highest_layer(layer_state)) {
  121. case 0: oled_write_P(PSTR(" QWERTY "), false); break;
  122. case 1: oled_write_P(PSTR(" MEDIA "), false); break;
  123. case 2: oled_write_P(PSTR(" MOBA "), false); break;
  124. case 3: oled_write_P(PSTR(" FPS "), false); break;
  125. default: oled_write_P(PSTR("Undefined"), false);
  126. }
  127. }
  128.  
  129. // Keylock State
  130. void render_keylock_status(uint8_t led_usb_state) {
  131. oled_write_P(PSTR(" "), false);
  132. oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("-NUML") : PSTR("-----"), false);
  133. oled_write_P(PSTR(" "), false);
  134. oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("-CAPS") : PSTR("-----"), false);
  135. oled_write_P(PSTR(" "), false);
  136. oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("-SCRL") : PSTR("-----"), false);
  137. oled_write_P(PSTR(" "), false);
  138. }
  139.  
  140. // Keylogger
  141. # define KEYLOGGER_LENGTH 8
  142. static uint32_t oled_timer = 0;
  143. static char keylog_str[KEYLOGGER_LENGTH + 1] = {0};
  144.  
  145. static const char PROGMEM code_to_name[0xFF] = {
  146. // 0 1 2 3 4 5 6 7 8 9 A B c D E F
  147. 182, ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x
  148. 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
  149. '3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 17, 29, 22, '-', '=', '[', // 2x
  150. ']','\\', '#', ';','\'', '`', ',', '.', '/', 188, 149, 150, 151, 152, 153, 154, // 3x
  151. 155, 156, 157, 158, 159, 181, 191, 190, ' ', ' ', 185, 183, 16, 186, 184, 26, // 4x
  152. 27, 25, 24, 189, '/', '*', '-', '+', ' ', '1', '2', '3', '4', '5', '6', '7', // 5x
  153. '8', '9', '0', '.', ' ', 187, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
  154. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
  155. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
  156. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
  157. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 214, 215, 216, 217, 218, 219, 220, 221, // Ax
  158. ' ', ' ', 213, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
  159. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
  160. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
  161. 'C', 'S', 'A', 'W', ' ', 'S', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex
  162. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx
  163. };
  164.  
  165. void add_keylog(uint16_t keycode);
  166.  
  167. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  168. if (record->event.pressed) {
  169. oled_timer = timer_read32();
  170. add_keylog(keycode);
  171. }
  172. return true;
  173. }
  174.  
  175. void add_keylog(uint16_t keycode) {
  176. 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)) {
  177. keycode = keycode & 0xFF;
  178. } else if (keycode > 0xFF) {
  179. keycode = 0;
  180. }
  181.  
  182. for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) {
  183. keylog_str[i] = keylog_str[i - 1];
  184. }
  185.  
  186. if (keycode < (sizeof(code_to_name) / sizeof(char))) {
  187. keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
  188. }
  189. }
  190.  
  191. void render_keylogger_status(void) {
  192. oled_write(keylog_str, false);
  193. }
  194.  
  195. // WMP Counter and Graph
  196. #include "wpm.c"
  197.  
  198. char wpm_str[10];
  199. uint16_t wpm_graph_timer = 0;
  200. static uint8_t zero_bar_count = 0;
  201. static uint8_t bar_count = 0;
  202.  
  203. static void render_wpm_graph(void) {
  204. uint8_t bar_height = 0;
  205. uint8_t bar_segment = 0;
  206.  
  207. if (wpm_graph_timer == 0) {
  208. render_skeeb_logo();
  209. wpm_graph_timer = timer_read();
  210. return;
  211. }
  212. if(timer_elapsed(wpm_graph_timer) > 500) {
  213. wpm_graph_timer = timer_read();
  214.  
  215. if(OLED_DISPLAY_HEIGHT == 64)
  216. bar_height = get_current_wpm() / 2;
  217. if(OLED_DISPLAY_HEIGHT == 32)
  218. bar_height = get_current_wpm() / 4;
  219. if(bar_height > OLED_DISPLAY_HEIGHT)
  220. bar_height = OLED_DISPLAY_HEIGHT;
  221.  
  222. if(bar_height == 0) {
  223. // keep track of how many zero bars we have drawn. If
  224. // there is a whole screen worth, turn the display off and
  225. // wait until there is something to do
  226. if (zero_bar_count > OLED_DISPLAY_WIDTH) {
  227. oled_off();
  228. return;
  229. }
  230. zero_bar_count++;
  231. } else
  232. zero_bar_count=0;
  233.  
  234. oled_pan(false);
  235. bar_count++;
  236. for (uint8_t i = (OLED_DISPLAY_HEIGHT / 8); i > 0; i--) {
  237. if (bar_height > 7) {
  238. if (i % 2 == 1 && bar_count % 3 == 0)
  239. bar_segment = 254;
  240. else
  241. bar_segment = 255;
  242. bar_height -= 8;
  243. } else {
  244. switch (bar_height) {
  245. case 0:
  246. bar_segment = 0;
  247. break;
  248.  
  249. case 1:
  250. bar_segment = 128;
  251. break;
  252.  
  253. case 2:
  254. bar_segment = 192;
  255. break;
  256.  
  257. case 3:
  258. bar_segment = 224;
  259. break;
  260.  
  261. case 4:
  262. bar_segment = 240;
  263. break;
  264.  
  265. case 5:
  266. bar_segment = 248;
  267. break;
  268.  
  269. case 6:
  270. bar_segment = 252;
  271. break;
  272.  
  273. case 7:
  274. bar_segment = 254;
  275. break;
  276. }
  277. bar_height = 0;
  278.  
  279. if (i % 2 == 1 && bar_count % 3 == 0)
  280. bar_segment++;
  281. }
  282. oled_write_raw_byte(bar_segment, (i-1) * OLED_DISPLAY_WIDTH);
  283. }
  284. }
  285. }
  286.  
  287.  
  288. // [OLED Init] ------------------------------------------------------//
  289.  
  290. // Rotate Screen
  291. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  292. return OLED_ROTATION_180;
  293. }
  294.  
  295. // {OLED Task} ------------------------------------------------------//
  296. void oled_task_user(void) {
  297.  
  298. // MASTER SIDE
  299. if (is_keyboard_master()) {
  300. oled_write_P(oled_header, false);
  301. render_layer_state();
  302. oled_write_P(oled_layer_keylog_separator, false);
  303. render_keylogger_status();
  304. oled_set_cursor(20, 2);
  305. oled_write_P(oled_layer_line_end, false);
  306. oled_write_P(oled_layer_keylog_bottom, false);
  307. oled_write_P(oled_line_start, false);
  308. // render_keylock_status(host_keyboard_leds());
  309. // oled_write_P(oled_layer_line_end, false);
  310. // oled_write_P(oled_mods_bottom, false);
  311. // oled_write_P(oled_line_start, false);
  312. // render_mod_status(get_mods() | get_oneshot_mods());
  313. // oled_write_P(oled_layer_line_end, false);
  314. // oled_write_P(oled_footer, false);
  315. sprintf(wpm_str, "WPM: %03d", get_current_wpm());
  316. oled_write_P(PSTR("\n"), false);
  317. oled_write(wpm_str, false);
  318. }
  319.  
  320. // SLAVE SIDE
  321. else {
  322. render_wpm_graph();
  323. }
  324. }
  325.  
  326. void keyboard_pre_init_user(void) {
  327. setPinInputHigh(D0);
  328. setPinInputHigh(D1);
  329. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement