jj40.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
  3. Modified 2018 Kenneth A. <github.com/krusli>
  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. 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. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #include "jj40.h"
  16. #ifdef RGBLIGHT_ENABLE
  17. #include <string.h>
  18. #include "i2c_master.h"
  19. #include "rgblight.h"
  20. extern rgblight_config_t rgblight_config;
  21. void matrix_init_kb(void) {
  22. i2c_init();
  23. // call user level keymaps, if any
  24. matrix_init_user();
  25. }
  26. // custom RGB driver
  27. void rgblight_set(void) {
  28. if (!rgblight_config.enable) {
  29. memset(led, 0, 3 * RGBLED_NUM);
  30. }
  31. i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
  32. }
  33. bool rgb_init = false;
  34. void matrix_scan_kb(void) {
  35. // if LEDs were previously on before poweroff, turn them back on
  36. if (rgb_init == false && rgblight_config.enable) {
  37. i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
  38. rgb_init = true;
  39. }
  40. rgblight_task();
  41. matrix_scan_user();
  42. }
  43. #endif