logo

qmk_firmware

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

gg86.c (6018B)


  1. /* Copyright 2023 Gopolar
  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. // OLED animation
  18. #include "lib/logo.h"
  19. #ifdef RGB_MATRIX_ENABLE
  20. #include <string.h>
  21. #include <math.h>
  22. #include <lib/lib8tion/lib8tion.h>
  23. led_config_t g_led_config = { {
  24. { 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, NO_LED, 74, 73, 72 },
  25. { 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71 },
  26. { 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38 },
  27. { 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, NO_LED, 37, NO_LED, NO_LED, NO_LED },
  28. { 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, NO_LED, 10, NO_LED },
  29. { 0, 1, 2, NO_LED, NO_LED, 3, NO_LED, NO_LED, NO_LED, NO_LED, 4, 5, 6, NO_LED, 7, 8, 9 }
  30. }, {
  31. // Key matrix (0 -> 87)
  32. {3 , 64}, {19 , 64}, {36 , 64}, {91 , 64}, {146, 64}, {162, 64}, {179, 64}, {198, 64}, {211, 64}, {224, 64},
  33. {211, 52}, {182, 52}, {170, 52}, {146, 52}, {133, 52}, {120, 52}, {107, 52}, {94 , 52}, {81 , 52}, {68 , 52}, {55 , 52}, {42 , 52}, {29 , 52}, {16 , 52}, {2 , 52},
  34. {2 , 41}, {23 , 41}, {36 , 41}, {49 , 41}, {62 , 41}, {75 , 41}, {88 , 41}, {101, 41}, {114, 41}, {127, 41}, {140, 41}, {153, 41}, {174, 41},
  35. {224, 29}, {211, 29}, {198, 29}, {179, 29}, {162, 29}, {149, 29}, {136, 29}, {123, 29}, {110, 29}, {97 , 29}, {84 , 29}, {71 , 29}, {58 , 29}, {45 , 29}, {32 , 29}, {19 , 29}, {3 , 29},
  36. {0 , 17}, {13 , 17}, {26 , 17}, {39 , 17}, {52 , 17}, {65 , 17}, {78 , 17}, {91 , 17}, {104, 17}, {117, 17}, {130, 17}, {143, 17}, {156, 17}, {175, 17}, {198, 17}, {211, 17}, {224, 17},
  37. {224, 0}, {211, 0}, {198, 0}, {182, 0}, {169, 0}, {156, 0}, {143, 0}, {123, 0}, {110, 0}, {97 , 0}, {84 , 0}, {65 , 0}, {52 , 0}, {39 , 0}, {26 , 0}, {0 , 0},
  38. // Underglow (88 -> 99)
  39. {1 , 6}, {50 , 6}, {89 , 6}, {135, 6}, {176, 6}, {198, 6}, {221, 55}, {192, 58}, {138, 59}, {96 , 61}, {42 , 59}, {7 , 60},
  40. }, {
  41. // Key matrix (0 -> 87)
  42. 1, 1, 1, 4, 1, 1, 1, 4, 4, 4,
  43. 4, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
  44. 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
  45. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
  46. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 4, 4, 4,
  47. 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
  48. // Underglow (88 -> 99)
  49. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  50. } };
  51. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  52. switch (keycode) {
  53. case QK_RGB_MATRIX_TOGGLE:
  54. if (record->event.pressed) {
  55. switch (rgb_matrix_get_flags()) {
  56. case LED_FLAG_ALL: {
  57. rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR);
  58. rgb_matrix_set_color_all(0, 0, 0);
  59. }
  60. break;
  61. case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): {
  62. rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
  63. rgb_matrix_set_color_all(0, 0, 0);
  64. }
  65. break;
  66. case (LED_FLAG_UNDERGLOW): {
  67. rgb_matrix_set_flags(LED_FLAG_NONE);
  68. rgb_matrix_set_color_all(0, 0, 0);
  69. }
  70. break;
  71. default: {
  72. rgb_matrix_set_flags(LED_FLAG_ALL);
  73. rgb_matrix_enable_noeeprom();
  74. }
  75. break;
  76. }
  77. }
  78. return false;
  79. }
  80. return process_record_user(keycode, record);
  81. }
  82. bool rgb_matrix_indicators_kb(void) {
  83. if (!rgb_matrix_indicators_user()) {
  84. return false;
  85. }
  86. hsv_t hsv = rgb_matrix_config.hsv;
  87. uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1));
  88. hsv.h = time;
  89. rgb_t rgb = hsv_to_rgb(hsv);
  90. if (host_keyboard_led_state().caps_lock) {
  91. rgb_matrix_set_color(25, rgb.r, rgb.g, rgb.b);
  92. } else if (!(rgb_matrix_get_flags() & LED_FLAG_INDICATOR)) {
  93. rgb_matrix_set_color(25, 0, 0, 0);
  94. }
  95. if (host_keyboard_led_state().scroll_lock) {
  96. rgb_matrix_set_color(73, rgb.r, rgb.g, rgb.b);
  97. } else if (!(rgb_matrix_get_flags() & LED_FLAG_INDICATOR)) {
  98. rgb_matrix_set_color(73, 0, 0, 0);
  99. }
  100. return true;
  101. }
  102. #endif
  103. #ifdef OLED_ENABLE
  104. uint16_t startup_timer;
  105. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  106. startup_timer = timer_read();
  107. return rotation;
  108. }
  109. bool oled_task_kb(void) {
  110. static bool finished_logo = false;
  111. if ((timer_elapsed(startup_timer) < 5000) && !finished_logo) {
  112. render_logo();
  113. } else {
  114. finished_logo = true;
  115. if (!oled_task_user()) {
  116. return false;
  117. }
  118. }
  119. return true;
  120. }
  121. #endif