aboutsummaryrefslogtreecommitdiff
path: root/drivers/led/issi/is31fl3741-simple.c
diff options
context:
space:
mode:
authorRyan <[email protected]>2023-11-01 11:53:45 +1100
committerGitHub <[email protected]>2023-11-01 00:53:45 +0000
commitb52aca0af83fade24c56b4bb7369f18183123bd3 (patch)
tree9b553c4b771717cc334f3c8683052bc701472c4d /drivers/led/issi/is31fl3741-simple.c
parenteac8e6788871a087eafdc5492eee425a7205d727 (diff)
downloadqmk_firmware-b52aca0af83fade24c56b4bb7369f18183123bd3.tar.gz
qmk_firmware-b52aca0af83fade24c56b4bb7369f18183123bd3.zip
Relocate LED driver init code (#22365)
Diffstat (limited to 'drivers/led/issi/is31fl3741-simple.c')
-rw-r--r--drivers/led/issi/is31fl3741-simple.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/drivers/led/issi/is31fl3741-simple.c b/drivers/led/issi/is31fl3741-simple.c
index c7335866ec..8e77a6446d 100644
--- a/drivers/led/issi/is31fl3741-simple.c
+++ b/drivers/led/issi/is31fl3741-simple.c
@@ -143,6 +143,36 @@ bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
return true;
}
+void is31fl3741_init_drivers(void) {
+ i2c_init();
+
+ is31fl3741_init(IS31FL3741_I2C_ADDRESS_1);
+#if defined(IS31FL3741_I2C_ADDRESS_2)
+ is31fl3741_init(IS31FL3741_I2C_ADDRESS_2);
+# if defined(IS31FL3741_I2C_ADDRESS_3)
+ is31fl3741_init(IS31FL3741_I2C_ADDRESS_3);
+# if defined(IS31FL3741_I2C_ADDRESS_4)
+ is31fl3741_init(IS31FL3741_I2C_ADDRESS_4);
+# endif
+# endif
+#endif
+
+ for (int i = 0; i < IS31FL3741_LED_COUNT; i++) {
+ is31fl3741_set_led_control_register(i, true);
+ }
+
+ is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_1, 0);
+#if defined(IS31FL3741_I2C_ADDRESS_2)
+ is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_2, 1);
+# if defined(IS31FL3741_I2C_ADDRESS_3)
+ is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_3, 2);
+# if defined(IS31FL3741_I2C_ADDRESS_4)
+ is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_4, 3);
+# endif
+# endif
+#endif
+}
+
void is31fl3741_init(uint8_t addr) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, shutdown is enabled last.
@@ -174,7 +204,7 @@ void is31fl3741_init(uint8_t addr) {
void is31fl3741_set_value(int index, uint8_t value) {
is31fl3741_led_t led;
- if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
+ if (index >= 0 && index < IS31FL3741_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3741_leds[index]), sizeof(led));
if (g_pwm_buffer[led.driver][led.v] == value) {
@@ -186,7 +216,7 @@ void is31fl3741_set_value(int index, uint8_t value) {
}
void is31fl3741_set_value_all(uint8_t value) {
- for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
+ for (int i = 0; i < IS31FL3741_LED_COUNT; i++) {
is31fl3741_set_value(i, value);
}
}