You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.6 KiB

  1. /* Copyright 2019 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_NK65
  17. #error RGB_BACKLIGHT_NK65 not defined, recheck config.h
  18. #endif
  19. #include "nk65.h"
  20. #include "drivers/led/issi/is31fl3733.h"
  21. /* Indicator LEDS are part of the LED driver
  22. * Top LED is blue only. LED driver 2 RGB 7 Green channel
  23. * Middle LED is blue and red. LED driver 2 RGB 6 Red and Blue channel
  24. * Bottom LED is red only LED driver 2 RGB 6 Green channel.
  25. */
  26. bool led_update_kb(led_t led_state) {
  27. bool res = led_update_user(led_state);
  28. if(res) {
  29. if (led_state.caps_lock) {
  30. IS31FL3733_set_color( 7+64-1, 0, 255, 0 );
  31. } else {
  32. IS31FL3733_set_color( 7+64-1, 0, 0, 0 );
  33. }
  34. }
  35. return res;
  36. }
  37. __attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
  38. uint8_t R = 0;
  39. uint8_t G = 0;
  40. uint8_t B = 0;
  41. if (state & (1UL << 1)) {
  42. R = 255;
  43. B = 255;
  44. }
  45. if (state & (1UL << 2)) {
  46. G = 255;
  47. }
  48. IS31FL3733_set_color( 6+64-1, R, G, B );
  49. return state;
  50. }