skog.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Copyright 2018 Jumail Mundekkat / MxBlue
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ps2avrGB support code by Kenneth A. (bminiex/.[ch])
  14. */
  15. #include "skog.h"
  16. #include "rgblight.h"
  17. #include <avr/pgmspace.h>
  18. #include "action_layer.h"
  19. #include "i2c.h"
  20. #include "quantum.h"
  21. #include "backlight.h"
  22. #include "backlight_custom.h"
  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. #ifdef RGBLIGHT_ENABLE
  42. extern rgblight_config_t rgblight_config;
  43. // custom RGB driver
  44. void rgblight_set(void) {
  45. if (!rgblight_config.enable) {
  46. for (uint8_t i=0; i<RGBLED_NUM; i++) {
  47. led[i].r = 0;
  48. led[i].g = 0;
  49. led[i].b = 0;
  50. }
  51. }
  52. i2c_init();
  53. i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
  54. }
  55. bool rgb_init = false;
  56. void matrix_scan_kb(void) {
  57. // if LEDs were previously on before poweroff, turn them back on
  58. if (rgb_init == false && rgblight_config.enable) {
  59. i2c_init();
  60. i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
  61. rgb_init = true;
  62. }
  63. rgblight_task();
  64. #else
  65. void matrix_scan_kb(void) {
  66. #endif
  67. matrix_scan_user();
  68. /* Nothing else for now. */
  69. }
  70. __attribute__((weak)) // overridable
  71. void matrix_init_user(void) {
  72. }
  73. __attribute__((weak)) // overridable
  74. void matrix_scan_user(void) {
  75. }