ansi.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright 2020 Yiancar
  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. #ifndef RGB_BACKLIGHT_KW_MEGA
  17. #error RGB_BACKLIGHT_KW_MEGA not defined, recheck config.h
  18. #endif
  19. #include "ansi.h"
  20. #include "drivers/issi/is31fl3733.h"
  21. uint8_t R = 0;
  22. uint8_t G = 0;
  23. uint8_t B = 0;
  24. /* Indicator LEDs are part of the LED driver
  25. * Here the LEDs are used to indicate layers 1, 2 and 3.
  26. * Below there is a commented out example of how to use the indicators for capslock.
  27. */
  28. // bool led_update_kb(led_t led_state) {
  29. // bool res = led_update_user(led_state);
  30. // if(res) {
  31. // if (led_state.caps_lock) {
  32. // G = 255;
  33. // } else {
  34. // G = 0;
  35. // }
  36. // IS31FL3733_set_color( 6+64-1, R, G, B );
  37. // }
  38. // return res;
  39. // }
  40. __attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
  41. R = 0;
  42. G = 0;
  43. B = 0;
  44. if (IS_LAYER_ON_STATE(layer_state, 1)) {
  45. G = 255;
  46. }
  47. if (IS_LAYER_ON_STATE(layer_state, 2)) {
  48. R = 255;
  49. }
  50. if (IS_LAYER_ON_STATE(layer_state, 3)) {
  51. B = 255;
  52. }
  53. IS31FL3733_set_color( 6+64-1, R, G, B );
  54. return state;
  55. }