singa.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. __attribute__ ((weak))
  34. void matrix_scan_user(void) {
  35. }
  36. void backlight_init_ports(void) {
  37. // initialize pins D0, D1, D4 and D6 as output
  38. setPinOutput(D0);
  39. setPinOutput(D1);
  40. setPinOutput(D4);
  41. setPinOutput(D6);
  42. // turn RGB LEDs on
  43. writePinHigh(D0);
  44. writePinHigh(D1);
  45. writePinHigh(D4);
  46. writePinHigh(D6);
  47. }
  48. void backlight_set(uint8_t level) {
  49. if (level == 0) {
  50. // turn RGB LEDs off
  51. writePinLow(D0);
  52. writePinLow(D1);
  53. writePinLow(D4);
  54. writePinLow(D6);
  55. } else {
  56. // turn RGB LEDs on
  57. writePinHigh(D0);
  58. writePinHigh(D1);
  59. writePinHigh(D4);
  60. writePinHigh(D6);
  61. }
  62. }