[BUG] Allow multiple IS31FL3741 drivers per board in rgb_matrix (#20988)

This commit is contained in:
André Greiner-Petter 2023-05-27 12:26:14 +09:00 committed by GitHub
parent 5642bd1807
commit 249fb3c2c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View file

@ -104,11 +104,11 @@ void IS31FL3741_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
} }
bool IS31FL3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { bool IS31FL3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// Assume PG1 is already selected // Assume PG0 is already selected
for (int i = 0; i < 342; i += 18) { for (int i = 0; i < 342; i += 18) {
if (i == 180) { if (i == 180) {
// unlock the command register and select PG2 // unlock the command register and select PG1
IS31FL3741_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5); IS31FL3741_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
IS31FL3741_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM1); IS31FL3741_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM1);
} }
@ -246,7 +246,7 @@ void IS31FL3741_update_led_control_registers(uint8_t addr, uint8_t index) {
// CS1_SW1 to CS30_SW6 are on PG2 // CS1_SW1 to CS30_SW6 are on PG2
for (int i = CS1_SW1; i <= CS30_SW6; ++i) { for (int i = CS1_SW1; i <= CS30_SW6; ++i) {
IS31FL3741_write_register(addr, i, g_scaling_registers[0][i]); IS31FL3741_write_register(addr, i, g_scaling_registers[index][i]);
} }
// unlock the command register and select PG3 // unlock the command register and select PG3
@ -255,7 +255,7 @@ void IS31FL3741_update_led_control_registers(uint8_t addr, uint8_t index) {
// CS1_SW7 to CS39_SW9 are on PG3 // CS1_SW7 to CS39_SW9 are on PG3
for (int i = CS1_SW7; i <= CS39_SW9; ++i) { for (int i = CS1_SW7; i <= CS39_SW9; ++i) {
IS31FL3741_write_register(addr, i - CS1_SW7, g_scaling_registers[0][i]); IS31FL3741_write_register(addr, i - CS1_SW7, g_scaling_registers[index][i]);
} }
g_scaling_registers_update_required[index] = false; g_scaling_registers_update_required[index] = false;

View file

@ -98,6 +98,15 @@ static void init(void) {
# elif defined(IS31FL3741) # elif defined(IS31FL3741)
IS31FL3741_init(DRIVER_ADDR_1); IS31FL3741_init(DRIVER_ADDR_1);
# if defined(DRIVER_ADDR_2)
IS31FL3741_init(DRIVER_ADDR_2);
# if defined(DRIVER_ADDR_3)
IS31FL3741_init(DRIVER_ADDR_3);
# if defined(DRIVER_ADDR_4)
IS31FL3741_init(DRIVER_ADDR_4);
# endif
# endif
# endif
# elif defined(IS31FLCOMMON) # elif defined(IS31FLCOMMON)
IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1); IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1);
@ -196,6 +205,15 @@ static void init(void) {
# elif defined(IS31FL3741) # elif defined(IS31FL3741)
IS31FL3741_update_led_control_registers(DRIVER_ADDR_1, 0); IS31FL3741_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
IS31FL3741_update_led_control_registers(DRIVER_ADDR_2, 1);
# if defined(DRIVER_ADDR_3)
IS31FL3741_update_led_control_registers(DRIVER_ADDR_3, 2);
# if defined(DRIVER_ADDR_4)
IS31FL3741_update_led_control_registers(DRIVER_ADDR_4, 3);
# endif
# endif
# endif
# elif defined(IS31FLCOMMON) # elif defined(IS31FLCOMMON)
# ifdef ISSI_MANUAL_SCALING # ifdef ISSI_MANUAL_SCALING
@ -315,6 +333,12 @@ static void flush(void) {
IS31FL3741_update_pwm_buffers(DRIVER_ADDR_1, 0); IS31FL3741_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2) # if defined(DRIVER_ADDR_2)
IS31FL3741_update_pwm_buffers(DRIVER_ADDR_2, 1); IS31FL3741_update_pwm_buffers(DRIVER_ADDR_2, 1);
# if defined(DRIVER_ADDR_3)
IS31FL3741_update_pwm_buffers(DRIVER_ADDR_3, 2);
# if defined(DRIVER_ADDR_4)
IS31FL3741_update_pwm_buffers(DRIVER_ADDR_4, 3);
# endif
# endif
# endif # endif
} }