From b52aca0af83fade24c56b4bb7369f18183123bd3 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 1 Nov 2023 11:53:45 +1100 Subject: Relocate LED driver init code (#22365) --- drivers/led/snled27351-simple.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'drivers/led/snled27351-simple.c') diff --git a/drivers/led/snled27351-simple.c b/drivers/led/snled27351-simple.c index 882fe4e8b4..c274506f83 100644 --- a/drivers/led/snled27351-simple.c +++ b/drivers/led/snled27351-simple.c @@ -99,6 +99,34 @@ bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { return true; } +void snled27351_init_drivers(void) { + snled27351_init(SNLED27351_I2C_ADDRESS_1); +#if defined(SNLED27351_I2C_ADDRESS_2) + snled27351_init(SNLED27351_I2C_ADDRESS_2); +# if defined(SNLED27351_I2C_ADDRESS_3) + snled27351_init(SNLED27351_I2C_ADDRESS_3); +# if defined(SNLED27351_I2C_ADDRESS_4) + snled27351_init(SNLED27351_I2C_ADDRESS_4); +# endif +# endif +#endif + + for (int i = 0; i < SNLED27351_LED_COUNT; i++) { + snled27351_set_led_control_register(i, true); + } + + snled27351_update_led_control_registers(SNLED27351_I2C_ADDRESS_1, 0); +#if defined(SNLED27351_I2C_ADDRESS_2) + snled27351_update_led_control_registers(SNLED27351_I2C_ADDRESS_2, 1); +# if defined(SNLED27351_I2C_ADDRESS_3) + snled27351_update_led_control_registers(SNLED27351_I2C_ADDRESS_3, 2); +# if defined(SNLED27351_I2C_ADDRESS_4) + snled27351_update_led_control_registers(SNLED27351_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void snled27351_init(uint8_t addr) { // Select to function page snled27351_write_register(addr, SNLED27351_REG_CONFIGURE_CMD_PAGE, SNLED27351_FUNCTION_PAGE); @@ -147,7 +175,7 @@ void snled27351_init(uint8_t addr) { void snled27351_set_value(int index, uint8_t value) { snled27351_led_t led; - if (index >= 0 && index < LED_MATRIX_LED_COUNT) { + if (index >= 0 && index < SNLED27351_LED_COUNT) { memcpy_P(&led, (&g_snled27351_leds[index]), sizeof(led)); if (g_pwm_buffer[led.driver][led.v] == value) { @@ -159,7 +187,7 @@ void snled27351_set_value(int index, uint8_t value) { } void snled27351_set_value_all(uint8_t value) { - for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < SNLED27351_LED_COUNT; i++) { snled27351_set_value(i, value); } } -- cgit v1.2.3