logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

pi40.c (11716B)


  1. /* Copyright 2022 ziptyze
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "quantum.h"
  17. #ifdef OLED_ENABLE
  18. static uint32_t oled_logo_timer = 0;
  19. static bool clear_logo = true;
  20. static const char PROGMEM my_logo[] = {
  21. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  22. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  23. 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
  24. 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
  25. 0x0f, 0x0f, 0x0f, 0x1f, 0xff, 0xff, 0xff, 0x1f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
  26. 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x00,
  27. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  28. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  29. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  30. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  31. 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  32. 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
  33. 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  34. 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
  35. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  36. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  37. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  38. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  39. 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  40. 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
  41. 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
  42. 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x00,
  43. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  44. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  45. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  46. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  47. 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
  48. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfb,
  49. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff,
  50. 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  51. 0x00, 0x00, 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. };
  54. #endif
  55. #ifdef OLED_ENABLE
  56. void init_timer(void){
  57. oled_logo_timer = timer_read32();
  58. };
  59. void user_oled_magic(void) {
  60. // Host Keyboard Layer Status
  61. oled_write_P(PSTR("Layer: "), false);
  62. switch (get_highest_layer(layer_state)) {
  63. case 0:
  64. oled_write_P(PSTR("One\n"), false);
  65. break;
  66. case 1:
  67. oled_write_P(PSTR("Two\n"), false);
  68. break;
  69. case 2:
  70. oled_write_P(PSTR("Three\n"), false);
  71. break;
  72. case 3:
  73. oled_write_P(PSTR("Four\n"), false);
  74. break;
  75. case 4:
  76. oled_write_P(PSTR("Five\n"), false);
  77. break;
  78. case 5:
  79. oled_write_P(PSTR("Six\n"), false);
  80. break;
  81. case 6:
  82. oled_write_P(PSTR("Seven\n"), false);
  83. break;
  84. case 7:
  85. oled_write_P(PSTR("Eight\n"), false);
  86. break;
  87. case 8:
  88. oled_write_P(PSTR("Nine\n"), false);
  89. break;
  90. case 9:
  91. oled_write_P(PSTR("Ten\n"), false);
  92. break;
  93. default:
  94. // Or use the write_ln shortcut over adding '\n' to the end of your string
  95. oled_write_ln_P(PSTR("Undefined"), false);
  96. }
  97. // Host Keyboard LED Status
  98. led_t led_state = host_keyboard_led_state();
  99. oled_write_P(led_state.caps_lock ? PSTR("Cap(x) ") : PSTR("Cap( ) "), false);
  100. oled_write_P(led_state.num_lock ? PSTR("Num(x) ") : PSTR("Num( ) "), false);
  101. oled_write_P(led_state.scroll_lock ? PSTR("Scrl(x)") : PSTR("Scrl( )"), false);
  102. switch (rgb_matrix_get_mode()) {
  103. case 1:
  104. oled_write_P(PSTR("Solid Color\n "), false);
  105. break;
  106. case 2:
  107. oled_write_P(PSTR("Alphas Mods\n "), false);
  108. break;
  109. case 3:
  110. oled_write_P(PSTR("Gradient Up Down\n "), false);
  111. break;
  112. case 4:
  113. oled_write_P(PSTR("Gradient Left Right\n "), false);
  114. break;
  115. case 5:
  116. oled_write_P(PSTR("Breathing\n "), false);
  117. break;
  118. case 6:
  119. oled_write_P(PSTR("Band Sat\n "), false);
  120. break;
  121. case 7:
  122. oled_write_P(PSTR("Band Val\n "), false);
  123. break;
  124. case 8:
  125. oled_write_P(PSTR("Band Pinwheel Sat\n "), false);
  126. break;
  127. case 9:
  128. oled_write_P(PSTR("Band Pinwheel Val\n "), false);
  129. break;
  130. case 10:
  131. oled_write_P(PSTR("Band Spiral Sat\n "), false);
  132. break;
  133. case 11:
  134. oled_write_P(PSTR("Band Spiral Val\n "), false);
  135. break;
  136. case 12:
  137. oled_write_P(PSTR("Cycle All\n "), false);
  138. break;
  139. case 13:
  140. oled_write_P(PSTR("Cycle Left Right\n "), false);
  141. break;
  142. case 14:
  143. oled_write_P(PSTR("Cycle Up Down\n "), false);
  144. break;
  145. case 15:
  146. oled_write_P(PSTR("Rainbow\nMoving Chevron "), false);
  147. break;
  148. case 16:
  149. oled_write_P(PSTR("Cycle Out In\n "), false);
  150. break;
  151. case 17:
  152. oled_write_P(PSTR("Cycle Out In Dual\n "), false);
  153. break;
  154. case 18:
  155. oled_write_P(PSTR("Cycle Pinwheel\n "), false);
  156. break;
  157. case 19:
  158. oled_write_P(PSTR("Cycle Spiral\n "), false);
  159. break;
  160. case 20:
  161. oled_write_P(PSTR("Dual Beacon\n "), false);
  162. break;
  163. case 21:
  164. oled_write_P(PSTR("Rainbow Beacon\n "), false);
  165. break;
  166. case 22:
  167. oled_write_P(PSTR("Rainbow Pinwheels\n "), false);
  168. break;
  169. case 23:
  170. oled_write_P(PSTR("Raindrops\n "), false);
  171. break;
  172. case 24:
  173. oled_write_P(PSTR("Jellybean Raindrops\n "), false);
  174. break;
  175. case 25:
  176. oled_write_P(PSTR("Hue Breathing\n "), false);
  177. break;
  178. case 26:
  179. oled_write_P(PSTR("Hue Pendulum\n "), false);
  180. break;
  181. case 27:
  182. oled_write_P(PSTR("Hue Wave\n "), false);
  183. break;
  184. case 28:
  185. oled_write_P(PSTR("Pixel Rain\n "), false);
  186. break;
  187. case 29:
  188. oled_write_P(PSTR("Pixel Flow\n "), false);
  189. break;
  190. case 30:
  191. oled_write_P(PSTR("Pixel Fractal\n "), false);
  192. break;
  193. case 31:
  194. oled_write_P(PSTR("Typing Heatmap\n "), false);
  195. break;
  196. case 32:
  197. oled_write_P(PSTR("Digital Rain\n "), false);
  198. break;
  199. case 33:
  200. oled_write_P(PSTR("Solid Reactive\nSimple "), false);
  201. break;
  202. case 34:
  203. oled_write_P(PSTR("Solid Reactive\n "), false);
  204. break;
  205. case 35:
  206. oled_write_P(PSTR("Solid Reactive\nWide "), false);
  207. break;
  208. case 36:
  209. oled_write_P(PSTR("Solid Reactive\nMultiwide "), false);
  210. break;
  211. case 37:
  212. oled_write_P(PSTR("Solid Reactive\nCross "), false);
  213. break;
  214. case 38:
  215. oled_write_P(PSTR("Solid Reactive\nMulticross "), false);
  216. break;
  217. case 39:
  218. oled_write_P(PSTR("Solid Reactive\nNexus "), false);
  219. break;
  220. case 40:
  221. oled_write_P(PSTR("Solid Reactive\nMultinexus "), false);
  222. break;
  223. case 41:
  224. oled_write_P(PSTR("Splash\n "), false);
  225. break;
  226. case 42:
  227. oled_write_P(PSTR("Multisplash\n "), false);
  228. break;
  229. case 43:
  230. oled_write_P(PSTR("Solid Splash\n "), false);
  231. break;
  232. case 44:
  233. oled_write_P(PSTR("Solid Multisplash\n "), false);
  234. break;
  235. default:
  236. // Or use the write_ln shortcut over adding '\n' to the end of your string
  237. oled_write_ln_P(PSTR("Undefined\n "), false);
  238. }
  239. }
  240. void render_logo(void) {
  241. oled_write_raw_P(my_logo, sizeof(my_logo));
  242. }
  243. void clear_screen(void) {
  244. if (clear_logo){
  245. for (uint8_t i = 0; i < OLED_DISPLAY_HEIGHT; ++i) {
  246. for (uint8_t j = 0; j < OLED_DISPLAY_WIDTH; ++j) {
  247. oled_write_raw_byte(0x0, i*OLED_DISPLAY_WIDTH + j);
  248. }
  249. }
  250. clear_logo = false;
  251. }
  252. }
  253. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  254. return OLED_ROTATION_180;
  255. }
  256. void keyboard_post_init_kb(void) {
  257. init_timer();
  258. keyboard_post_init_user();
  259. }
  260. # define SHOW_LOGO 5000
  261. bool oled_task_kb(void) {
  262. if (!oled_task_user()) { return false; }
  263. if ((timer_elapsed32(oled_logo_timer) < SHOW_LOGO)){
  264. render_logo();
  265. }else{
  266. clear_screen();
  267. user_oled_magic();
  268. }
  269. return false;
  270. }
  271. #endif