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.

54 lines
1.8 KiB

  1. /* Copyright 2021 Andrew Fahmy
  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. #ifdef RGB_MATRIX_ENABLE
  17. # include "rgb_matrix.h"
  18. # include "i2c_master.h"
  19. # include "is31fl3733-dual.h"
  20. # include "gpio.h"
  21. static void init(void) {
  22. i2c_init(&I2CD1, I2C1_SCL_PIN, I2C1_SDA_PIN);
  23. is31fl3733_init(0, IS31FL3733_I2C_ADDRESS_1, 0);
  24. # ifdef USE_I2C2
  25. i2c_init(&I2CD2, I2C2_SCL_PIN, I2C2_SDA_PIN);
  26. is31fl3733_init(1, IS31FL3733_I2C_ADDRESS_2, 0);
  27. # endif
  28. for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) {
  29. bool enabled = true;
  30. // This only caches it for later
  31. is31fl3733_set_led_control_register(index, enabled, enabled, enabled);
  32. }
  33. is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0);
  34. # ifdef USE_I2C2
  35. is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1);
  36. # endif
  37. }
  38. static void flush(void) {
  39. is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_1, 0);
  40. # ifdef USE_I2C2
  41. is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_2, 1);
  42. # endif
  43. }
  44. const rgb_matrix_driver_t rgb_matrix_driver = {
  45. .init = init,
  46. .flush = flush,
  47. .set_color = is31fl3733_set_color,
  48. .set_color_all = is31fl3733_set_color_all,
  49. };
  50. #endif