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.

97 lines
2.1 KiB

  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 "ymd96.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. // for keyboard subdirectory level init functions
  23. // @Override
  24. void matrix_init_kb(void) {
  25. // call user level keymaps, if any
  26. matrix_init_user();
  27. }
  28. #ifdef BACKLIGHT_ENABLE
  29. /// Overrides functions in `quantum.c`
  30. void backlight_init_ports(void) {
  31. b_led_init_ports();
  32. }
  33. void backlight_task(void) {
  34. b_led_task();
  35. }
  36. void backlight_set(uint8_t level) {
  37. b_led_set(level);
  38. }
  39. #endif
  40. #ifdef RGBLIGHT_ENABLE
  41. extern rgblight_config_t rgblight_config;
  42. // custom RGB driver
  43. void rgblight_set(void) {
  44. if (!rgblight_config.enable) {
  45. for (uint8_t i=0; i<RGBLED_NUM; i++) {
  46. led[i].r = 0;
  47. led[i].g = 0;
  48. led[i].b = 0;
  49. }
  50. }
  51. i2c_init();
  52. i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
  53. }
  54. bool rgb_init = false;
  55. void matrix_scan_kb(void) {
  56. // if LEDs were previously on before poweroff, turn them back on
  57. if (rgb_init == false && rgblight_config.enable) {
  58. i2c_init();
  59. i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
  60. rgb_init = true;
  61. }
  62. rgblight_task();
  63. #else
  64. void matrix_scan_kb(void) {
  65. #endif
  66. matrix_scan_user();
  67. /* Nothing else for now. */
  68. }
  69. __attribute__((weak)) // overridable
  70. void matrix_init_user(void) {
  71. }
  72. __attribute__((weak)) // overridable
  73. void matrix_scan_user(void) {
  74. }