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.

57 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. static void init(void) {
  21. i2c_init(&I2CD1, I2C1_SCL_BANK, I2C1_SDA_BANK, I2C1_SCL, I2C1_SDA);
  22. IS31FL3733_init(0, DRIVER_ADDR_1, 0);
  23. # ifdef USE_I2C2
  24. i2c_init(&I2CD2, I2C2_SCL_BANK, I2C2_SDA_BANK, I2C2_SCL, I2C2_SDA);
  25. IS31FL3733_init(1, DRIVER_ADDR_2, 0);
  26. # endif
  27. for (int index = 0; index < DRIVER_LED_TOTAL; index++) {
  28. bool enabled = true;
  29. // This only caches it for later
  30. IS31FL3733_set_led_control_register(index, enabled, enabled, enabled);
  31. }
  32. IS31FL3733_update_led_control_registers(DRIVER_ADDR_1, 0);
  33. # ifdef USE_I2C2
  34. IS31FL3733_update_led_control_registers(DRIVER_ADDR_2, 1);
  35. # endif
  36. }
  37. static void flush(void) {
  38. IS31FL3733_update_pwm_buffers(DRIVER_ADDR_1, 0);
  39. # ifdef USE_I2C2
  40. IS31FL3733_update_pwm_buffers(DRIVER_ADDR_2, 1);
  41. # endif
  42. }
  43. const rgb_matrix_driver_t rgb_matrix_driver = {
  44. .init = init,
  45. .flush = flush,
  46. .set_color = IS31FL3733_set_color,
  47. .set_color_all = IS31FL3733_set_color_all,
  48. };
  49. #endif