is31fl3741.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Copyright 2017 Jason Williams
  2. * Copyright 2018 Jack Humbert
  3. * Copyright 2018 Yiancar
  4. * Copyright 2020 MelGeek
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #pragma once
  20. #include <stdint.h>
  21. #include <stdbool.h>
  22. typedef struct is31_led {
  23. uint8_t driver : 2;
  24. uint8_t rcs;
  25. uint8_t rsw;
  26. uint8_t gcs;
  27. uint8_t gsw;
  28. uint8_t bcs;
  29. uint8_t bsw;
  30. } __attribute__((packed)) is31_led;
  31. extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
  32. extern const is31_led g_is31_indicator_leds[DRIVER_INDICATOR_LED_TOTAL];
  33. void IS31FL3741_init(uint8_t addr);
  34. void IS31FL3741_write_register(uint8_t addr, uint8_t reg, uint8_t data);
  35. bool IS31FL3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
  36. void IS31FL3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
  37. void IS31FL3741_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
  38. void IS31FL3741_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
  39. // This should not be called from an interrupt
  40. // (eg. from a timer interrupt).
  41. // Call this while idle (in between matrix scans).
  42. // If the buffer is dirty, it will update the driver with the buffer.
  43. void IS31FL3741_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
  44. void IS31FL3741_update_led_control_registers(uint8_t addr1, uint8_t addr2);
  45. void IS31FL3741_set_scaling_registers(const is31_led *pled, uint8_t red, uint8_t green, uint8_t blue);
  46. void IS31FL3741_set_pwm_buffer(const is31_led *pled, uint8_t red, uint8_t green, uint8_t blue);