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.

61 lines
1.7 KiB

  1. /* Copyright 2020 B. Fletcher (toraifu) <typefast@kyaa.gg>
  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 "indicators.h"
  17. #include "drivers/led/issi/is31fl3731-simple.h"
  18. #include "i2c_master.h"
  19. /* Set up IS31FL3731 for use in powering indicator LEDs. Absolutely overkill for this job but it was already in the design.
  20. * init IS31FL3731 and i2c
  21. */
  22. void init_fallacy_leds(void) {
  23. i2c_init();
  24. IS31FL3731_init(LED_DRIVER_ADDR_1);
  25. for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
  26. IS31FL3731_set_led_control_register(i, true);
  27. }
  28. IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
  29. }
  30. /* update the buffer
  31. */
  32. void update_fallacy_leds(void) {
  33. IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
  34. }
  35. /* wrapper to actually set the LED PWM
  36. */
  37. void set_fallacy_led(int index, bool state) {
  38. if (state) {
  39. IS31FL3731_set_value(index, 128);
  40. }
  41. else {
  42. IS31FL3731_set_value(index, 0);
  43. }
  44. }
  45. /* define LED matrix
  46. */
  47. const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
  48. {0, C1_1},
  49. {0, C2_1},
  50. {0, C3_1},
  51. };