logo

qmk_firmware

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

pila87.c (4472B)


  1. /* Copyright 2023 Phage Studio
  2. * Copyright 2023 HorrorTroll <https://github.com/HorrorTroll>
  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 "quantum.h"
  18. #ifdef RGB_MATRIX_ENABLE
  19. #include <string.h>
  20. #include <math.h>
  21. #include <lib/lib8tion/lib8tion.h>
  22. led_config_t g_led_config = { {
  23. { 75, NO_LED, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90 },
  24. { 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58 },
  25. { 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 },
  26. { 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, NO_LED, 28, NO_LED, NO_LED, NO_LED },
  27. { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, NO_LED, NO_LED, 26, NO_LED, 27, NO_LED },
  28. { 14, 13, 12, 11, 10, 9, 8, 7, NO_LED, NO_LED, 6, 5, 4, 3, 2, 1, 0 }
  29. }, {
  30. {224, 64}, {211, 64}, {198, 64}, {180, 64}, {164, 64}, {148, 64}, {131, 64}, {110, 61}, {104, 61}, {83 , 64}, {65 , 61}, {58 , 61}, {34 , 64}, {18 , 64}, {2 , 64},
  31. {8 , 52}, {29 , 52}, {42 , 52}, {55 , 52}, {68 , 52}, {81 , 52}, {94 , 52}, {107, 52}, {120, 52}, {133, 52}, {146, 52}, {170, 52}, {211, 52},
  32. {174, 41}, {153, 41}, {140, 41}, {127, 41}, {114, 41}, {101, 41}, {88 , 41}, {75 , 41}, {62 , 41}, {49 , 41}, {36 , 41}, {23 , 41}, {5 , 41},
  33. {3 , 29}, {19 , 29}, {32 , 29}, {45 , 29}, {58 , 29}, {71 , 29}, {84 , 29}, {97 , 29}, {110, 29}, {123, 29}, {136, 29}, {149, 29}, {162, 29}, {179, 29}, {198, 29}, {211, 29}, {224, 29},
  34. {224, 17}, {211, 17}, {198, 17}, {175, 17}, {156, 17}, {143, 17}, {130, 17}, {117, 17}, {104, 17}, {91 , 17}, {78 , 17}, {65 , 17}, {52 , 17}, {39 , 17}, {26 , 17}, {13 , 17}, {0 , 17},
  35. {0 , 0}, {26 , 0}, {39 , 0}, {52 , 0}, {65 , 0}, {84 , 0}, {97 , 0}, {110, 0}, {123, 0}, {143, 0}, {156, 0}, {169, 0}, {182, 0}, {198, 0}, {211, 0}, {224, 0},
  36. }, {
  37. 4, 4, 4, 1, 1, 1, 1, 4, 4, 4, 4, 4, 1, 1, 1,
  38. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 4,
  39. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8,
  40. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  41. 4, 4, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  42. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 4,
  43. } };
  44. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  45. switch (keycode) {
  46. case QK_RGB_MATRIX_TOGGLE:
  47. if (record->event.pressed) {
  48. switch (rgb_matrix_get_flags()) {
  49. case LED_FLAG_ALL: {
  50. rgb_matrix_set_flags(LED_FLAG_NONE);
  51. rgb_matrix_set_color_all(0, 0, 0);
  52. }
  53. break;
  54. default: {
  55. rgb_matrix_set_flags(LED_FLAG_ALL);
  56. rgb_matrix_enable_noeeprom();
  57. }
  58. break;
  59. }
  60. }
  61. return false;
  62. }
  63. return process_record_user(keycode, record);
  64. }
  65. bool rgb_matrix_indicators_kb(void) {
  66. if (!rgb_matrix_indicators_user()) {
  67. return false;
  68. }
  69. hsv_t hsv = rgb_matrix_config.hsv;
  70. uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1));
  71. hsv.h = time;
  72. rgb_t rgb = hsv_to_rgb(hsv);
  73. if (host_keyboard_led_state().caps_lock) {
  74. rgb_matrix_set_color(40, rgb.r, rgb.g, rgb.b);
  75. } else if (!(rgb_matrix_get_flags() & LED_FLAG_INDICATOR)) {
  76. rgb_matrix_set_color(40, 0, 0, 0);
  77. }
  78. return true;
  79. }
  80. #endif