rgb_functions.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright 2021 Drashna Jael're
  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 "rgb_functions.h"
  17. #include <stdint.h>
  18. #include "quantum.h"
  19. #include "action.h"
  20. #include "rgblight.h"
  21. #include "rgb_matrix.h"
  22. #ifdef RGBLIGHT_ENABLE
  23. #undef WS2812_DI_PIN
  24. #define WS2812_DI_PIN RGBLIGHT_DI_PIN
  25. #define ws2812_init ws2812_rgb_init
  26. #define ws2812_setleds ws2812_rgb_setleds
  27. #include "ws2812_bitbang.c"
  28. const rgblight_driver_t rgblight_driver = {
  29. .init = ws2812_init,
  30. .setleds = ws2812_setleds,
  31. };
  32. #endif
  33. #ifdef RGB_MATRIX_ENABLE
  34. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  35. if (!process_record_user(keycode, record)) { return false; }
  36. if (record->event.pressed) {
  37. switch(keycode) {
  38. case RGB_MATRIX_TOGGLE: // toggle rgb matrix
  39. rgb_matrix_toggle();
  40. return false;
  41. case RGB_MATRIX_MODE_INC:
  42. rgb_matrix_step();
  43. return false;
  44. case RGB_MATRIX_MODE_DEC:
  45. rgb_matrix_step_reverse();
  46. return false;
  47. case RGB_MATRIX_HUE_INC:
  48. rgb_matrix_increase_hue();
  49. return false;
  50. case RGB_MATRIX_HUE_DEC:
  51. rgb_matrix_decrease_hue();
  52. return false;
  53. case RGB_MATRIX_SAT_INC:
  54. rgb_matrix_increase_sat();
  55. return false;
  56. case RGB_MATRIX_SAT_DEC:
  57. rgb_matrix_decrease_sat();
  58. return false;
  59. case RGB_MATRIX_VAL_INC:
  60. rgb_matrix_increase_val();
  61. return false;
  62. case RGB_MATRIX_VAL_DEC:
  63. rgb_matrix_decrease_val();
  64. return false;
  65. default:
  66. break;
  67. }
  68. }
  69. return true;
  70. }
  71. #endif