From b52aca0af83fade24c56b4bb7369f18183123bd3 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 1 Nov 2023 11:53:45 +1100 Subject: [PATCH] Relocate LED driver init code (#22365) --- drivers/led/aw20216s.c | 11 +- drivers/led/aw20216s.h | 3 +- drivers/led/issi/is31fl3218-simple.c | 12 +- drivers/led/issi/is31fl3218-simple.h | 2 +- drivers/led/issi/is31fl3218.c | 12 +- drivers/led/issi/is31fl3218.h | 2 +- drivers/led/issi/is31fl3731-simple.c | 34 +- drivers/led/issi/is31fl3731-simple.h | 3 +- drivers/led/issi/is31fl3731.c | 34 +- drivers/led/issi/is31fl3731.h | 3 +- drivers/led/issi/is31fl3733-simple.c | 47 ++- drivers/led/issi/is31fl3733-simple.h | 7 +- drivers/led/issi/is31fl3733.c | 47 ++- drivers/led/issi/is31fl3733.h | 7 +- drivers/led/issi/is31fl3736-simple.c | 34 +- drivers/led/issi/is31fl3736-simple.h | 3 +- drivers/led/issi/is31fl3736.c | 34 +- drivers/led/issi/is31fl3736.h | 3 +- drivers/led/issi/is31fl3737-simple.c | 34 +- drivers/led/issi/is31fl3737-simple.h | 3 +- drivers/led/issi/is31fl3737.c | 34 +- drivers/led/issi/is31fl3737.h | 3 +- drivers/led/issi/is31fl3741-simple.c | 34 +- drivers/led/issi/is31fl3741-simple.h | 3 +- drivers/led/issi/is31fl3741.c | 34 +- drivers/led/issi/is31fl3741.h | 3 +- drivers/led/issi/is31flcommon.c | 70 +++++ drivers/led/issi/is31flcommon.h | 2 + drivers/led/snled27351-simple.c | 32 +- drivers/led/snled27351-simple.h | 3 +- drivers/led/snled27351.c | 32 +- drivers/led/snled27351.h | 3 +- keyboards/acheron/apollo/87h/gamma/config.h | 1 - keyboards/aeboards/satellite/rev1/config.h | 4 +- keyboards/aeboards/satellite/rev1/rev1.c | 4 +- keyboards/fallacy/config.h | 2 +- keyboards/fallacy/indicators.c | 11 +- keyboards/hs60/v2/ansi/config.h | 2 +- keyboards/hs60/v2/hhkb/config.h | 2 +- keyboards/hs60/v2/iso/config.h | 2 +- keyboards/input_club/k_type/config.h | 4 +- keyboards/input_club/k_type/i2c_master.h | 1 + keyboards/input_club/k_type/is31fl3733-dual.c | 35 ++- keyboards/input_club/k_type/is31fl3733-dual.h | 7 +- .../input_club/k_type/k_type-rgbdriver.c | 22 +- keyboards/input_club/k_type/k_type.c | 2 +- keyboards/input_club/k_type/post_rules.mk | 4 +- keyboards/keebwerk/mega/ansi/config.h | 2 +- keyboards/kprepublic/bm60hsrgb/rev2/config.h | 4 +- keyboards/kprepublic/bm60hsrgb/rev2/rev2.c | 14 +- .../kprepublic/bm60hsrgb_iso/rev2/config.h | 4 +- .../kprepublic/bm60hsrgb_iso/rev2/rev2.c | 14 +- .../kprepublic/bm60hsrgb_poker/rev2/config.h | 4 +- .../kprepublic/bm60hsrgb_poker/rev2/rev2.c | 14 +- keyboards/matrix/m20add/config.h | 2 +- keyboards/matrix/m20add/rgb_ring.c | 10 +- keyboards/neson_design/700e/700e.c | 32 +- keyboards/neson_design/700e/config.h | 2 +- keyboards/neson_design/n6/config.h | 2 +- keyboards/neson_design/n6/n6.c | 26 +- keyboards/novelkeys/nk65/config.h | 2 +- keyboards/novelkeys/nk87/config.h | 2 +- keyboards/spaceholdings/nebula12/config.h | 2 +- keyboards/spaceholdings/nebula68/config.h | 2 +- keyboards/tkc/portico/config.h | 2 +- keyboards/tkc/portico/portico.c | 2 +- keyboards/tkc/portico75/config.h | 2 +- keyboards/tkc/portico75/portico75.c | 2 +- keyboards/wilba_tech/rama_works_kara/config.h | 2 +- keyboards/wilba_tech/rama_works_koyu/config.h | 2 +- .../wilba_tech/rama_works_m10_c/config.h | 2 +- .../wilba_tech/rama_works_m50_a/config.h | 2 +- .../wilba_tech/rama_works_m60_a/config.h | 2 +- .../wilba_tech/rama_works_m65_b/config.h | 2 +- .../wilba_tech/rama_works_m65_bx/config.h | 2 +- keyboards/wilba_tech/rama_works_m6_b/config.h | 2 +- .../wilba_tech/rama_works_u80_a/config.h | 2 +- keyboards/wilba_tech/wt60_a/config.h | 2 +- keyboards/wilba_tech/wt60_b/config.h | 2 +- keyboards/wilba_tech/wt60_bx/config.h | 2 +- keyboards/wilba_tech/wt60_c/config.h | 2 +- keyboards/wilba_tech/wt65_a/config.h | 2 +- keyboards/wilba_tech/wt65_b/config.h | 2 +- keyboards/wilba_tech/wt75_a/config.h | 2 +- keyboards/wilba_tech/wt75_b/config.h | 2 +- keyboards/wilba_tech/wt75_c/config.h | 2 +- keyboards/wilba_tech/wt80_a/config.h | 2 +- keyboards/wilba_tech/wt_mono_backlight.c | 11 +- keyboards/wilba_tech/wt_rgb_backlight.c | 66 ++-- keyboards/wilba_tech/zeal60/config.h | 2 +- keyboards/wilba_tech/zeal65/config.h | 2 +- keyboards/xelus/dawn60/rev1/config.h | 2 +- keyboards/xelus/dawn60/rev1_qmk/config.h | 4 +- keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c | 34 +- keyboards/xelus/pachi/rgb/rev1/config.h | 3 +- keyboards/xelus/pachi/rgb/rev1/rev1.c | 4 +- keyboards/xelus/pachi/rgb/rev2/config.h | 3 +- keyboards/xelus/pachi/rgb/rev2/rev2.c | 4 +- quantum/led_matrix/led_matrix_drivers.c | 286 ++--------------- quantum/rgb_matrix/rgb_matrix_drivers.c | 297 ++---------------- 100 files changed, 795 insertions(+), 798 deletions(-) diff --git a/drivers/led/aw20216s.c b/drivers/led/aw20216s.c index 988cb6e9f6a..8f3ebec5108 100644 --- a/drivers/led/aw20216s.c +++ b/drivers/led/aw20216s.c @@ -126,6 +126,15 @@ static inline void aw20216s_auto_lowpower(pin_t cs_pin) { aw20216s_write_register(cs_pin, AW20216S_PAGE_FUNCTION, AW20216S_REG_MIXFUNCTION, AW20216S_MIXCR_DEFAULT | AW20216S_LPEN); } +void aw20216s_init_drivers(void) { + spi_init(); + + aw20216s_init(AW20216S_CS_PIN_1, AW20216S_EN_PIN_1); +#if defined(AW20216S_CS_PIN_2) + aw20216s_init(AW20216S_CS_PIN_2, AW20216S_EN_PIN_2); +#endif +} + void aw20216s_init(pin_t cs_pin, pin_t en_pin) { setPinOutput(en_pin); writePinHigh(en_pin); @@ -155,7 +164,7 @@ void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (uint8_t i = 0; i < AW20216S_LED_COUNT; i++) { aw20216s_set_color(i, red, green, blue); } } diff --git a/drivers/led/aw20216s.h b/drivers/led/aw20216s.h index 40601264466..0d6bd3c1890 100644 --- a/drivers/led/aw20216s.h +++ b/drivers/led/aw20216s.h @@ -65,8 +65,9 @@ typedef struct aw20216s_led_t { uint8_t b; } aw20216s_led_t; -extern const aw20216s_led_t PROGMEM g_aw20216s_leds[RGB_MATRIX_LED_COUNT]; +extern const aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT]; +void aw20216s_init_drivers(void); void aw20216s_init(pin_t cs_pin, pin_t en_pin); void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue); diff --git a/drivers/led/issi/is31fl3218-simple.c b/drivers/led/issi/is31fl3218-simple.c index a78dedfcf1e..bdf3187fe17 100644 --- a/drivers/led/issi/is31fl3218-simple.c +++ b/drivers/led/issi/is31fl3218-simple.c @@ -68,6 +68,8 @@ void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) { } void is31fl3218_init(void) { + i2c_init(); + // In case we ever want to reinitialize (?) is31fl3218_write_register(IS31FL3218_REG_RESET, 0x00); @@ -86,11 +88,17 @@ void is31fl3218_init(void) { // Load PWM registers and LED Control register data is31fl3218_write_register(IS31FL3218_REG_UPDATE, 0x01); + + for (int i = 0; i < IS31FL3218_LED_COUNT; i++) { + is31fl3218_set_led_control_register(i, true); + } + + is31fl3218_update_led_control_registers(); } void is31fl3218_set_value(int index, uint8_t value) { is31fl3218_led_t led; - if (index >= 0 && index < LED_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3218_LED_COUNT) { memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led)); } if (g_pwm_buffer[led.v - IS31FL3218_REG_PWM] == value) { @@ -101,7 +109,7 @@ void is31fl3218_set_value(int index, uint8_t value) { } void is31fl3218_set_value_all(uint8_t value) { - for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3218_LED_COUNT; i++) { is31fl3218_set_value(i, value); } } diff --git a/drivers/led/issi/is31fl3218-simple.h b/drivers/led/issi/is31fl3218-simple.h index 34a4886957a..959990a93fd 100644 --- a/drivers/led/issi/is31fl3218-simple.h +++ b/drivers/led/issi/is31fl3218-simple.h @@ -30,7 +30,7 @@ typedef struct is31fl3218_led_t { uint8_t v; } __attribute__((packed)) is31fl3218_led_t; -extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[LED_MATRIX_LED_COUNT]; +extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT]; void is31fl3218_init(void); diff --git a/drivers/led/issi/is31fl3218.c b/drivers/led/issi/is31fl3218.c index 87a0acfc088..04523a3c01b 100644 --- a/drivers/led/issi/is31fl3218.c +++ b/drivers/led/issi/is31fl3218.c @@ -68,6 +68,8 @@ void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) { } void is31fl3218_init(void) { + i2c_init(); + // In case we ever want to reinitialize (?) is31fl3218_write_register(IS31FL3218_REG_RESET, 0x00); @@ -86,11 +88,17 @@ void is31fl3218_init(void) { // Load PWM registers and LED Control register data is31fl3218_write_register(IS31FL3218_REG_UPDATE, 0x01); + + for (int i = 0; i < IS31FL3218_LED_COUNT; i++) { + is31fl3218_set_led_control_register(i, true, true, true); + } + + is31fl3218_update_led_control_registers(); } void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { is31fl3218_led_t led; - if (index >= 0 && index < RGB_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3218_LED_COUNT) { memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led)); } if (g_pwm_buffer[led.r - IS31FL3218_REG_PWM] == red && g_pwm_buffer[led.g - IS31FL3218_REG_PWM] == green && g_pwm_buffer[led.b - IS31FL3218_REG_PWM] == blue) { @@ -103,7 +111,7 @@ void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3218_LED_COUNT; i++) { is31fl3218_set_color(i, red, green, blue); } } diff --git a/drivers/led/issi/is31fl3218.h b/drivers/led/issi/is31fl3218.h index 844e11f4903..c48bc2f2389 100644 --- a/drivers/led/issi/is31fl3218.h +++ b/drivers/led/issi/is31fl3218.h @@ -32,7 +32,7 @@ typedef struct is31fl3218_led_t { uint8_t b; } __attribute__((packed)) is31fl3218_led_t; -extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[RGB_MATRIX_LED_COUNT]; +extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT]; void is31fl3218_init(void); diff --git a/drivers/led/issi/is31fl3731-simple.c b/drivers/led/issi/is31fl3731-simple.c index adf2ccfca09..3663d30c106 100644 --- a/drivers/led/issi/is31fl3731-simple.c +++ b/drivers/led/issi/is31fl3731-simple.c @@ -104,6 +104,36 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { } } +void is31fl3731_init_drivers(void) { + i2c_init(); + + is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); +#if defined(IS31FL3731_I2C_ADDRESS_2) + is31fl3731_init(IS31FL3731_I2C_ADDRESS_2); +# if defined(IS31FL3731_I2C_ADDRESS_3) + is31fl3731_init(IS31FL3731_I2C_ADDRESS_3); +# if defined(IS31FL3731_I2C_ADDRESS_4) + is31fl3731_init(IS31FL3731_I2C_ADDRESS_4); +# endif +# endif +#endif + + for (int i = 0; i < IS31FL3731_LED_COUNT; i++) { + is31fl3731_set_led_control_register(i, true); + } + + is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0); +#if defined(IS31FL3731_I2C_ADDRESS_2) + is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1); +# if defined(IS31FL3731_I2C_ADDRESS_3) + is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2); +# if defined(IS31FL3731_I2C_ADDRESS_4) + is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void is31fl3731_init(uint8_t addr) { // In order to avoid the LEDs being driven with garbage data // in the LED driver's PWM registers, first enable software shutdown, @@ -161,7 +191,7 @@ void is31fl3731_init(uint8_t addr) { void is31fl3731_set_value(int index, uint8_t value) { is31fl3731_led_t led; - if (index >= 0 && index < LED_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3731_LED_COUNT) { memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led)); // Subtract 0x24 to get the second index of g_pwm_buffer @@ -175,7 +205,7 @@ void is31fl3731_set_value(int index, uint8_t value) { } void is31fl3731_set_value_all(uint8_t value) { - for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3731_LED_COUNT; i++) { is31fl3731_set_value(i, value); } } diff --git a/drivers/led/issi/is31fl3731-simple.h b/drivers/led/issi/is31fl3731-simple.h index 2ab253717c3..32504c1933a 100644 --- a/drivers/led/issi/is31fl3731-simple.h +++ b/drivers/led/issi/is31fl3731-simple.h @@ -66,8 +66,9 @@ typedef struct is31fl3731_led_t { uint8_t v; } __attribute__((packed)) is31fl3731_led_t; -extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[LED_MATRIX_LED_COUNT]; +extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT]; +void is31fl3731_init_drivers(void); void is31fl3731_init(uint8_t addr); void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/issi/is31fl3731.c b/drivers/led/issi/is31fl3731.c index 767c0da0d90..42abd8ed38a 100644 --- a/drivers/led/issi/is31fl3731.c +++ b/drivers/led/issi/is31fl3731.c @@ -101,6 +101,36 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { } } +void is31fl3731_init_drivers(void) { + i2c_init(); + + is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); +#if defined(IS31FL3731_I2C_ADDRESS_2) + is31fl3731_init(IS31FL3731_I2C_ADDRESS_2); +# if defined(IS31FL3731_I2C_ADDRESS_3) + is31fl3731_init(IS31FL3731_I2C_ADDRESS_3); +# if defined(IS31FL3731_I2C_ADDRESS_4) + is31fl3731_init(IS31FL3731_I2C_ADDRESS_4); +# endif +# endif +#endif + + for (int i = 0; i < IS31FL3731_LED_COUNT; i++) { + is31fl3731_set_led_control_register(i, true, true, true); + } + + is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0); +#if defined(IS31FL3731_I2C_ADDRESS_2) + is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1); +# if defined(IS31FL3731_I2C_ADDRESS_3) + is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2); +# if defined(IS31FL3731_I2C_ADDRESS_4) + is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void is31fl3731_init(uint8_t addr) { // In order to avoid the LEDs being driven with garbage data // in the LED driver's PWM registers, first enable software shutdown, @@ -158,7 +188,7 @@ void is31fl3731_init(uint8_t addr) { void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { is31fl3731_led_t led; - if (index >= 0 && index < RGB_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3731_LED_COUNT) { memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led)); // Subtract 0x24 to get the second index of g_pwm_buffer @@ -173,7 +203,7 @@ void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void is31fl3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3731_LED_COUNT; i++) { is31fl3731_set_color(i, red, green, blue); } } diff --git a/drivers/led/issi/is31fl3731.h b/drivers/led/issi/is31fl3731.h index 756c5b473a8..73fa0188970 100644 --- a/drivers/led/issi/is31fl3731.h +++ b/drivers/led/issi/is31fl3731.h @@ -67,8 +67,9 @@ typedef struct is31fl3731_led_t { uint8_t b; } __attribute__((packed)) is31fl3731_led_t; -extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT]; +extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT]; +void is31fl3731_init_drivers(void); void is31fl3731_init(uint8_t addr); void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/issi/is31fl3733-simple.c b/drivers/led/issi/is31fl3733-simple.c index dbbf86a8f54..aa1b02450c1 100644 --- a/drivers/led/issi/is31fl3733-simple.c +++ b/drivers/led/issi/is31fl3733-simple.c @@ -63,6 +63,19 @@ # define IS31FL3733_GLOBALCURRENT 0xFF #endif +#ifndef IS31FL3733_SYNC_1 +# define IS31FL3733_SYNC_1 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_2 +# define IS31FL3733_SYNC_2 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_3 +# define IS31FL3733_SYNC_3 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_4 +# define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE +#endif + // Transfer buffer for TWITransmitData() uint8_t g_twi_transfer_buffer[20]; @@ -126,6 +139,36 @@ bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { return true; } +void is31fl3733_init_drivers(void) { + i2c_init(); + + is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1); +#if defined(IS31FL3733_I2C_ADDRESS_2) + is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2); +# if defined(IS31FL3733_I2C_ADDRESS_3) + is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3); +# if defined(IS31FL3733_I2C_ADDRESS_4) + is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4); +# endif +# endif +#endif + + for (int i = 0; i < IS31FL3733_LED_COUNT; i++) { + is31fl3733_set_led_control_register(i, true); + } + + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0); +#if defined(IS31FL3733_I2C_ADDRESS_2) + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1); +# if defined(IS31FL3733_I2C_ADDRESS_3) + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2); +# if defined(IS31FL3733_I2C_ADDRESS_4) + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void is31fl3733_init(uint8_t addr, uint8_t sync) { // In order to avoid the LEDs being driven with garbage data // in the LED driver's PWM registers, shutdown is enabled last. @@ -174,7 +217,7 @@ void is31fl3733_init(uint8_t addr, uint8_t sync) { void is31fl3733_set_value(int index, uint8_t value) { is31fl3733_led_t led; - if (index >= 0 && index < LED_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3733_LED_COUNT) { memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led)); if (g_pwm_buffer[led.driver][led.v] == value) { @@ -186,7 +229,7 @@ void is31fl3733_set_value(int index, uint8_t value) { } void is31fl3733_set_value_all(uint8_t value) { - for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3733_LED_COUNT; i++) { is31fl3733_set_value(i, value); } } diff --git a/drivers/led/issi/is31fl3733-simple.h b/drivers/led/issi/is31fl3733-simple.h index e9f68e35065..367af43c6a2 100644 --- a/drivers/led/issi/is31fl3733-simple.h +++ b/drivers/led/issi/is31fl3733-simple.h @@ -85,8 +85,9 @@ typedef struct is31fl3733_led_t { uint8_t v; } __attribute__((packed)) is31fl3733_led_t; -extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[LED_MATRIX_LED_COUNT]; +extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT]; +void is31fl3733_init_drivers(void); void is31fl3733_init(uint8_t addr, uint8_t sync); bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data); bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); @@ -119,6 +120,10 @@ void is31fl3733_flush(void); #define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0b011 #define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0b100 +#define IS31FL3733_SYNC_NONE 0b00 +#define IS31FL3733_SYNC_MASTER 0b01 +#define IS31FL3733_SYNC_SLAVE 0b10 + #define A_1 0x00 #define A_2 0x01 #define A_3 0x02 diff --git a/drivers/led/issi/is31fl3733.c b/drivers/led/issi/is31fl3733.c index 35ec96a55a9..24b07330307 100644 --- a/drivers/led/issi/is31fl3733.c +++ b/drivers/led/issi/is31fl3733.c @@ -62,6 +62,19 @@ # define IS31FL3733_GLOBALCURRENT 0xFF #endif +#ifndef IS31FL3733_SYNC_1 +# define IS31FL3733_SYNC_1 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_2 +# define IS31FL3733_SYNC_2 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_3 +# define IS31FL3733_SYNC_3 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_4 +# define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE +#endif + // Transfer buffer for TWITransmitData() uint8_t g_twi_transfer_buffer[20]; @@ -125,6 +138,36 @@ bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { return true; } +void is31fl3733_init_drivers(void) { + i2c_init(); + + is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1); +#if defined(IS31FL3733_I2C_ADDRESS_2) + is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2); +# if defined(IS31FL3733_I2C_ADDRESS_3) + is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3); +# if defined(IS31FL3733_I2C_ADDRESS_4) + is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4); +# endif +# endif +#endif + + for (int i = 0; i < IS31FL3733_LED_COUNT; i++) { + is31fl3733_set_led_control_register(i, true, true, true); + } + + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0); +#if defined(IS31FL3733_I2C_ADDRESS_2) + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1); +# if defined(IS31FL3733_I2C_ADDRESS_3) + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2); +# if defined(IS31FL3733_I2C_ADDRESS_4) + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void is31fl3733_init(uint8_t addr, uint8_t sync) { // In order to avoid the LEDs being driven with garbage data // in the LED driver's PWM registers, shutdown is enabled last. @@ -173,7 +216,7 @@ void is31fl3733_init(uint8_t addr, uint8_t sync) { void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { is31fl3733_led_t led; - if (index >= 0 && index < RGB_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3733_LED_COUNT) { memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led)); if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) { @@ -187,7 +230,7 @@ void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void is31fl3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3733_LED_COUNT; i++) { is31fl3733_set_color(i, red, green, blue); } } diff --git a/drivers/led/issi/is31fl3733.h b/drivers/led/issi/is31fl3733.h index bda6f1908fd..4902b3c1d7d 100644 --- a/drivers/led/issi/is31fl3733.h +++ b/drivers/led/issi/is31fl3733.h @@ -110,8 +110,9 @@ typedef struct is31fl3733_led_t { uint8_t b; } __attribute__((packed)) is31fl3733_led_t; -extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT]; +extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT]; +void is31fl3733_init_drivers(void); void is31fl3733_init(uint8_t addr, uint8_t sync); bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data); bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); @@ -144,6 +145,10 @@ void is31fl3733_flush(void); #define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0b011 #define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0b100 +#define IS31FL3733_SYNC_NONE 0b00 +#define IS31FL3733_SYNC_MASTER 0b01 +#define IS31FL3733_SYNC_SLAVE 0b10 + #define A_1 0x00 #define A_2 0x01 #define A_3 0x02 diff --git a/drivers/led/issi/is31fl3736-simple.c b/drivers/led/issi/is31fl3736-simple.c index d8262c3416a..2876533819c 100644 --- a/drivers/led/issi/is31fl3736-simple.c +++ b/drivers/led/issi/is31fl3736-simple.c @@ -112,6 +112,36 @@ void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { } } +void is31fl3736_init_drivers(void) { + i2c_init(); + + is31fl3736_init(IS31FL3736_I2C_ADDRESS_1); +#if defined(IS31FL3736_I2C_ADDRESS_2) + is31fl3736_init(IS31FL3736_I2C_ADDRESS_2); +# if defined(IS31FL3736_I2C_ADDRESS_3) + is31fl3736_init(IS31FL3736_I2C_ADDRESS_3); +# if defined(IS31FL3736_I2C_ADDRESS_4) + is31fl3736_init(IS31FL3736_I2C_ADDRESS_4); +# endif +# endif +#endif + + for (int i = 0; i < IS31FL3736_LED_COUNT; i++) { + is31fl3736_set_led_control_register(i, true); + } + + is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_1, 0); +#if defined(IS31FL3736_I2C_ADDRESS_2) + is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_2, 1); +# if defined(IS31FL3736_I2C_ADDRESS_3) + is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_3, 2); +# if defined(IS31FL3736_I2C_ADDRESS_4) + is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void is31fl3736_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. @@ -159,7 +189,7 @@ void is31fl3736_init(uint8_t addr) { void is31fl3736_set_value(int index, uint8_t value) { is31fl3736_led_t led; - if (index >= 0 && index < LED_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3736_LED_COUNT) { memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led)); if (g_pwm_buffer[led.driver][led.v] == value) { @@ -171,7 +201,7 @@ void is31fl3736_set_value(int index, uint8_t value) { } void is31fl3736_set_value_all(uint8_t value) { - for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3736_LED_COUNT; i++) { is31fl3736_set_value(i, value); } } diff --git a/drivers/led/issi/is31fl3736-simple.h b/drivers/led/issi/is31fl3736-simple.h index fe3cec9564c..88422ec3a45 100644 --- a/drivers/led/issi/is31fl3736-simple.h +++ b/drivers/led/issi/is31fl3736-simple.h @@ -80,8 +80,9 @@ typedef struct is31fl3736_led_t { uint8_t v; } __attribute__((packed)) is31fl3736_led_t; -extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[LED_MATRIX_LED_COUNT]; +extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[IS31FL3736_LED_COUNT]; +void is31fl3736_init_drivers(void); void is31fl3736_init(uint8_t addr); void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/issi/is31fl3736.c b/drivers/led/issi/is31fl3736.c index 4edf1b04c87..ad421e5cf20 100644 --- a/drivers/led/issi/is31fl3736.c +++ b/drivers/led/issi/is31fl3736.c @@ -112,6 +112,36 @@ void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { } } +void is31fl3736_init_drivers(void) { + i2c_init(); + + is31fl3736_init(IS31FL3736_I2C_ADDRESS_1); +#if defined(IS31FL3736_I2C_ADDRESS_2) + is31fl3736_init(IS31FL3736_I2C_ADDRESS_2); +# if defined(IS31FL3736_I2C_ADDRESS_3) + is31fl3736_init(IS31FL3736_I2C_ADDRESS_3); +# if defined(IS31FL3736_I2C_ADDRESS_4) + is31fl3736_init(IS31FL3736_I2C_ADDRESS_4); +# endif +# endif +#endif + + for (int i = 0; i < IS31FL3736_LED_COUNT; i++) { + is31fl3736_set_led_control_register(i, true, true, true); + } + + is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_1, 0); +#if defined(IS31FL3736_I2C_ADDRESS_2) + is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_2, 1); +# if defined(IS31FL3736_I2C_ADDRESS_3) + is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_3, 2); +# if defined(IS31FL3736_I2C_ADDRESS_4) + is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void is31fl3736_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. @@ -159,7 +189,7 @@ void is31fl3736_init(uint8_t addr) { void is31fl3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { is31fl3736_led_t led; - if (index >= 0 && index < RGB_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3736_LED_COUNT) { memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led)); if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) { @@ -173,7 +203,7 @@ void is31fl3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void is31fl3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3736_LED_COUNT; i++) { is31fl3736_set_color(i, red, green, blue); } } diff --git a/drivers/led/issi/is31fl3736.h b/drivers/led/issi/is31fl3736.h index 728021ae298..b64fdf9d1c8 100644 --- a/drivers/led/issi/is31fl3736.h +++ b/drivers/led/issi/is31fl3736.h @@ -94,8 +94,9 @@ typedef struct is31fl3736_led_t { uint8_t b; } __attribute__((packed)) is31fl3736_led_t; -extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[RGB_MATRIX_LED_COUNT]; +extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[IS31FL3736_LED_COUNT]; +void is31fl3736_init_drivers(void); void is31fl3736_init(uint8_t addr); void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/issi/is31fl3737-simple.c b/drivers/led/issi/is31fl3737-simple.c index 7a4263d9aff..aa6eba982c2 100644 --- a/drivers/led/issi/is31fl3737-simple.c +++ b/drivers/led/issi/is31fl3737-simple.c @@ -115,6 +115,36 @@ void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { } } +void is31fl3737_init_drivers(void) { + i2c_init(); + + is31fl3737_init(IS31FL3737_I2C_ADDRESS_1); +#if defined(IS31FL3737_I2C_ADDRESS_2) + is31fl3737_init(IS31FL3737_I2C_ADDRESS_2); +# if defined(IS31FL3737_I2C_ADDRESS_3) + is31fl3737_init(IS31FL3737_I2C_ADDRESS_3); +# if defined(IS31FL3737_I2C_ADDRESS_4) + is31fl3737_init(IS31FL3737_I2C_ADDRESS_4); +# endif +# endif +#endif + + for (int i = 0; i < IS31FL3737_LED_COUNT; i++) { + is31fl3737_set_led_control_register(i, true); + } + + is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_1, 0); +#if defined(IS31FL3737_I2C_ADDRESS_2) + is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_2, 1); +# if defined(IS31FL3737_I2C_ADDRESS_3) + is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_3, 2); +# if defined(IS31FL3737_I2C_ADDRESS_4) + is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void is31fl3737_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. @@ -162,7 +192,7 @@ void is31fl3737_init(uint8_t addr) { void is31fl3737_set_value(int index, uint8_t value) { is31fl3737_led_t led; - if (index >= 0 && index < LED_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3737_LED_COUNT) { memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led)); if (g_pwm_buffer[led.driver][led.v] == value) { @@ -174,7 +204,7 @@ void is31fl3737_set_value(int index, uint8_t value) { } void is31fl3737_set_value_all(uint8_t value) { - for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3737_LED_COUNT; i++) { is31fl3737_set_value(i, value); } } diff --git a/drivers/led/issi/is31fl3737-simple.h b/drivers/led/issi/is31fl3737-simple.h index b177d4fb0a1..4c7af021763 100644 --- a/drivers/led/issi/is31fl3737-simple.h +++ b/drivers/led/issi/is31fl3737-simple.h @@ -70,8 +70,9 @@ typedef struct is31fl3737_led_t { uint8_t v; } __attribute__((packed)) is31fl3737_led_t; -extern const is31fl3737_led_t PROGMEM g_is31fl3737_leds[LED_MATRIX_LED_COUNT]; +extern const is31fl3737_led_t PROGMEM g_is31fl3737_leds[IS31FL3737_LED_COUNT]; +void is31fl3737_init_drivers(void); void is31fl3737_init(uint8_t addr); void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/issi/is31fl3737.c b/drivers/led/issi/is31fl3737.c index d769bb9707f..75544231ecb 100644 --- a/drivers/led/issi/is31fl3737.c +++ b/drivers/led/issi/is31fl3737.c @@ -115,6 +115,36 @@ void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { } } +void is31fl3737_init_drivers(void) { + i2c_init(); + + is31fl3737_init(IS31FL3737_I2C_ADDRESS_1); +#if defined(IS31FL3737_I2C_ADDRESS_2) + is31fl3737_init(IS31FL3737_I2C_ADDRESS_2); +# if defined(IS31FL3737_I2C_ADDRESS_3) + is31fl3737_init(IS31FL3737_I2C_ADDRESS_3); +# if defined(IS31FL3737_I2C_ADDRESS_4) + is31fl3737_init(IS31FL3737_I2C_ADDRESS_4); +# endif +# endif +#endif + + for (int i = 0; i < IS31FL3737_LED_COUNT; i++) { + is31fl3737_set_led_control_register(i, true, true, true); + } + + is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_1, 0); +#if defined(IS31FL3737_I2C_ADDRESS_2) + is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_2, 1); +# if defined(IS31FL3737_I2C_ADDRESS_3) + is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_3, 2); +# if defined(IS31FL3737_I2C_ADDRESS_4) + is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_4, 3); +# endif +# endif +#endif +} + void is31fl3737_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. @@ -162,7 +192,7 @@ void is31fl3737_init(uint8_t addr) { void is31fl3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { is31fl3737_led_t led; - if (index >= 0 && index < RGB_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3737_LED_COUNT) { memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led)); if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) { @@ -176,7 +206,7 @@ void is31fl3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void is31fl3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3737_LED_COUNT; i++) { is31fl3737_set_color(i, red, green, blue); } } diff --git a/drivers/led/issi/is31fl3737.h b/drivers/led/issi/is31fl3737.h index 12f84e3bfe4..fadab70c74f 100644 --- a/drivers/led/issi/is31fl3737.h +++ b/drivers/led/issi/is31fl3737.h @@ -87,8 +87,9 @@ typedef struct is31fl3737_led_t { uint8_t b; } __attribute__((packed)) is31fl3737_led_t; -extern const is31fl3737_led_t PROGMEM g_is31fl3737_leds[RGB_MATRIX_LED_COUNT]; +extern const is31fl3737_led_t PROGMEM g_is31fl3737_leds[IS31FL3737_LED_COUNT]; +void is31fl3737_init_drivers(void); void is31fl3737_init(uint8_t addr); void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/issi/is31fl3741-simple.c b/drivers/led/issi/is31fl3741-simple.c index c7335866ec1..8e77a6446d1 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); } } diff --git a/drivers/led/issi/is31fl3741-simple.h b/drivers/led/issi/is31fl3741-simple.h index 8ecc3302981..d97591fa608 100644 --- a/drivers/led/issi/is31fl3741-simple.h +++ b/drivers/led/issi/is31fl3741-simple.h @@ -70,8 +70,9 @@ typedef struct is31fl3741_led_t { uint32_t v : 10; } __attribute__((packed)) is31fl3741_led_t; -extern const is31fl3741_led_t PROGMEM g_is31fl3741_leds[RGB_MATRIX_LED_COUNT]; +extern const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT]; +void is31fl3741_init_drivers(void); void is31fl3741_init(uint8_t addr); 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); diff --git a/drivers/led/issi/is31fl3741.c b/drivers/led/issi/is31fl3741.c index 5e4ed711ca6..f316b761574 100644 --- a/drivers/led/issi/is31fl3741.c +++ b/drivers/led/issi/is31fl3741.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, true, 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_color(int index, uint8_t red, uint8_t green, uint8_t blue) { is31fl3741_led_t led; - if (index >= 0 && index < RGB_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.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) { @@ -188,7 +218,7 @@ void is31fl3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void is31fl3741_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3741_LED_COUNT; i++) { is31fl3741_set_color(i, red, green, blue); } } diff --git a/drivers/led/issi/is31fl3741.h b/drivers/led/issi/is31fl3741.h index 13e132efa09..1febb6398b0 100644 --- a/drivers/led/issi/is31fl3741.h +++ b/drivers/led/issi/is31fl3741.h @@ -87,8 +87,9 @@ typedef struct is31fl3741_led_t { uint32_t b : 10; } __attribute__((packed)) is31fl3741_led_t; -extern const is31fl3741_led_t PROGMEM g_is31fl3741_leds[RGB_MATRIX_LED_COUNT]; +extern const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT]; +void is31fl3741_init_drivers(void); void is31fl3741_init(uint8_t addr); 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); diff --git a/drivers/led/issi/is31flcommon.c b/drivers/led/issi/is31flcommon.c index 850f23c8312..d6b9bce93d7 100644 --- a/drivers/led/issi/is31flcommon.c +++ b/drivers/led/issi/is31flcommon.c @@ -188,6 +188,41 @@ void IS31FL_common_flush(void) { } #ifdef RGB_MATRIX_ENABLE +void IS31FL_RGB_init_drivers(void) { + i2c_init(); + + IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1); +# if defined(DRIVER_ADDR_2) + IS31FL_common_init(DRIVER_ADDR_2, ISSI_SSR_2); +# if defined(DRIVER_ADDR_3) + IS31FL_common_init(DRIVER_ADDR_3, ISSI_SSR_3); +# if defined(DRIVER_ADDR_4) + IS31FL_common_init(DRIVER_ADDR_4, ISSI_SSR_4); +# endif +# endif +# endif + + for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + IS31FL_RGB_set_scaling_buffer(i, true, true, true); + } + + // This actually updates the LED drivers +# ifdef ISSI_MANUAL_SCALING + IS31FL_set_manual_scaling_buffer(); +# endif + + IS31FL_common_update_scaling_register(DRIVER_ADDR_1, 0); +# if defined(DRIVER_ADDR_2) + IS31FL_common_update_scaling_register(DRIVER_ADDR_2, 1); +# if defined(DRIVER_ADDR_3) + IS31FL_common_update_scaling_register(DRIVER_ADDR_3, 2); +# if defined(DRIVER_ADDR_4) + IS31FL_common_update_scaling_register(DRIVER_ADDR_4, 3); +# endif +# endif +# endif +} + // Colour is set by adjusting PWM register void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { if (index >= 0 && index < RGB_MATRIX_LED_COUNT) { @@ -231,6 +266,41 @@ void IS31FL_RGB_set_scaling_buffer(uint8_t index, bool red, bool green, bool blu #elif defined(LED_MATRIX_ENABLE) // LED Matrix Specific scripts +void IS31FL_simple_init_drivers(void) { + i2c_init(); + + IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1); +# if defined(DRIVER_ADDR_2) + IS31FL_common_init(DRIVER_ADDR_2, ISSI_SSR_2); +# if defined(DRIVER_ADDR_3) + IS31FL_common_init(DRIVER_ADDR_3, ISSI_SSR_3); +# if defined(DRIVER_ADDR_4) + IS31FL_common_init(DRIVER_ADDR_4, ISSI_SSR_4); +# endif +# endif +# endif + + for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) { + IS31FL_simple_set_scaling_buffer(i, true); + } + +// This actually updates the LED drivers +# ifdef ISSI_MANUAL_SCALING + IS31FL_set_manual_scaling_buffer(); +# endif + + IS31FL_common_update_scaling_register(DRIVER_ADDR_1, 0); +# if defined(DRIVER_ADDR_2) + IS31FL_common_update_scaling_register(DRIVER_ADDR_2, 1); +# if defined(DRIVER_ADDR_3) + IS31FL_common_update_scaling_register(DRIVER_ADDR_3, 2); +# if defined(DRIVER_ADDR_4) + IS31FL_common_update_scaling_register(DRIVER_ADDR_4, 3); +# endif +# endif +# endif +} + void IS31FL_simple_set_scaling_buffer(uint8_t index, bool value) { is31_led led; memcpy_P(&led, (&g_is31_leds[index]), sizeof(led)); diff --git a/drivers/led/issi/is31flcommon.h b/drivers/led/issi/is31flcommon.h index c380f2a8d6a..94ec9ae3ced 100644 --- a/drivers/led/issi/is31flcommon.h +++ b/drivers/led/issi/is31flcommon.h @@ -71,11 +71,13 @@ void IS31FL_common_flush(void); #ifdef RGB_MATRIX_ENABLE // RGB Matrix Specific scripts +void IS31FL_RGB_init_drivers(void); void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); void IS31FL_RGB_set_color_all(uint8_t red, uint8_t green, uint8_t blue); void IS31FL_RGB_set_scaling_buffer(uint8_t index, bool red, bool green, bool blue); #elif defined(LED_MATRIX_ENABLE) // LED Matrix Specific scripts +void IS31FL_simple_init_drivers(void); void IS31FL_simple_set_scaling_buffer(uint8_t index, bool value); void IS31FL_simple_set_brightness(int index, uint8_t value); void IS31FL_simple_set_brigntness_all(uint8_t value); diff --git a/drivers/led/snled27351-simple.c b/drivers/led/snled27351-simple.c index 882fe4e8b49..c274506f834 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); } } diff --git a/drivers/led/snled27351-simple.h b/drivers/led/snled27351-simple.h index e8238071a54..64257202b97 100644 --- a/drivers/led/snled27351-simple.h +++ b/drivers/led/snled27351-simple.h @@ -68,8 +68,9 @@ typedef struct snled27351_led_t { uint8_t v; } __attribute__((packed)) snled27351_led_t; -extern const snled27351_led_t PROGMEM g_snled27351_leds[LED_MATRIX_LED_COUNT]; +extern const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT]; +void snled27351_init_drivers(void); void snled27351_init(uint8_t addr); bool snled27351_write_register(uint8_t addr, uint8_t reg, uint8_t data); bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/snled27351.c b/drivers/led/snled27351.c index 198b190dac8..2746737a5a3 100644 --- a/drivers/led/snled27351.c +++ b/drivers/led/snled27351.c @@ -98,6 +98,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, true, 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); @@ -146,7 +174,7 @@ void snled27351_init(uint8_t addr) { void snled27351_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { snled27351_led_t led; - if (index >= 0 && index < RGB_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.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) { @@ -160,7 +188,7 @@ void snled27351_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void snled27351_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < SNLED27351_LED_COUNT; i++) { snled27351_set_color(i, red, green, blue); } } diff --git a/drivers/led/snled27351.h b/drivers/led/snled27351.h index e92ca717992..cecd552dbb5 100644 --- a/drivers/led/snled27351.h +++ b/drivers/led/snled27351.h @@ -82,8 +82,9 @@ typedef struct snled27351_led_t { uint8_t b; } __attribute__((packed)) snled27351_led_t; -extern const snled27351_led_t PROGMEM g_snled27351_leds[RGB_MATRIX_LED_COUNT]; +extern const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT]; +void snled27351_init_drivers(void); void snled27351_init(uint8_t addr); bool snled27351_write_register(uint8_t addr, uint8_t reg, uint8_t data); bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/keyboards/acheron/apollo/87h/gamma/config.h b/keyboards/acheron/apollo/87h/gamma/config.h index e8600a18f1a..151239ba339 100644 --- a/keyboards/acheron/apollo/87h/gamma/config.h +++ b/keyboards/acheron/apollo/87h/gamma/config.h @@ -30,7 +30,6 @@ along with this program. If not, see . #define IS31FL3741_DRIVER_COUNT 1 #define DRIVER_1_LED_TOTAL 87 #define RGB_MATRIX_LED_COUNT DRIVER_1_LED_TOTAL -#define ISSI_DRIVER_TOTAL RGB_MATRIX_LED_COUNT #define RGB_MATRIX_DEFAULT_VAL 80 #define RGB_MATRIX_FRAMEBUFFER_EFFECTS diff --git a/keyboards/aeboards/satellite/rev1/config.h b/keyboards/aeboards/satellite/rev1/config.h index fcf3105f0f5..7a062883943 100644 --- a/keyboards/aeboards/satellite/rev1/config.h +++ b/keyboards/aeboards/satellite/rev1/config.h @@ -23,8 +23,8 @@ #define IS31FL3731_DRIVER_COUNT 2 #define DRIVER_1_LED_TOTAL 36 #define DRIVER_2_LED_TOTAL 36 -#define ISSI_DRIVER_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) -#define RGB_MATRIX_LED_COUNT ISSI_DRIVER_TOTAL +#define IS31FL3731_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) +#define RGB_MATRIX_LED_COUNT IS31FL3731_LED_COUNT #define RGB_MATRIX_DEFAULT_VAL 80 #define RGB_MATRIX_FRAMEBUFFER_EFFECTS diff --git a/keyboards/aeboards/satellite/rev1/rev1.c b/keyboards/aeboards/satellite/rev1/rev1.c index 4c6e7d6d7c6..6727894e067 100644 --- a/keyboards/aeboards/satellite/rev1/rev1.c +++ b/keyboards/aeboards/satellite/rev1/rev1.c @@ -18,7 +18,7 @@ #include "drivers/led/issi/is31fl3731.h" #ifdef RGB_MATRIX_ENABLE -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -149,7 +149,7 @@ static void init(void) { is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); is31fl3731_init(IS31FL3731_I2C_ADDRESS_2); - for (int index = 0; index < ISSI_DRIVER_TOTAL; index++) { + for (int index = 0; index < IS31FL3731_LED_COUNT; index++) { bool enabled = !( ( index == 18+5) || //B5 ( index == 36+17) || //C17 ( index == 54+13) //D13 diff --git a/keyboards/fallacy/config.h b/keyboards/fallacy/config.h index 254f809c342..65cea1d5c14 100755 --- a/keyboards/fallacy/config.h +++ b/keyboards/fallacy/config.h @@ -20,7 +20,7 @@ */ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_DRIVER_COUNT 1 -#define LED_MATRIX_LED_COUNT 3 +#define IS31FL3731_LED_COUNT 3 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ diff --git a/keyboards/fallacy/indicators.c b/keyboards/fallacy/indicators.c index a8630d2e113..b95786db417 100755 --- a/keyboards/fallacy/indicators.c +++ b/keyboards/fallacy/indicators.c @@ -22,14 +22,7 @@ * init IS31FL3731 and i2c */ void init_fallacy_leds(void) { - i2c_init(); - is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); - - for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) { - is31fl3731_set_led_control_register(i, true); - } - - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0); + is31fl3731_init_drivers(); } @@ -54,7 +47,7 @@ void set_fallacy_led(int index, bool state) { /* define LED matrix */ -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[LED_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { {0, C1_1}, {0, C2_1}, {0, C3_1}, diff --git a/keyboards/hs60/v2/ansi/config.h b/keyboards/hs60/v2/ansi/config.h index 3600b30feb5..e4dc24dc33b 100644 --- a/keyboards/hs60/v2/ansi/config.h +++ b/keyboards/hs60/v2/ansi/config.h @@ -55,7 +55,7 @@ along with this program. If not, see . #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define IS31FL3733_DRIVER_COUNT 1 -#define RGB_MATRIX_LED_COUNT 64 +#define IS31FL3733_LED_COUNT 64 // These define which keys in the matrix are alphas/mods // Used for backlight effects so colors are different for diff --git a/keyboards/hs60/v2/hhkb/config.h b/keyboards/hs60/v2/hhkb/config.h index bdc27435cf5..029e1ebb18f 100644 --- a/keyboards/hs60/v2/hhkb/config.h +++ b/keyboards/hs60/v2/hhkb/config.h @@ -55,7 +55,7 @@ along with this program. If not, see . #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define IS31FL3733_DRIVER_COUNT 1 -#define RGB_MATRIX_LED_COUNT 64 +#define IS31FL3733_LED_COUNT 64 // These define which keys in the matrix are alphas/mods // Used for backlight effects so colors are different for diff --git a/keyboards/hs60/v2/iso/config.h b/keyboards/hs60/v2/iso/config.h index 9a9a4ed623d..52cada51a6c 100644 --- a/keyboards/hs60/v2/iso/config.h +++ b/keyboards/hs60/v2/iso/config.h @@ -52,7 +52,7 @@ along with this program. If not, see . #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define IS31FL3733_DRIVER_COUNT 1 -#define RGB_MATRIX_LED_COUNT 64 +#define IS31FL3733_LED_COUNT 64 // These define which keys in the matrix are alphas/mods // Used for backlight effects so colors are different for diff --git a/keyboards/input_club/k_type/config.h b/keyboards/input_club/k_type/config.h index d6abd39a833..c188038a824 100644 --- a/keyboards/input_club/k_type/config.h +++ b/keyboards/input_club/k_type/config.h @@ -34,7 +34,6 @@ along with this program. If not, see . //#define NO_ACTION_ONESHOT #ifdef RGB_MATRIX_ENABLE -//#include "gpio.h" // RGB Matrix Animation modes. Explicitly enabled // For full list of effects, see: // https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects @@ -106,7 +105,8 @@ along with this program. If not, see . # define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND # define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_GND_GND # define IS31FL3733_DRIVER_COUNT 2 +# define IS31FL3733_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) # define DRIVER_1_LED_TOTAL 64 # define DRIVER_2_LED_TOTAL 55 -# define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) +# define RGB_MATRIX_LED_COUNT IS31FL3733_LED_COUNT #endif diff --git a/keyboards/input_club/k_type/i2c_master.h b/keyboards/input_club/k_type/i2c_master.h index d4e9d6878f0..db4f12e43c4 100644 --- a/keyboards/input_club/k_type/i2c_master.h +++ b/keyboards/input_club/k_type/i2c_master.h @@ -26,6 +26,7 @@ #include #include +#include "gpio.h" #ifndef I2C_COUNT # define I2C_COUNT 1 diff --git a/keyboards/input_club/k_type/is31fl3733-dual.c b/keyboards/input_club/k_type/is31fl3733-dual.c index 54e9d76960b..0b6c6a607c5 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.c +++ b/keyboards/input_club/k_type/is31fl3733-dual.c @@ -60,6 +60,19 @@ # define IS31FL3733_GLOBALCURRENT 0xFF #endif +#ifndef IS31FL3733_SYNC_1 +# define IS31FL3733_SYNC_1 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_2 +# define IS31FL3733_SYNC_2 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_3 +# define IS31FL3733_SYNC_3 IS31FL3733_SYNC_NONE +#endif +#ifndef IS31FL3733_SYNC_4 +# define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE +#endif + // Transfer buffer for TWITransmitData() uint8_t g_twi_transfer_buffer[20]; @@ -125,6 +138,24 @@ bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffe return true; } +void is31fl3733_init_drivers(void) { + i2c_init(&I2CD1, I2C1_SCL_PIN, I2C1_SDA_PIN); + is31fl3733_init(0, IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1); +# ifdef USE_I2C2 + i2c_init(&I2CD2, I2C2_SCL_PIN, I2C2_SDA_PIN); + is31fl3733_init(1, IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2); +# endif + + for (int i = 0; i < IS31FL3733_LED_COUNT; i++) { + is31fl3733_set_led_control_register(i, true, true, true); + } + + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0); +# ifdef USE_I2C2 + is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1); +# endif +} + void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync) { // In order to avoid the LEDs being driven with garbage data // in the LED driver's PWM registers, shutdown is enabled last. @@ -173,7 +204,7 @@ void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync) { void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { is31fl3733_led_t led; - if (index >= 0 && index < RGB_MATRIX_LED_COUNT) { + if (index >= 0 && index < IS31FL3733_LED_COUNT) { memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led)); if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) { @@ -187,7 +218,7 @@ void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { } void is31fl3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (int i = 0; i < IS31FL3733_LED_COUNT; i++) { is31fl3733_set_color(i, red, green, blue); } } diff --git a/keyboards/input_club/k_type/is31fl3733-dual.h b/keyboards/input_club/k_type/is31fl3733-dual.h index 33943af3202..696c234b678 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.h +++ b/keyboards/input_club/k_type/is31fl3733-dual.h @@ -46,8 +46,9 @@ typedef struct is31fl3733_led_t { uint8_t b; } __attribute__((packed)) is31fl3733_led_t; -extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT]; +extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT]; +void is31fl3733_init_drivers(void); void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync); bool is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data); bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffer); @@ -80,6 +81,10 @@ void is31fl3733_flush(void); #define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0x03 #define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0x04 +#define IS31FL3733_SYNC_NONE 0b00 +#define IS31FL3733_SYNC_MASTER 0b01 +#define IS31FL3733_SYNC_SLAVE 0b10 + #define A_1 0x00 #define A_2 0x01 #define A_3 0x02 diff --git a/keyboards/input_club/k_type/k_type-rgbdriver.c b/keyboards/input_club/k_type/k_type-rgbdriver.c index 1e8132e6dc0..e4d2d2d04b0 100644 --- a/keyboards/input_club/k_type/k_type-rgbdriver.c +++ b/keyboards/input_club/k_type/k_type-rgbdriver.c @@ -16,30 +16,10 @@ #ifdef RGB_MATRIX_ENABLE # include "rgb_matrix.h" -# include "i2c_master.h" # include "is31fl3733-dual.h" -# include "gpio.h" - -static void init(void) { - i2c_init(&I2CD1, I2C1_SCL_PIN, I2C1_SDA_PIN); - is31fl3733_init(0, IS31FL3733_I2C_ADDRESS_1, 0); -# ifdef USE_I2C2 - i2c_init(&I2CD2, I2C2_SCL_PIN, I2C2_SDA_PIN); - is31fl3733_init(1, IS31FL3733_I2C_ADDRESS_2, 0); -# endif - for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) { - bool enabled = true; - // This only caches it for later - is31fl3733_set_led_control_register(index, enabled, enabled, enabled); - } - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0); -# ifdef USE_I2C2 - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1); -# endif -} const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, + .init = is31fl3733_init_drivers, .flush = is31fl3733_flush, .set_color = is31fl3733_set_color, .set_color_all = is31fl3733_set_color_all, diff --git a/keyboards/input_club/k_type/k_type.c b/keyboards/input_club/k_type/k_type.c index c6d06b51dcc..e97007fc704 100644 --- a/keyboards/input_club/k_type/k_type.c +++ b/keyboards/input_club/k_type/k_type.c @@ -20,7 +20,7 @@ along with this program. If not, see . #ifdef RGB_MATRIX_ENABLE # include "is31fl3733-dual.h" -const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT] = { { 0, B_1, A_1, C_1 }, { 0, B_2, A_2, C_2 }, { 0, B_3, A_3, C_3 }, diff --git a/keyboards/input_club/k_type/post_rules.mk b/keyboards/input_club/k_type/post_rules.mk index 897e422b051..ba750e2624e 100644 --- a/keyboards/input_club/k_type/post_rules.mk +++ b/keyboards/input_club/k_type/post_rules.mk @@ -1,5 +1,5 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) # Additional files for RGB lighting - SRC += k_type-rgbdriver.c - QUANTUM_LIB_SRC += i2c_master.c is31fl3733-dual.c + SRC += k_type-rgbdriver.c is31fl3733-dual.c + QUANTUM_LIB_SRC += i2c_master.c endif diff --git a/keyboards/keebwerk/mega/ansi/config.h b/keyboards/keebwerk/mega/ansi/config.h index ee98c956363..c3b90cc2ca8 100755 --- a/keyboards/keebwerk/mega/ansi/config.h +++ b/keyboards/keebwerk/mega/ansi/config.h @@ -53,7 +53,7 @@ along with this program. If not, see . #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_GND_SDA #define IS31FL3733_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 128 +#define IS31FL3733_LED_COUNT 128 // These define which keys in the matrix are alphas/mods // Used for backlight effects so colors are different for diff --git a/keyboards/kprepublic/bm60hsrgb/rev2/config.h b/keyboards/kprepublic/bm60hsrgb/rev2/config.h index 93498386223..8d194f5ccb3 100644 --- a/keyboards/kprepublic/bm60hsrgb/rev2/config.h +++ b/keyboards/kprepublic/bm60hsrgb/rev2/config.h @@ -74,7 +74,7 @@ #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120 -#define ISSI_LED_TOTAL DRIVER_1_LED_TOTAL +#define IS31FL3733_LED_COUNT DRIVER_1_LED_TOTAL // Underglow LEDs are WS2812, but someone might want to use RGBLIGHT for them; // don't use those LEDs in RGB Matrix in that case. @@ -84,7 +84,7 @@ # define WS2812_LED_TOTAL 6 #endif -#define RGB_MATRIX_LED_COUNT (ISSI_LED_TOTAL + WS2812_LED_TOTAL) +#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_TOTAL) #ifdef RGB_MATRIX_ENABLE # define RGB_MATRIX_KEYPRESSES diff --git a/keyboards/kprepublic/bm60hsrgb/rev2/rev2.c b/keyboards/kprepublic/bm60hsrgb/rev2/rev2.c index 8b786d7cfb3..0e9b3d318d4 100644 --- a/keyboards/kprepublic/bm60hsrgb/rev2/rev2.c +++ b/keyboards/kprepublic/bm60hsrgb/rev2/rev2.c @@ -22,7 +22,7 @@ # include "is31fl3733.h" # include "ws2812.h" -const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT] = { { 0, B_1, A_1, C_1 }, { 0, B_2, A_2, C_2 }, { 0, B_3, A_3, C_3 }, @@ -153,8 +153,8 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL]; static void rgb_matrix_driver_init(void) { i2c_init(); - is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, 0); - for (uint8_t index = 0; index < ISSI_LED_TOTAL; index++) { + is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_NONE); + for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) { bool enabled = true; is31fl3733_set_led_control_register(index, enabled, enabled, enabled); } @@ -169,13 +169,13 @@ static void rgb_matrix_driver_flush(void) { } static void rgb_matrix_driver_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { - if (index < ISSI_LED_TOTAL) { + if (index < IS31FL3733_LED_COUNT) { is31fl3733_set_color(index, red, green, blue); } else { # if WS2812_LED_TOTAL > 0 - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].r = red; - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].g = green; - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].b = blue; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].r = red; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].g = green; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].b = blue; # endif } } diff --git a/keyboards/kprepublic/bm60hsrgb_iso/rev2/config.h b/keyboards/kprepublic/bm60hsrgb_iso/rev2/config.h index acd30f0659b..b22c3844603 100644 --- a/keyboards/kprepublic/bm60hsrgb_iso/rev2/config.h +++ b/keyboards/kprepublic/bm60hsrgb_iso/rev2/config.h @@ -82,7 +82,7 @@ // IS31FL3733+WS2812 driver setup used by this board the LED controller drivers // are compiled unconditionally). -#define ISSI_LED_TOTAL DRIVER_1_LED_TOTAL +#define IS31FL3733_LED_COUNT DRIVER_1_LED_TOTAL #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 180 @@ -94,7 +94,7 @@ # define WS2812_LED_TOTAL 6 #endif -#define RGB_MATRIX_LED_COUNT (ISSI_LED_TOTAL + WS2812_LED_TOTAL) +#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_TOTAL) #ifdef RGB_MATRIX_ENABLE # define RGB_MATRIX_KEYPRESSES diff --git a/keyboards/kprepublic/bm60hsrgb_iso/rev2/rev2.c b/keyboards/kprepublic/bm60hsrgb_iso/rev2/rev2.c index 02dd4ab6cee..2cfe18e08ef 100644 --- a/keyboards/kprepublic/bm60hsrgb_iso/rev2/rev2.c +++ b/keyboards/kprepublic/bm60hsrgb_iso/rev2/rev2.c @@ -24,7 +24,7 @@ # include "ws2812.h" -const PROGMEM is31fl3733_led_t g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = { +const PROGMEM is31fl3733_led_t g_is31fl3733_leds[IS31FL3733_LED_COUNT] = { { 0, B_1, A_1, C_1 }, { 0, B_2, A_2, C_2 }, { 0, B_3, A_3, C_3 }, @@ -153,8 +153,8 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL]; static void rgb_matrix_driver_init(void) { i2c_init(); - is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, 0); - for (uint8_t index = 0; index < ISSI_LED_TOTAL; index++) { + is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_NONE); + for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) { bool enabled = true; is31fl3733_set_led_control_register(index, enabled, enabled, enabled); } @@ -169,13 +169,13 @@ static void rgb_matrix_driver_flush(void) { } static void rgb_matrix_driver_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { - if (index < ISSI_LED_TOTAL) { + if (index < IS31FL3733_LED_COUNT) { is31fl3733_set_color(index, red, green, blue); } else { # if WS2812_LED_TOTAL > 0 - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].r = red; - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].g = green; - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].b = blue; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].r = red; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].g = green; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].b = blue; # endif } } diff --git a/keyboards/kprepublic/bm60hsrgb_poker/rev2/config.h b/keyboards/kprepublic/bm60hsrgb_poker/rev2/config.h index 7fd7575148a..57cb40dc249 100644 --- a/keyboards/kprepublic/bm60hsrgb_poker/rev2/config.h +++ b/keyboards/kprepublic/bm60hsrgb_poker/rev2/config.h @@ -81,7 +81,7 @@ #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define DRIVER_1_LED_TOTAL 61 -#define ISSI_LED_TOTAL DRIVER_1_LED_TOTAL +#define IS31FL3733_LED_COUNT DRIVER_1_LED_TOTAL // Underglow LEDs are WS2812, but someone might want to use RGBLIGHT for them; // don't use those LEDs in RGB Matrix in that case. @@ -91,7 +91,7 @@ # define WS2812_LED_TOTAL 6 #endif -#define RGB_MATRIX_LED_COUNT (ISSI_LED_TOTAL + WS2812_LED_TOTAL) +#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_TOTAL) #ifdef RGB_MATRIX_ENABLE # define RGB_MATRIX_KEYPRESSES diff --git a/keyboards/kprepublic/bm60hsrgb_poker/rev2/rev2.c b/keyboards/kprepublic/bm60hsrgb_poker/rev2/rev2.c index f76c45e6c53..2e66a3096e5 100644 --- a/keyboards/kprepublic/bm60hsrgb_poker/rev2/rev2.c +++ b/keyboards/kprepublic/bm60hsrgb_poker/rev2/rev2.c @@ -21,7 +21,7 @@ # include "is31fl3733.h" # include "ws2812.h" -const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT] = { { 0, B_1, A_1, C_1 }, { 0, B_2, A_2, C_2 }, { 0, B_3, A_3, C_3 }, @@ -149,8 +149,8 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL]; static void rgb_matrix_driver_init(void) { i2c_init(); - is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, 0); - for (uint8_t index = 0; index < ISSI_LED_TOTAL; index++) { + is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_NONE); + for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) { bool enabled = true; is31fl3733_set_led_control_register(index, enabled, enabled, enabled); } @@ -165,13 +165,13 @@ static void rgb_matrix_driver_flush(void) { } static void rgb_matrix_driver_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { - if (index < ISSI_LED_TOTAL) { + if (index < IS31FL3733_LED_COUNT) { is31fl3733_set_color(index, red, green, blue); } else { # if WS2812_LED_TOTAL > 0 - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].r = red; - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].g = green; - rgb_matrix_ws2812_array[index - ISSI_LED_TOTAL].b = blue; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].r = red; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].g = green; + rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].b = blue; # endif } } diff --git a/keyboards/matrix/m20add/config.h b/keyboards/matrix/m20add/config.h index aba23573577..51b050ca7c1 100644 --- a/keyboards/matrix/m20add/config.h +++ b/keyboards/matrix/m20add/config.h @@ -80,4 +80,4 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_DRIVER_COUNT 1 -#define RGB_MATRIX_LED_COUNT 20 +#define IS31FL3731_LED_COUNT 20 diff --git a/keyboards/matrix/m20add/rgb_ring.c b/keyboards/matrix/m20add/rgb_ring.c index 553a3d53605..f3fbe83d72c 100644 --- a/keyboards/matrix/m20add/rgb_ring.c +++ b/keyboards/matrix/m20add/rgb_ring.c @@ -30,7 +30,7 @@ #endif // rgb ring leds setting -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -371,13 +371,7 @@ void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) void rgb_ring_init(void) { - i2c_init(); - is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); - for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) { - bool enabled = true; - is31fl3731_set_led_control_register(index, enabled, enabled, enabled); - } - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0); + is31fl3731_init_drivers(); } void rgb_ring_task(void) diff --git a/keyboards/neson_design/700e/700e.c b/keyboards/neson_design/700e/700e.c index d4aa336edb5..9def73d6a44 100644 --- a/keyboards/neson_design/700e/700e.c +++ b/keyboards/neson_design/700e/700e.c @@ -111,7 +111,7 @@ static void self_testing(void) } if (rgb_state.index >= ST_LEFT_END) { - for (int i = rgb_state.index - 1; i < RGB_MATRIX_LED_COUNT - rgb_state.index + 1; i++) { + for (int i = rgb_state.index - 1; i < IS31FL3731_LED_COUNT - rgb_state.index + 1; i++) { is31fl3731_set_color(i, led.r, led.g, led.b); } if (rgb_state.index == ST_LEFT_END) { @@ -173,13 +173,13 @@ static void self_testing(void) } break; case ST_STAGE_3: - if (rgb_state.index != RGB_MATRIX_LED_COUNT/2) { + if (rgb_state.index != IS31FL3731_LED_COUNT/2) { is31fl3731_set_color_all(0, 0, 0); } // light left and right - if (rgb_state.index == RGB_MATRIX_LED_COUNT/2) { + if (rgb_state.index == IS31FL3731_LED_COUNT/2) { if (rgb_state.duration) { rgb_state.duration--; } else { @@ -207,7 +207,7 @@ static void self_testing(void) update_ticks(); } -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -294,18 +294,8 @@ void matrix_init_kb(void) setPinOutput(LED_CAPS_LOCK_PIN); writePinLow(LED_CAPS_LOCK_PIN); - i2c_init(); - is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); -#ifdef IS31FL3731_I2C_ADDRESS_2 - is31fl3731_init(IS31FL3731_I2C_ADDRESS_2); -#endif - for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) { - is31fl3731_set_led_control_register(index, true, true, true); - } - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0); -#ifdef IS31FL3731_I2C_ADDRESS_2 - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1); -#endif + is31fl3731_init_drivers(); + update_ticks(); matrix_init_user(); } @@ -350,16 +340,16 @@ void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) { if (rgb_state.state != NORMAL) return; - for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (uint8_t i = 0; i < IS31FL3731_LED_COUNT; i++) { is31fl3731_set_color(i, start_led[i].r, start_led[i].g, start_led[i].b); } rgb_led_t leds[4]; for (int i = 0; i < 4; i++) { - leds[i].r = start_led[RGB_MATRIX_LED_COUNT+i].g; - leds[i].g = start_led[RGB_MATRIX_LED_COUNT+i].r; - leds[i].b = start_led[RGB_MATRIX_LED_COUNT+i].b; + leds[i].r = start_led[IS31FL3731_LED_COUNT+i].g; + leds[i].g = start_led[IS31FL3731_LED_COUNT+i].r; + leds[i].b = start_led[IS31FL3731_LED_COUNT+i].b; } - //ws2812_setleds(start_led+RGB_MATRIX_LED_COUNT, 4); + //ws2812_setleds(start_led+IS31FL3731_LED_COUNT, 4); ws2812_setleds(leds, 4); } diff --git a/keyboards/neson_design/700e/config.h b/keyboards/neson_design/700e/config.h index bd1d9888ec6..4cecb6165a8 100644 --- a/keyboards/neson_design/700e/config.h +++ b/keyboards/neson_design/700e/config.h @@ -35,6 +35,6 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL+DRIVER_2_LED_TOTAL) +#define IS31FL3731_LED_COUNT (DRIVER_1_LED_TOTAL+DRIVER_2_LED_TOTAL) #define USB_SUSPEND_WAKEUP_DELAY 1000 diff --git a/keyboards/neson_design/n6/config.h b/keyboards/neson_design/n6/config.h index 22a25a0d923..847b26eb256 100644 --- a/keyboards/neson_design/n6/config.h +++ b/keyboards/neson_design/n6/config.h @@ -35,4 +35,4 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL+DRIVER_2_LED_TOTAL) +#define IS31FL3731_LED_COUNT (DRIVER_1_LED_TOTAL+DRIVER_2_LED_TOTAL) diff --git a/keyboards/neson_design/n6/n6.c b/keyboards/neson_design/n6/n6.c index 5f3ae3a169d..38b634eeb73 100644 --- a/keyboards/neson_design/n6/n6.c +++ b/keyboards/neson_design/n6/n6.c @@ -115,7 +115,7 @@ static void self_testing(void) } if (rgb_state.index >= ST_LEFT_END) { - for (int i = rgb_state.index - 1; i < RGB_MATRIX_LED_COUNT - rgb_state.index + 1; i++) { + for (int i = rgb_state.index - 1; i < IS31FL3731_LED_COUNT - rgb_state.index + 1; i++) { is31fl3731_set_color(i, led.r, led.g, led.b); } if (rgb_state.index == ST_LEFT_END) { @@ -177,13 +177,13 @@ static void self_testing(void) } break; case ST_STAGE_3: - if (rgb_state.index != RGB_MATRIX_LED_COUNT/2) { + if (rgb_state.index != IS31FL3731_LED_COUNT/2) { is31fl3731_set_color_all(0, 0, 0); } // light left and right - if (rgb_state.index == RGB_MATRIX_LED_COUNT/2) { + if (rgb_state.index == IS31FL3731_LED_COUNT/2) { if (rgb_state.duration) { rgb_state.duration--; } else { @@ -211,7 +211,7 @@ static void self_testing(void) update_ticks(); } -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -298,18 +298,8 @@ void matrix_init_kb(void) setPinOutput(LED_CAPS_LOCK_PIN); writePinLow(LED_CAPS_LOCK_PIN); - i2c_init(); - is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); -#ifdef IS31FL3731_I2C_ADDRESS_2 - is31fl3731_init(IS31FL3731_I2C_ADDRESS_2); -#endif - for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) { - is31fl3731_set_led_control_register(index, true, true, true); - } - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0); -#ifdef IS31FL3731_I2C_ADDRESS_2 - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1); -#endif + is31fl3731_init_drivers(); + update_ticks(); matrix_init_user(); } @@ -352,10 +342,10 @@ void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) { if (rgb_state.state != NORMAL) return; - for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + for (uint8_t i = 0; i < IS31FL3731_LED_COUNT; i++) { is31fl3731_set_color(i, start_led[i].r, start_led[i].g, start_led[i].b); } - ws2812_setleds(start_led+RGB_MATRIX_LED_COUNT, 1); + ws2812_setleds(start_led+IS31FL3731_LED_COUNT, 1); } bool led_update_kb(led_t led_state) diff --git a/keyboards/novelkeys/nk65/config.h b/keyboards/novelkeys/nk65/config.h index 4dc1ab91656..bbba5cd7d8d 100755 --- a/keyboards/novelkeys/nk65/config.h +++ b/keyboards/novelkeys/nk65/config.h @@ -53,7 +53,7 @@ along with this program. If not, see . #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_GND_SDA #define IS31FL3733_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 128 +#define IS31FL3733_LED_COUNT 128 // These define which keys in the matrix are alphas/mods // Used for backlight effects so colors are different for diff --git a/keyboards/novelkeys/nk87/config.h b/keyboards/novelkeys/nk87/config.h index 3b3e9309c11..41ecb8a8e34 100755 --- a/keyboards/novelkeys/nk87/config.h +++ b/keyboards/novelkeys/nk87/config.h @@ -53,7 +53,7 @@ along with this program. If not, see . #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_GND_SDA #define IS31FL3733_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 128 +#define IS31FL3733_LED_COUNT 128 // These define which keys in the matrix are alphas/mods // Used for backlight effects so colors are different for diff --git a/keyboards/spaceholdings/nebula12/config.h b/keyboards/spaceholdings/nebula12/config.h index 5e4b48927f0..512b7751361 100755 --- a/keyboards/spaceholdings/nebula12/config.h +++ b/keyboards/spaceholdings/nebula12/config.h @@ -75,7 +75,7 @@ along with this program. If not, see . #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_DRIVER_COUNT 1 -#define RGB_MATRIX_LED_COUNT 16 +#define IS31FL3731_LED_COUNT 16 // These define which keys in the matrix are alphas/mods // Used for backlight effects so colors are different for diff --git a/keyboards/spaceholdings/nebula68/config.h b/keyboards/spaceholdings/nebula68/config.h index 0283a4a036f..1ad24d364c7 100755 --- a/keyboards/spaceholdings/nebula68/config.h +++ b/keyboards/spaceholdings/nebula68/config.h @@ -59,7 +59,7 @@ along with this program. If not, see . #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_GND_SDA #define IS31FL3733_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 128 +#define IS31FL3733_LED_COUNT 128 // These define which keys in the matrix are alphas/mods // Used for backlight effects so colors are different for diff --git a/keyboards/tkc/portico/config.h b/keyboards/tkc/portico/config.h index 5599f2a36b1..2a1056b4a5f 100644 --- a/keyboards/tkc/portico/config.h +++ b/keyboards/tkc/portico/config.h @@ -51,7 +51,7 @@ along with this program. If not, see . #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 67 +#define IS31FL3731_LED_COUNT 67 #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/tkc/portico/portico.c b/keyboards/tkc/portico/portico.c index bbb09ef8f67..72f8754f6c9 100644 --- a/keyboards/tkc/portico/portico.c +++ b/keyboards/tkc/portico/portico.c @@ -19,7 +19,7 @@ along with this program. If not, see . #ifdef RGB_MATRIX_ENABLE -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { { 0, C2_1, C3_1, C4_1 }, { 0, C1_1, C3_2, C4_2 }, { 0, C1_2, C2_2, C4_3 }, diff --git a/keyboards/tkc/portico75/config.h b/keyboards/tkc/portico75/config.h index 756dfbb54a9..3a9b50baca7 100644 --- a/keyboards/tkc/portico75/config.h +++ b/keyboards/tkc/portico75/config.h @@ -81,7 +81,7 @@ along with this program. If not, see . // WT_RGB IS31FL3741 driver code # define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND # define IS31FL3741_DRIVER_COUNT 1 -# define RGB_MATRIX_LED_COUNT 98 +# define IS31FL3741_LED_COUNT 98 # define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/tkc/portico75/portico75.c b/keyboards/tkc/portico75/portico75.c index 69d62560714..f0751483aad 100644 --- a/keyboards/tkc/portico75/portico75.c +++ b/keyboards/tkc/portico75/portico75.c @@ -20,7 +20,7 @@ along with this program. If not, see . #ifdef RGB_MATRIX_ENABLE -const is31fl3741_led_t PROGMEM g_is31fl3741_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT] = { {0, CS18_SW1, CS17_SW1, CS16_SW1}, {0, CS18_SW2, CS17_SW2, CS16_SW2}, {0, CS18_SW3, CS17_SW3, CS16_SW3}, diff --git a/keyboards/wilba_tech/rama_works_kara/config.h b/keyboards/wilba_tech/rama_works_kara/config.h index 5d8c9df8206..09aac7a5528 100644 --- a/keyboards/wilba_tech/rama_works_kara/config.h +++ b/keyboards/wilba_tech/rama_works_kara/config.h @@ -19,7 +19,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 // Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/wilba_tech/rama_works_koyu/config.h b/keyboards/wilba_tech/rama_works_koyu/config.h index aad4cd12ac2..512cff857bb 100644 --- a/keyboards/wilba_tech/rama_works_koyu/config.h +++ b/keyboards/wilba_tech/rama_works_koyu/config.h @@ -19,7 +19,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 // Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m10_c/config.h b/keyboards/wilba_tech/rama_works_m10_c/config.h index 529896f6eda..1e0d943b96f 100644 --- a/keyboards/wilba_tech/rama_works_m10_c/config.h +++ b/keyboards/wilba_tech/rama_works_m10_c/config.h @@ -23,7 +23,7 @@ // IS31FL3731 driver #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_DRIVER_COUNT 1 -#define RGB_MATRIX_LED_COUNT 12 +#define IS31FL3731_LED_COUNT 12 // Enable WT RGB backlight #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/rama_works_m50_a/config.h b/keyboards/wilba_tech/rama_works_m50_a/config.h index 599550b91f6..98149ffa143 100644 --- a/keyboards/wilba_tech/rama_works_m50_a/config.h +++ b/keyboards/wilba_tech/rama_works_m50_a/config.h @@ -24,7 +24,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 // Enable WT RGB backlight #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/rama_works_m60_a/config.h b/keyboards/wilba_tech/rama_works_m60_a/config.h index bc7d7e61287..c291ba2db3f 100644 --- a/keyboards/wilba_tech/rama_works_m60_a/config.h +++ b/keyboards/wilba_tech/rama_works_m60_a/config.h @@ -19,7 +19,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 // Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m65_b/config.h b/keyboards/wilba_tech/rama_works_m65_b/config.h index b3e381d77db..9807fbc8746 100644 --- a/keyboards/wilba_tech/rama_works_m65_b/config.h +++ b/keyboards/wilba_tech/rama_works_m65_b/config.h @@ -24,7 +24,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 // Enable WT RGB backlight #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/rama_works_m65_bx/config.h b/keyboards/wilba_tech/rama_works_m65_bx/config.h index 8070e917d74..64da89ff9e4 100644 --- a/keyboards/wilba_tech/rama_works_m65_bx/config.h +++ b/keyboards/wilba_tech/rama_works_m65_bx/config.h @@ -24,7 +24,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 // Enable WT RGB backlight #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/rama_works_m6_b/config.h b/keyboards/wilba_tech/rama_works_m6_b/config.h index 27a5e72c047..112cd500beb 100644 --- a/keyboards/wilba_tech/rama_works_m6_b/config.h +++ b/keyboards/wilba_tech/rama_works_m6_b/config.h @@ -20,7 +20,7 @@ /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE -#define RGB_MATRIX_LED_COUNT 6 +#define IS31FL3218_LED_COUNT 6 #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/rama_works_u80_a/config.h b/keyboards/wilba_tech/rama_works_u80_a/config.h index 4ab2d53c3c9..2a0da80fed4 100644 --- a/keyboards/wilba_tech/rama_works_u80_a/config.h +++ b/keyboards/wilba_tech/rama_works_u80_a/config.h @@ -42,7 +42,7 @@ #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_I2C_ADDRESS_3 IS31FL3731_I2C_ADDRESS_SCL #define IS31FL3731_DRIVER_COUNT 3 -#define RGB_MATRIX_LED_COUNT 108 +#define IS31FL3731_LED_COUNT 108 #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/wt60_a/config.h b/keyboards/wilba_tech/wt60_a/config.h index c9d448fbb82..25a6f25a1c8 100644 --- a/keyboards/wilba_tech/wt60_a/config.h +++ b/keyboards/wilba_tech/wt60_a/config.h @@ -64,4 +64,4 @@ #define IS31FL3736_I2C_ADDRESS_1 IS31FL3736_I2C_ADDRESS_GND_GND #define IS31FL3736_DRIVER_COUNT 1 -#define LED_MATRIX_LED_COUNT 96 +#define IS31FL3736_LED_COUNT 96 diff --git a/keyboards/wilba_tech/wt60_b/config.h b/keyboards/wilba_tech/wt60_b/config.h index c5fb1b32c76..926136f332f 100644 --- a/keyboards/wilba_tech/wt60_b/config.h +++ b/keyboards/wilba_tech/wt60_b/config.h @@ -26,7 +26,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/wt60_bx/config.h b/keyboards/wilba_tech/wt60_bx/config.h index f87d9ff48e3..85ab052437a 100644 --- a/keyboards/wilba_tech/wt60_bx/config.h +++ b/keyboards/wilba_tech/wt60_bx/config.h @@ -26,7 +26,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/wt60_c/config.h b/keyboards/wilba_tech/wt60_c/config.h index 4a1b8b6ad2b..ca7366bc32b 100644 --- a/keyboards/wilba_tech/wt60_c/config.h +++ b/keyboards/wilba_tech/wt60_c/config.h @@ -26,7 +26,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 #define RGB_BACKLIGHT_ENABLED 1 diff --git a/keyboards/wilba_tech/wt65_a/config.h b/keyboards/wilba_tech/wt65_a/config.h index 04d607e77a7..88f28ac8445 100644 --- a/keyboards/wilba_tech/wt65_a/config.h +++ b/keyboards/wilba_tech/wt65_a/config.h @@ -64,4 +64,4 @@ #define IS31FL3736_I2C_ADDRESS_1 IS31FL3736_I2C_ADDRESS_GND_GND #define IS31FL3736_DRIVER_COUNT 1 -#define LED_MATRIX_LED_COUNT 96 +#define IS31FL3736_LED_COUNT 96 diff --git a/keyboards/wilba_tech/wt65_b/config.h b/keyboards/wilba_tech/wt65_b/config.h index 780b3c80c47..164caecd00c 100644 --- a/keyboards/wilba_tech/wt65_b/config.h +++ b/keyboards/wilba_tech/wt65_b/config.h @@ -64,4 +64,4 @@ #define IS31FL3736_I2C_ADDRESS_1 IS31FL3736_I2C_ADDRESS_GND_GND #define IS31FL3736_DRIVER_COUNT 1 -#define LED_MATRIX_LED_COUNT 96 +#define IS31FL3736_LED_COUNT 96 diff --git a/keyboards/wilba_tech/wt75_a/config.h b/keyboards/wilba_tech/wt75_a/config.h index 29399e148a4..a8185a68074 100644 --- a/keyboards/wilba_tech/wt75_a/config.h +++ b/keyboards/wilba_tech/wt75_a/config.h @@ -64,4 +64,4 @@ #define IS31FL3736_I2C_ADDRESS_1 IS31FL3736_I2C_ADDRESS_GND_GND #define IS31FL3736_DRIVER_COUNT 1 -#define LED_MATRIX_LED_COUNT 96 +#define IS31FL3736_LED_COUNT 96 diff --git a/keyboards/wilba_tech/wt75_b/config.h b/keyboards/wilba_tech/wt75_b/config.h index 71ca6891cad..48342516914 100644 --- a/keyboards/wilba_tech/wt75_b/config.h +++ b/keyboards/wilba_tech/wt75_b/config.h @@ -64,4 +64,4 @@ #define IS31FL3736_I2C_ADDRESS_1 IS31FL3736_I2C_ADDRESS_GND_GND #define IS31FL3736_DRIVER_COUNT 1 -#define LED_MATRIX_LED_COUNT 96 +#define IS31FL3736_LED_COUNT 96 diff --git a/keyboards/wilba_tech/wt75_c/config.h b/keyboards/wilba_tech/wt75_c/config.h index b404dccfbbf..d1e81992f53 100644 --- a/keyboards/wilba_tech/wt75_c/config.h +++ b/keyboards/wilba_tech/wt75_c/config.h @@ -64,4 +64,4 @@ #define IS31FL3736_I2C_ADDRESS_1 IS31FL3736_I2C_ADDRESS_GND_GND #define IS31FL3736_DRIVER_COUNT 1 -#define LED_MATRIX_LED_COUNT 96 +#define IS31FL3736_LED_COUNT 96 diff --git a/keyboards/wilba_tech/wt80_a/config.h b/keyboards/wilba_tech/wt80_a/config.h index a1f8fbdef6c..c6594c16898 100644 --- a/keyboards/wilba_tech/wt80_a/config.h +++ b/keyboards/wilba_tech/wt80_a/config.h @@ -64,4 +64,4 @@ #define IS31FL3736_I2C_ADDRESS_1 IS31FL3736_I2C_ADDRESS_GND_GND #define IS31FL3736_DRIVER_COUNT 1 -#define LED_MATRIX_LED_COUNT 96 +#define IS31FL3736_LED_COUNT 96 diff --git a/keyboards/wilba_tech/wt_mono_backlight.c b/keyboards/wilba_tech/wt_mono_backlight.c index 4add18b14eb..e218f0af4be 100644 --- a/keyboards/wilba_tech/wt_mono_backlight.c +++ b/keyboards/wilba_tech/wt_mono_backlight.c @@ -50,7 +50,7 @@ backlight_config g_config = { .color_1 = MONO_BACKLIGHT_COLOR_1, }; -const is31fl3736_led_t PROGMEM g_is31fl3736_leds[LED_MATRIX_LED_COUNT] = { +const is31fl3736_led_t PROGMEM g_is31fl3736_leds[IS31FL3736_LED_COUNT] = { {0, A_1}, {0, A_2}, {0, A_3}, @@ -170,14 +170,7 @@ uint32_t g_any_key_hit = 0; void backlight_init_drivers(void) { - // Initialize I2C - i2c_init(); - is31fl3736_init( IS31FL3736_I2C_ADDRESS_1 ); - - for ( uint8_t index = 0; index < 96; index++ ) { - is31fl3736_set_led_control_register( index, true ); - } - is31fl3736_update_led_control_registers( IS31FL3736_I2C_ADDRESS_1, 0 ); + is31fl3736_init_drivers(); } void backlight_set_key_hit(uint8_t row, uint8_t column) diff --git a/keyboards/wilba_tech/wt_rgb_backlight.c b/keyboards/wilba_tech/wt_rgb_backlight.c index 1c865deecf8..8bd04c840fd 100644 --- a/keyboards/wilba_tech/wt_rgb_backlight.c +++ b/keyboards/wilba_tech/wt_rgb_backlight.c @@ -157,7 +157,7 @@ uint32_t g_any_key_hit = 0; #if defined(RGB_BACKLIGHT_HS60) #define ISSI_ADDR_1 IS31FL3733_I2C_ADDRESS_GND_GND -const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -234,7 +234,7 @@ const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = { #define ISSI_ADDR_1 IS31FL3733_I2C_ADDRESS_GND_GND #define ISSI_ADDR_2 IS31FL3733_I2C_ADDRESS_GND_SDA -const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -375,7 +375,7 @@ const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = { #elif defined(RGB_BACKLIGHT_NEBULA12) #define ISSI_ADDR_1 IS31FL3731_I2C_ADDRESS_GND -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -406,7 +406,7 @@ const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { #define ISSI_ADDR_2 IS31FL3731_I2C_ADDRESS_SDA #define ISSI_ADDR_3 IS31FL3731_I2C_ADDRESS_SCL -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -531,7 +531,7 @@ const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { #define ISSI_ADDR_1 IS31FL3731_I2C_ADDRESS_GND #define ISSI_ADDR_2 IS31FL3731_I2C_ADDRESS_SDA -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -610,7 +610,7 @@ const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { #define ISSI_ADDR_1 IS31FL3731_I2C_ADDRESS_GND #define ISSI_ADDR_2 IS31FL3731_I2C_ADDRESS_VCC -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -694,7 +694,7 @@ const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { #define ISSI_ADDR_1 IS31FL3741_I2C_ADDRESS_GND #define ISSI_ADDR_2 -const is31fl3741_led_t PROGMEM g_is31fl3741_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -817,7 +817,7 @@ const is31fl3741_led_t PROGMEM g_is31fl3741_leds[RGB_MATRIX_LED_COUNT] = { }; #elif defined(RGB_BACKLIGHT_M6_B) -const is31fl3218_led_t PROGMEM g_is31fl3218_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT] = { {OUT1, OUT2, OUT3}, {OUT4, OUT5, OUT6}, {OUT7, OUT8, OUT9}, @@ -829,7 +829,7 @@ const is31fl3218_led_t PROGMEM g_is31fl3218_leds[RGB_MATRIX_LED_COUNT] = { #define ISSI_ADDR_1 IS31FL3731_I2C_ADDRESS_GND #define ISSI_ADDR_2 -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { {0, C1_9, C3_10, C4_10}, // LB1 {0, C1_10, C2_10, C4_11}, // LB2 {0, C1_11, C2_11, C3_11}, // LB3 @@ -847,7 +847,7 @@ const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { #define ISSI_ADDR_1 IS31FL3731_I2C_ADDRESS_GND #define ISSI_ADDR_2 IS31FL3731_I2C_ADDRESS_SDA -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -1817,12 +1817,12 @@ void backlight_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) is31fl3733_set_color( index, red, green, blue ); } #elif defined(RGB_BACKLIGHT_DAWN60) - if( index < RGB_MATRIX_LED_COUNT ) { + if( index < IS31FL3731_LED_COUNT ) { is31fl3731_set_color( index, red, green, blue ); } else { - g_ws2812_leds[index - RGB_MATRIX_LED_COUNT].r = red; - g_ws2812_leds[index - RGB_MATRIX_LED_COUNT].g = green; - g_ws2812_leds[index - RGB_MATRIX_LED_COUNT].b = blue; + g_ws2812_leds[index - IS31FL3731_LED_COUNT].r = red; + g_ws2812_leds[index - IS31FL3731_LED_COUNT].g = green; + g_ws2812_leds[index - IS31FL3731_LED_COUNT].b = blue; ws2812_setleds(g_ws2812_leds, WS2812_LED_TOTAL); } #else @@ -2111,9 +2111,9 @@ void backlight_effect_alphas_mods(void) for (int i = 0; i < WS2812_LED_TOTAL; i++) { if ((RGB_UNDERGLOW_ALPHA_TOP_START <= i && i <= RGB_UNDERGLOW_ALPHA_TOP_END) || (RGB_UNDERGLOW_ALPHA_BOT_START <= i && i <= RGB_UNDERGLOW_ALPHA_BOT_END)) { - backlight_set_color(i + RGB_MATRIX_LED_COUNT, rgb1.r, rgb1.g, rgb1.b); + backlight_set_color(i + IS31FL3731_LED_COUNT, rgb1.r, rgb1.g, rgb1.b); } else { - backlight_set_color(i + RGB_MATRIX_LED_COUNT, rgb2.r, rgb2.g, rgb2.b); + backlight_set_color(i + IS31FL3731_LED_COUNT, rgb2.r, rgb2.g, rgb2.b); } } #endif @@ -2902,7 +2902,7 @@ void backlight_init_drivers(void) #if defined(RGB_BACKLIGHT_M6_B) is31fl3218_init(); - for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) + for ( int index = 0; index < IS31FL3218_LED_COUNT; index++ ) { bool enabled = true; @@ -2913,9 +2913,9 @@ void backlight_init_drivers(void) // This actually updates the LED drivers is31fl3218_update_led_control_registers(); #elif defined(RGB_BACKLIGHT_HS60) - is31fl3733_init( ISSI_ADDR_1, 0 ); + is31fl3733_init( ISSI_ADDR_1, IS31FL3733_SYNC_NONE ); - for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) + for ( int index = 0; index < IS31FL3733_LED_COUNT; index++ ) { #if defined(HS60_ANSI) bool enabled = !( ( index == 48-1 ) || //LA48 @@ -2934,10 +2934,10 @@ void backlight_init_drivers(void) // This actually updates the LED drivers is31fl3733_update_led_control_registers( ISSI_ADDR_1, 0 ); #elif defined(RGB_BACKLIGHT_NK65) - is31fl3733_init( ISSI_ADDR_1, 0 ); - is31fl3733_init( ISSI_ADDR_2, 0 ); + is31fl3733_init( ISSI_ADDR_1, IS31FL3733_SYNC_NONE ); + is31fl3733_init( ISSI_ADDR_2, IS31FL3733_SYNC_NONE ); - for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) + for ( int index = 0; index < IS31FL3733_LED_COUNT; index++ ) { bool enabled = !( ( index == 61-1 ) || //LA61 ( index > 6+64-1 ) ); //LB7-LB64 @@ -2949,10 +2949,10 @@ void backlight_init_drivers(void) is31fl3733_update_led_control_registers( ISSI_ADDR_1, 0 ); is31fl3733_update_led_control_registers( ISSI_ADDR_2, 1 ); #elif defined(RGB_BACKLIGHT_NK87) - is31fl3733_init( ISSI_ADDR_1, 0 ); - is31fl3733_init( ISSI_ADDR_2, 0 ); + is31fl3733_init( ISSI_ADDR_1, IS31FL3733_SYNC_NONE ); + is31fl3733_init( ISSI_ADDR_2, IS31FL3733_SYNC_NONE ); - for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) + for ( int index = 0; index < IS31FL3733_LED_COUNT; index++ ) { bool enabled = !( ( index == 61-1 ) || //LA61 ( (index >= 2+64-1) && (index <= 4+64-1) ) || @@ -2979,10 +2979,10 @@ void backlight_init_drivers(void) is31fl3733_update_led_control_registers( ISSI_ADDR_1, 0 ); is31fl3733_update_led_control_registers( ISSI_ADDR_2, 1 ); #elif defined(RGB_BACKLIGHT_NEBULA68) - is31fl3733_init( ISSI_ADDR_1, 0 ); - is31fl3733_init( ISSI_ADDR_2, 0 ); + is31fl3733_init( ISSI_ADDR_1, IS31FL3733_SYNC_NONE ); + is31fl3733_init( ISSI_ADDR_2, IS31FL3733_SYNC_NONE ); - for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) + for ( int index = 0; index < IS31FL3733_LED_COUNT; index++ ) { bool enabled = !( ( index == 61-1 ) || //LA61 ( index > 5+64-1 ) ); //LB6-LB64 @@ -2995,17 +2995,17 @@ void backlight_init_drivers(void) #elif defined(RGB_BACKLIGHT_PORTICO75) is31fl3741_init( ISSI_ADDR_1 ); bool enabled = true; - for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) + for ( int index = 0; index < IS31FL3741_LED_COUNT; index++ ) { is31fl3741_set_led_control_register( index, enabled, enabled, enabled ); } // This actually updates the LED drivers is31fl3741_update_led_control_registers( ISSI_ADDR_1, 0 ); #elif defined(RGB_BACKLIGHT_KW_MEGA) - is31fl3733_init( ISSI_ADDR_1, 0 ); - is31fl3733_init( ISSI_ADDR_2, 0 ); + is31fl3733_init( ISSI_ADDR_1, IS31FL3733_SYNC_NONE ); + is31fl3733_init( ISSI_ADDR_2, IS31FL3733_SYNC_NONE ); - for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) + for ( int index = 0; index < IS31FL3733_LED_COUNT; index++ ) { bool enabled = !( ( index == 61-1 ) || //LA61 ( index > 6+64-1 ) ); //LB7-LB64 @@ -3032,7 +3032,7 @@ void backlight_init_drivers(void) bool disable_spacebar_stab_leds = false; #endif - for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) + for ( int index = 0; index < BACKLIGHT_LED_COUNT; index++ ) { // OR the possible "disabled" cases together, then NOT the result to get the enabled state // LC6 LD13 not present on Zeal65 diff --git a/keyboards/wilba_tech/zeal60/config.h b/keyboards/wilba_tech/zeal60/config.h index 3233c6187d7..830dd6d78a2 100644 --- a/keyboards/wilba_tech/zeal60/config.h +++ b/keyboards/wilba_tech/zeal60/config.h @@ -19,7 +19,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 // Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/wilba_tech/zeal65/config.h b/keyboards/wilba_tech/zeal65/config.h index 1046ee81089..a7d1b81f846 100644 --- a/keyboards/wilba_tech/zeal65/config.h +++ b/keyboards/wilba_tech/zeal65/config.h @@ -19,7 +19,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 72 +#define IS31FL3731_LED_COUNT 72 // Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/xelus/dawn60/rev1/config.h b/keyboards/xelus/dawn60/rev1/config.h index c7945df3d6a..a2a127f0a4b 100644 --- a/keyboards/xelus/dawn60/rev1/config.h +++ b/keyboards/xelus/dawn60/rev1/config.h @@ -19,7 +19,7 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_DRIVER_COUNT 2 -#define RGB_MATRIX_LED_COUNT 64 +#define IS31FL3731_LED_COUNT 64 // Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/xelus/dawn60/rev1_qmk/config.h b/keyboards/xelus/dawn60/rev1_qmk/config.h index 33629a8ef3d..e0ffe308430 100644 --- a/keyboards/xelus/dawn60/rev1_qmk/config.h +++ b/keyboards/xelus/dawn60/rev1_qmk/config.h @@ -30,8 +30,8 @@ #define IS31FL3731_DRIVER_COUNT 2 #define DRIVER_1_LED_TOTAL 32 #define DRIVER_2_LED_TOTAL 32 -#define ISSI_DRIVER_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) -#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL + WS2812_LED_TOTAL) +#define IS31FL3731_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) +#define RGB_MATRIX_LED_COUNT (IS31FL3731_LED_COUNT + WS2812_LED_TOTAL) #define RGB_MATRIX_DEFAULT_VAL 80 #define RGB_MATRIX_KEYPRESSES diff --git a/keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c b/keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c index da83d358b97..35ac5a06b2e 100644 --- a/keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c +++ b/keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c @@ -25,7 +25,7 @@ #ifdef RGB_MATRIX_ENABLE rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL]; -const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -99,28 +99,6 @@ const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = { {1, C9_14, C8_14, C7_14}, //D14 {1, C9_15, C8_15, C6_14}, //D15 {1, C9_16, C7_15, C6_15}, //D16 - - //fake underglows 1- 20 - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0}, - {2, 0, 0, 0} }; __attribute__ ((weak)) @@ -169,7 +147,7 @@ static void init(void) { i2c_init(); is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); is31fl3731_init(IS31FL3731_I2C_ADDRESS_2); - for (int index = 0; index < ISSI_DRIVER_TOTAL; index++) { + for (int index = 0; index < IS31FL3731_LED_COUNT; index++) { bool enabled = true; is31fl3731_set_led_control_register(index, enabled, enabled, enabled); } @@ -187,12 +165,12 @@ static void flush(void) { } static void set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { - if (index < ISSI_DRIVER_TOTAL) { + if (index < IS31FL3731_LED_COUNT) { is31fl3731_set_color(index, red, green, blue); } else { - rgb_matrix_ws2812_array[index - ISSI_DRIVER_TOTAL].r = red; - rgb_matrix_ws2812_array[index - ISSI_DRIVER_TOTAL].g = green; - rgb_matrix_ws2812_array[index - ISSI_DRIVER_TOTAL].b = blue; + rgb_matrix_ws2812_array[index - IS31FL3731_LED_COUNT].r = red; + rgb_matrix_ws2812_array[index - IS31FL3731_LED_COUNT].g = green; + rgb_matrix_ws2812_array[index - IS31FL3731_LED_COUNT].b = blue; } } diff --git a/keyboards/xelus/pachi/rgb/rev1/config.h b/keyboards/xelus/pachi/rgb/rev1/config.h index e51a176c847..8d86a977c15 100644 --- a/keyboards/xelus/pachi/rgb/rev1/config.h +++ b/keyboards/xelus/pachi/rgb/rev1/config.h @@ -41,8 +41,7 @@ #define IS31FL3741_DRIVER_COUNT 1 #define DRIVER_1_LED_TOTAL 117 -#define RGB_MATRIX_LED_COUNT DRIVER_1_LED_TOTAL -#define ISSI_DRIVER_TOTAL RGB_MATRIX_LED_COUNT +#define IS31FL3741_LED_COUNT DRIVER_1_LED_TOTAL #define RGB_MATRIX_DEFAULT_VAL 80 #define RGB_MATRIX_FRAMEBUFFER_EFFECTS diff --git a/keyboards/xelus/pachi/rgb/rev1/rev1.c b/keyboards/xelus/pachi/rgb/rev1/rev1.c index 1a3d9b2f4d4..e43726115ed 100644 --- a/keyboards/xelus/pachi/rgb/rev1/rev1.c +++ b/keyboards/xelus/pachi/rgb/rev1/rev1.c @@ -22,7 +22,7 @@ void matrix_io_delay(void) { __asm__ volatile("nop\nnop\nnop\n"); } #ifdef RGB_MATRIX_ENABLE #include "i2c_master.h" #include "drivers/led/issi/is31fl3741.h" -const is31fl3741_led_t PROGMEM g_is31fl3741_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -189,7 +189,7 @@ led_config_t g_led_config = { { static void init(void) { i2c_init(); is31fl3741_init(IS31FL3741_I2C_ADDRESS_1); - for (int index = 0; index < ISSI_DRIVER_TOTAL; index++) { + for (int index = 0; index < IS31FL3741_LED_COUNT; index++) { bool enabled = !( ( index == -1+0+13) || //A13 ( index == -1+13+3) || //B3 ( index == -1+13+13) || //B13 diff --git a/keyboards/xelus/pachi/rgb/rev2/config.h b/keyboards/xelus/pachi/rgb/rev2/config.h index da989e16a2b..0afc9e2a43e 100644 --- a/keyboards/xelus/pachi/rgb/rev2/config.h +++ b/keyboards/xelus/pachi/rgb/rev2/config.h @@ -41,8 +41,7 @@ #define IS31FL3741_DRIVER_COUNT 1 #define DRIVER_1_LED_TOTAL 117 -#define RGB_MATRIX_LED_COUNT DRIVER_1_LED_TOTAL -#define ISSI_DRIVER_TOTAL RGB_MATRIX_LED_COUNT +#define IS31FL3741_LED_COUNT DRIVER_1_LED_TOTAL #define RGB_MATRIX_DEFAULT_VAL 80 #define RGB_MATRIX_FRAMEBUFFER_EFFECTS diff --git a/keyboards/xelus/pachi/rgb/rev2/rev2.c b/keyboards/xelus/pachi/rgb/rev2/rev2.c index 729b6b05453..25d1406653c 100644 --- a/keyboards/xelus/pachi/rgb/rev2/rev2.c +++ b/keyboards/xelus/pachi/rgb/rev2/rev2.c @@ -22,7 +22,7 @@ void matrix_io_delay(void) { __asm__ volatile("nop\nnop\nnop\n"); } #ifdef RGB_MATRIX_ENABLE #include "i2c_master.h" #include "drivers/led/issi/is31fl3741.h" -const is31fl3741_led_t PROGMEM g_is31fl3741_leds[RGB_MATRIX_LED_COUNT] = { +const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | R location @@ -195,7 +195,7 @@ led_config_t g_led_config = { { static void init(void) { i2c_init(); is31fl3741_init(IS31FL3741_I2C_ADDRESS_1); - for (int index = 0; index < ISSI_DRIVER_TOTAL; index++) { + for (int index = 0; index < IS31FL3741_LED_COUNT; index++) { bool enabled = !( ( index == -1+0+13) || //A13 ( index == -1+13+3) || //B3 ( index == -1+13+13) || //B13 diff --git a/quantum/led_matrix/led_matrix_drivers.c b/quantum/led_matrix/led_matrix_drivers.c index ab8da3353ac..117bed9851b 100644 --- a/quantum/led_matrix/led_matrix_drivers.c +++ b/quantum/led_matrix/led_matrix_drivers.c @@ -25,290 +25,68 @@ * in their own files. */ -#if defined(LED_MATRIX_IS31FL3218) || defined(LED_MATRIX_IS31FL3731) || defined(LED_MATRIX_IS31FL3733) || defined(LED_MATRIX_IS31FL3736) || defined(LED_MATRIX_IS31FL3737) || defined(LED_MATRIX_IS31FL3741) || defined(IS31FLCOMMON) || defined(LED_MATRIX_SNLED27351) -# include "i2c_master.h" - -static void init(void) { - i2c_init(); - -# if defined(LED_MATRIX_IS31FL3218) - is31fl3218_init(); - -# elif defined(LED_MATRIX_IS31FL3731) - is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); -# if defined(IS31FL3731_I2C_ADDRESS_2) - is31fl3731_init(IS31FL3731_I2C_ADDRESS_2); -# if defined(IS31FL3731_I2C_ADDRESS_3) - is31fl3731_init(IS31FL3731_I2C_ADDRESS_3); -# if defined(IS31FL3731_I2C_ADDRESS_4) - is31fl3731_init(IS31FL3731_I2C_ADDRESS_4); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_IS31FL3733) -# if !defined(IS31FL3733_SYNC_1) -# define IS31FL3733_SYNC_1 0 -# endif - is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1); -# if defined(IS31FL3733_I2C_ADDRESS_2) -# if !defined(IS31FL3733_SYNC_2) -# define IS31FL3733_SYNC_2 0 -# endif - is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2); -# if defined(IS31FL3733_I2C_ADDRESS_3) -# if !defined(IS31FL3733_SYNC_3) -# define IS31FL3733_SYNC_3 0 -# endif - is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3); -# if defined(IS31FL3733_I2C_ADDRESS_4) -# if !defined(IS31FL3733_SYNC_4) -# define IS31FL3733_SYNC_4 0 -# endif - is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_IS31FL3736) - is31fl3736_init(IS31FL3736_I2C_ADDRESS_1); -# if defined(IS31FL3736_I2C_ADDRESS_2) - is31fl3736_init(IS31FL3736_I2C_ADDRESS_2); -# if defined(IS31FL3736_I2C_ADDRESS_3) - is31fl3736_init(IS31FL3736_I2C_ADDRESS_3); -# if defined(IS31FL3736_I2C_ADDRESS_4) - is31fl3736_init(IS31FL3736_I2C_ADDRESS_4); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_IS31FL3737) - is31fl3737_init(IS31FL3737_I2C_ADDRESS_1); -# if defined(IS31FL3737_I2C_ADDRESS_2) - is31fl3737_init(IS31FL3737_I2C_ADDRESS_2); -# if defined(IS31FL3737_I2C_ADDRESS_3) - is31fl3737_init(IS31FL3737_I2C_ADDRESS_3); -# if defined(IS31FL3737_I2C_ADDRESS_4) - is31fl3737_init(IS31FL3737_I2C_ADDRESS_4); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_IS31FL3741) - 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 - -# elif defined(IS31FLCOMMON) - IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1); -# if defined(LED_DRIVER_ADDR_2) - IS31FL_common_init(DRIVER_ADDR_2, ISSI_SSR_2); -# if defined(LED_DRIVER_ADDR_3) - IS31FL_common_init(DRIVER_ADDR_3, ISSI_SSR_3); -# if defined(LED_DRIVER_ADDR_4) - IS31FL_common_init(DRIVER_ADDR_4, ISSI_SSR_4); -# endif -# endif -# endif -# elif defined(LED_MATRIX_SNLED27351) -# if defined(LED_DRIVER_SHUTDOWN_PIN) - setPinOutput(LED_DRIVER_SHUTDOWN_PIN); - writePinHigh(LED_DRIVER_SHUTDOWN_PIN); -# endif - - 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 -# endif - - for (int index = 0; index < LED_MATRIX_LED_COUNT; index++) { -# if defined(LED_MATRIX_IS31FL3218) - is31fl3218_set_led_control_register(index, true); -# elif defined(LED_MATRIX_IS31FL3731) - is31fl3731_set_led_control_register(index, true); -# elif defined(LED_MATRIX_IS31FL3733) - is31fl3733_set_led_control_register(index, true); -# elif defined(LED_MATRIX_IS31FL3736) - is31fl3736_set_led_control_register(index, true); -# elif defined(LED_MATRIX_IS31FL3737) - is31fl3737_set_led_control_register(index, true); -# elif defined(LED_MATRIX_IS31FL3741) - is31fl3741_set_led_control_register(index, true); -# elif defined(IS31FLCOMMON) - IS31FL_simple_set_scaling_buffer(index, true); -# elif defined(LED_MATRIX_SNLED27351) - snled27351_set_led_control_register(index, true); -# endif - } - -// This actually updates the LED drivers -# if defined(LED_MATRIX_IS31FL3218) - is31fl3218_update_led_control_registers(); - -# elif defined(LED_MATRIX_IS31FL3731) - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0); -# if defined(IS31FL3731_I2C_ADDRESS_2) - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1); -# if defined(IS31FL3731_I2C_ADDRESS_3) - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2); -# if defined(IS31FL3731_I2C_ADDRESS_4) - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_IS31FL3733) - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0); -# if defined(IS31FL3733_I2C_ADDRESS_2) - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1); -# if defined(IS31FL3733_I2C_ADDRESS_3) - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2); -# if defined(IS31FL3733_I2C_ADDRESS_4) - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_IS31FL3736) - is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_1, 0); -# if defined(IS31FL3736_I2C_ADDRESS_2) - is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_2, 1); -# if defined(IS31FL3736_I2C_ADDRESS_3) - is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_3, 2); -# if defined(IS31FL3736_I2C_ADDRESS_4) - is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_4, 3); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_IS31FL3737) - is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_1, 0); -# if defined(IS31FL3737_I2C_ADDRESS_2) - is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_2, 1); -# if defined(IS31FL3737_I2C_ADDRESS_3) - is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_3, 2); -# if defined(IS31FL3737_I2C_ADDRESS_4) - is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_4, 3); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_IS31FL3741) - 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 - -# elif defined(IS31FLCOMMON) -# ifdef ISSI_MANUAL_SCALING - IS31FL_set_manual_scaling_buffer(); -# endif - IS31FL_common_update_scaling_register(DRIVER_ADDR_1, 0); -# if defined(LED_DRIVER_ADDR_2) - IS31FL_common_update_scaling_register(DRIVER_ADDR_2, 1); -# if defined(LED_DRIVER_ADDR_3) - IS31FL_common_update_scaling_register(DRIVER_ADDR_3, 2); -# if defined(LED_DRIVER_ADDR_4) - IS31FL_common_update_scaling_register(DRIVER_ADDR_4, 3); -# endif -# endif -# endif - -# elif defined(LED_MATRIX_SNLED27351) - 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 -# endif -} - -# if defined(LED_MATRIX_IS31FL3218) +#if defined(LED_MATRIX_IS31FL3218) const led_matrix_driver_t led_matrix_driver = { - .init = init, + .init = is31fl3218_init, .flush = is31fl3218_update_pwm_buffers, .set_value = is31fl3218_set_value, .set_value_all = is31fl3218_set_value_all, }; -# elif defined(LED_MATRIX_IS31FL3731) +#elif defined(LED_MATRIX_IS31FL3731) const led_matrix_driver_t led_matrix_driver = { - .init = init, - .flush = is31fl3731_flush, - .set_value = is31fl3731_set_value, + .init = is31fl3731_init_drivers, + .flush = is31fl3731_flush, + .set_value = is31fl3731_set_value, .set_value_all = is31fl3731_set_value_all, }; -# elif defined(LED_MATRIX_IS31FL3733) +#elif defined(LED_MATRIX_IS31FL3733) const led_matrix_driver_t led_matrix_driver = { - .init = init, - .flush = is31fl3733_flush, - .set_value = is31fl3733_set_value, + .init = is31fl3733_init_drivers, + .flush = is31fl3733_flush, + .set_value = is31fl3733_set_value, .set_value_all = is31fl3733_set_value_all, }; -# elif defined(LED_MATRIX_IS31FL3736) +#elif defined(LED_MATRIX_IS31FL3736) const led_matrix_driver_t led_matrix_driver = { - .init = init, - .flush = is31fl3736_flush, - .set_value = is31fl3736_set_value, + .init = is31fl3736_init_drivers, + .flush = is31fl3736_flush, + .set_value = is31fl3736_set_value, .set_value_all = is31fl3736_set_value_all, }; -# elif defined(LED_MATRIX_IS31FL3737) +#elif defined(LED_MATRIX_IS31FL3737) const led_matrix_driver_t led_matrix_driver = { - .init = init, - .flush = is31fl3737_flush, - .set_value = is31fl3737_set_value, + .init = is31fl3737_init_drivers, + .flush = is31fl3737_flush, + .set_value = is31fl3737_set_value, .set_value_all = is31fl3737_set_value_all, }; -# elif defined(LED_MATRIX_IS31FL3741) +#elif defined(LED_MATRIX_IS31FL3741) const led_matrix_driver_t led_matrix_driver = { - .init = init, - .flush = is31fl3741_flush, - .set_value = is31fl3741_set_value, + .init = is31fl3741_init_drivers, + .flush = is31fl3741_flush, + .set_value = is31fl3741_set_value, .set_value_all = is31fl3741_set_value_all, }; -# elif defined(IS31FLCOMMON) +#elif defined(IS31FLCOMMON) const led_matrix_driver_t led_matrix_driver = { - .init = init, - .flush = IS31FL_common_flush, - .set_value = IS31FL_simple_set_brightness, + .init = IS31FL_simple_init_drivers, + .flush = IS31FL_common_flush, + .set_value = IS31FL_simple_set_brightness, .set_value_all = IS31FL_simple_set_brigntness_all, }; -# elif defined(LED_MATRIX_SNLED27351) + +#elif defined(LED_MATRIX_SNLED27351) const led_matrix_driver_t led_matrix_driver = { - .init = init, - .flush = snled27351_flush, - .set_value = snled27351_set_value, + .init = snled27351_init_drivers, + .flush = snled27351_flush, + .set_value = snled27351_set_value, .set_value_all = snled27351_set_value_all, }; -# endif + #endif diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 0fe93ee0778..0f979cb2337 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -24,307 +24,73 @@ * be here if shared between boards. */ -#if defined(RGB_MATRIX_IS31FL3218) || defined(RGB_MATRIX_IS31FL3731) || defined(RGB_MATRIX_IS31FL3733) || defined(RGB_MATRIX_IS31FL3736) || defined(RGB_MATRIX_IS31FL3737) || defined(RGB_MATRIX_IS31FL3741) || defined(IS31FLCOMMON) || defined(RGB_MATRIX_SNLED27351) -# include "i2c_master.h" - -static void init(void) { - i2c_init(); - -# if defined(RGB_MATRIX_IS31FL3218) - is31fl3218_init(); - -# elif defined(RGB_MATRIX_IS31FL3731) - is31fl3731_init(IS31FL3731_I2C_ADDRESS_1); -# if defined(IS31FL3731_I2C_ADDRESS_2) - is31fl3731_init(IS31FL3731_I2C_ADDRESS_2); -# if defined(IS31FL3731_I2C_ADDRESS_3) - is31fl3731_init(IS31FL3731_I2C_ADDRESS_3); -# if defined(IS31FL3731_I2C_ADDRESS_4) - is31fl3731_init(IS31FL3731_I2C_ADDRESS_4); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_IS31FL3733) -# if !defined(IS31FL3733_SYNC_1) -# define IS31FL3733_SYNC_1 0 -# endif - is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1); -# if defined(IS31FL3733_I2C_ADDRESS_2) -# if !defined(IS31FL3733_SYNC_2) -# define IS31FL3733_SYNC_2 0 -# endif - is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2); -# if defined(IS31FL3733_I2C_ADDRESS_3) -# if !defined(IS31FL3733_SYNC_3) -# define IS31FL3733_SYNC_3 0 -# endif - is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3); -# if defined(IS31FL3733_I2C_ADDRESS_4) -# if !defined(IS31FL3733_SYNC_4) -# define IS31FL3733_SYNC_4 0 -# endif - is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_IS31FL3736) - is31fl3736_init(IS31FL3736_I2C_ADDRESS_1); -# if defined(IS31FL3736_I2C_ADDRESS_2) - is31fl3736_init(IS31FL3736_I2C_ADDRESS_2); -# if defined(IS31FL3736_I2C_ADDRESS_3) - is31fl3736_init(IS31FL3736_I2C_ADDRESS_3); -# if defined(IS31FL3736_I2C_ADDRESS_4) - is31fl3736_init(IS31FL3736_I2C_ADDRESS_4); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_IS31FL3737) - is31fl3737_init(IS31FL3737_I2C_ADDRESS_1); -# if defined(IS31FL3737_I2C_ADDRESS_2) - is31fl3737_init(IS31FL3737_I2C_ADDRESS_2); -# if defined(IS31FL3737_I2C_ADDRESS_3) - is31fl3737_init(IS31FL3737_I2C_ADDRESS_3); -# if defined(IS31FL3737_I2C_ADDRESS_4) - is31fl3737_init(IS31FL3737_I2C_ADDRESS_4); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_IS31FL3741) - 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 - -# elif defined(IS31FLCOMMON) - IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1); -# if defined(DRIVER_ADDR_2) - IS31FL_common_init(DRIVER_ADDR_2, ISSI_SSR_2); -# if defined(DRIVER_ADDR_3) - IS31FL_common_init(DRIVER_ADDR_3, ISSI_SSR_3); -# if defined(DRIVER_ADDR_4) - IS31FL_common_init(DRIVER_ADDR_4, ISSI_SSR_4); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_SNLED27351) - 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 -# endif - - for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) { - bool enabled = true; - - // This only caches it for later -# if defined(RGB_MATRIX_IS31FL3218) - is31fl3218_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(RGB_MATRIX_IS31FL3731) - is31fl3731_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(RGB_MATRIX_IS31FL3733) - is31fl3733_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(RGB_MATRIX_IS31FL3736) - is31fl3736_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(RGB_MATRIX_IS31FL3737) - is31fl3737_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(RGB_MATRIX_IS31FL3741) - is31fl3741_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(IS31FLCOMMON) - IS31FL_RGB_set_scaling_buffer(index, enabled, enabled, enabled); -# elif defined(RGB_MATRIX_SNLED27351) - snled27351_set_led_control_register(index, enabled, enabled, enabled); -# endif - } - - // This actually updates the LED drivers -# if defined(RGB_MATRIX_IS31FL3218) - is31fl3218_update_led_control_registers(); - -# elif defined(RGB_MATRIX_IS31FL3731) - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0); -# if defined(IS31FL3731_I2C_ADDRESS_2) - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1); -# if defined(IS31FL3731_I2C_ADDRESS_3) - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2); -# if defined(IS31FL3731_I2C_ADDRESS_4) - is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_IS31FL3733) - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0); -# if defined(IS31FL3733_I2C_ADDRESS_2) - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1); -# if defined(IS31FL3733_I2C_ADDRESS_3) - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2); -# if defined(IS31FL3733_I2C_ADDRESS_4) - is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_IS31FL3736) - is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_1, 0); -# if defined(IS31FL3736_I2C_ADDRESS_2) - is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_2, 1); -# if defined(IS31FL3736_I2C_ADDRESS_3) - is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_3, 2); -# if defined(IS31FL3736_I2C_ADDRESS_4) - is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_4, 3); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_IS31FL3737) - is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_1, 0); -# if defined(IS31FL3737_I2C_ADDRESS_2) - is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_2, 1); -# if defined(IS31FL3737_I2C_ADDRESS_3) - is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_3, 2); -# if defined(IS31FL3737_I2C_ADDRESS_4) - is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_4, 3); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_IS31FL3741) - 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 - -# elif defined(IS31FLCOMMON) -# ifdef ISSI_MANUAL_SCALING - IS31FL_set_manual_scaling_buffer(); -# endif - IS31FL_common_update_scaling_register(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - IS31FL_common_update_scaling_register(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - IS31FL_common_update_scaling_register(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - IS31FL_common_update_scaling_register(DRIVER_ADDR_4, 3); -# endif -# endif -# endif - -# elif defined(RGB_MATRIX_SNLED27351) - 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 -# endif -} - -# if defined(RGB_MATRIX_IS31FL3218) +#if defined(RGB_MATRIX_IS31FL3218) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, + .init = is31fl3218_init, .flush = is31fl3218_update_pwm_buffers, .set_color = is31fl3218_set_color, .set_color_all = is31fl3218_set_color_all, }; -# elif defined(RGB_MATRIX_IS31FL3731) +#elif defined(RGB_MATRIX_IS31FL3731) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = is31fl3731_flush, - .set_color = is31fl3731_set_color, + .init = is31fl3731_init_drivers, + .flush = is31fl3731_flush, + .set_color = is31fl3731_set_color, .set_color_all = is31fl3731_set_color_all, }; -# elif defined(RGB_MATRIX_IS31FL3733) +#elif defined(RGB_MATRIX_IS31FL3733) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = is31fl3733_flush, - .set_color = is31fl3733_set_color, + .init = is31fl3733_init_drivers, + .flush = is31fl3733_flush, + .set_color = is31fl3733_set_color, .set_color_all = is31fl3733_set_color_all, }; -# elif defined(RGB_MATRIX_IS31FL3736) +#elif defined(RGB_MATRIX_IS31FL3736) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = is31fl3736_flush, - .set_color = is31fl3736_set_color, + .init = is31fl3736_init_drivers, + .flush = is31fl3736_flush, + .set_color = is31fl3736_set_color, .set_color_all = is31fl3736_set_color_all, }; -# elif defined(RGB_MATRIX_IS31FL3737) +#elif defined(RGB_MATRIX_IS31FL3737) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = is31fl3737_flush, - .set_color = is31fl3737_set_color, + .init = is31fl3737_init_drivers, + .flush = is31fl3737_flush, + .set_color = is31fl3737_set_color, .set_color_all = is31fl3737_set_color_all, }; -# elif defined(RGB_MATRIX_IS31FL3741) +#elif defined(RGB_MATRIX_IS31FL3741) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = is31fl3741_flush, - .set_color = is31fl3741_set_color, + .init = is31fl3741_init_drivers, + .flush = is31fl3741_flush, + .set_color = is31fl3741_set_color, .set_color_all = is31fl3741_set_color_all, }; -# elif defined(IS31FLCOMMON) +#elif defined(IS31FLCOMMON) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = IS31FL_common_flush, - .set_color = IS31FL_RGB_set_color, + .init = IS31FL_RGB_init_drivers, + .flush = IS31FL_common_flush, + .set_color = IS31FL_RGB_set_color, .set_color_all = IS31FL_RGB_set_color_all, }; -# elif defined(RGB_MATRIX_SNLED27351) +#elif defined(RGB_MATRIX_SNLED27351) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = snled27351_flush, - .set_color = snled27351_set_color, + .init = snled27351_init_drivers, + .flush = snled27351_flush, + .set_color = snled27351_set_color, .set_color_all = snled27351_set_color_all, }; -# endif #elif defined(RGB_MATRIX_AW20216S) -# include "spi_master.h" - -static void init(void) { - spi_init(); - - aw20216s_init(AW20216S_CS_PIN_1, AW20216S_EN_PIN_1); -# if defined(AW20216S_CS_PIN_2) - aw20216s_init(AW20216S_CS_PIN_2, AW20216S_EN_PIN_2); -# endif -} - const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, + .init = aw20216s_init_drivers, .flush = aw20216s_flush, .set_color = aw20216s_set_color, .set_color_all = aw20216s_set_color_all, @@ -391,4 +157,5 @@ const rgb_matrix_driver_t rgb_matrix_driver = { .set_color = setled, .set_color_all = setled_all, }; + #endif