ymdk_np21.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 "ymdk_np21.h"
  16. #include <avr/pgmspace.h>
  17. #include "action_layer.h"
  18. #include "quantum.h"
  19. #include "i2c.h"
  20. #include "backlight.h"
  21. #include "backlight_custom.h"
  22. extern rgblight_config_t rgblight_config;
  23. // for keyboard subdirectory level init functions
  24. // @Override
  25. void matrix_init_kb(void) {
  26. // call user level keymaps, if any
  27. // matrix_init_user();
  28. }
  29. #ifdef BACKLIGHT_ENABLE
  30. /// Overrides functions in `quantum.c`
  31. void backlight_init_ports(void) {
  32. b_led_init_ports();
  33. }
  34. void backlight_task(void) {
  35. b_led_task();
  36. }
  37. void backlight_set(uint8_t level) {
  38. b_led_set(level);
  39. }
  40. #endif
  41. // custom RGB driver
  42. void rgblight_set(void) {
  43. if (!rgblight_config.enable) {
  44. for (uint8_t i=0; i<RGBLED_NUM; i++) {
  45. led[i].r = 0;
  46. led[i].g = 0;
  47. led[i].b = 0;
  48. }
  49. }
  50. i2c_init();
  51. i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
  52. }
  53. bool rgb_init = false;
  54. void matrix_scan_user(void) {
  55. // if LEDs were previously on before poweroff, turn them back on
  56. if (rgb_init == false && rgblight_config.enable) {
  57. i2c_init();
  58. i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
  59. rgb_init = true;
  60. }
  61. rgblight_task();
  62. /* Nothing else for now. */
  63. }