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.

74 lines
1.7 KiB

  1. /*
  2. Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
  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. */
  14. #include <string.h>
  15. #include "rgblight.h"
  16. #include "i2c.h"
  17. #include "quantum.h"
  18. #ifdef RGBLIGHT_ENABLE
  19. extern rgblight_config_t rgblight_config;
  20. void rgblight_set(void) {
  21. if (!rgblight_config.enable) {
  22. for (uint8_t i = 0; i < RGBLED_NUM; i++) {
  23. led[i].r = 0;
  24. led[i].g = 0;
  25. led[i].b = 0;
  26. }
  27. }
  28. i2c_init();
  29. i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
  30. }
  31. #endif
  32. __attribute__ ((weak))
  33. void matrix_scan_user(void) {
  34. }
  35. void backlight_init_ports(void) {
  36. // initialize pins D0, D1, D4 and D6 as output
  37. setPinOutput(D0);
  38. setPinOutput(D1);
  39. setPinOutput(D4);
  40. setPinOutput(D6);
  41. // turn RGB LEDs on
  42. writePinHigh(D0);
  43. writePinHigh(D1);
  44. writePinHigh(D4);
  45. writePinHigh(D6);
  46. }
  47. void backlight_set(uint8_t level) {
  48. if (level == 0) {
  49. // turn RGB LEDs off
  50. writePinLow(D0);
  51. writePinLow(D1);
  52. writePinLow(D4);
  53. writePinLow(D6);
  54. } else {
  55. // turn RGB LEDs on
  56. writePinHigh(D0);
  57. writePinHigh(D1);
  58. writePinHigh(D4);
  59. writePinHigh(D6);
  60. }
  61. }