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.

88 lines
2.1 KiB

  1. /* Copyright 2018 amnesia0287
  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. #include "rgblight.h"
  17. #include "i2c_master.h"
  18. #include "quantum.h"
  19. #ifdef RGBLIGHT_ENABLE
  20. extern rgblight_config_t rgblight_config;
  21. void rgblight_set(void) {
  22. if (!rgblight_config.enable) {
  23. for (uint8_t i = 0; i < RGBLED_NUM; i++) {
  24. led[i].r = 0;
  25. led[i].g = 0;
  26. led[i].b = 0;
  27. }
  28. }
  29. i2c_init();
  30. i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
  31. }
  32. #endif
  33. void matrix_init_kb(void) {
  34. #ifdef RGBLIGHT_ENABLE
  35. if (rgblight_config.enable) {
  36. i2c_init();
  37. i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
  38. }
  39. #endif
  40. // call user level keymaps, if any
  41. matrix_init_user();
  42. }
  43. void matrix_scan_kb(void) {
  44. #ifdef RGBLIGHT_ENABLE
  45. rgblight_task();
  46. #endif
  47. matrix_scan_user();
  48. /* Nothing else for now. */
  49. }
  50. __attribute__ ((weak))
  51. void matrix_scan_user(void) {
  52. }
  53. void backlight_init_ports(void) {
  54. // initialize pins D0, D1, D4 and D6 as output
  55. setPinOutput(D0);
  56. setPinOutput(D1);
  57. setPinOutput(D4);
  58. setPinOutput(D6);
  59. // turn backlight LEDs on
  60. writePinHigh(D0);
  61. writePinHigh(D1);
  62. writePinHigh(D4);
  63. writePinHigh(D6);
  64. }
  65. void backlight_set(uint8_t level) {
  66. if (level == 0) {
  67. // turn backlight LEDs off
  68. writePinLow(D0);
  69. writePinLow(D1);
  70. writePinLow(D4);
  71. writePinLow(D6);
  72. } else {
  73. // turn backlight LEDs on
  74. writePinHigh(D0);
  75. writePinHigh(D1);
  76. writePinHigh(D4);
  77. writePinHigh(D6);
  78. }
  79. }