From 8b95dc6e00a9e5c9123a5b9dce7f50326dfb96aa Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 8 Jan 2024 17:28:40 +1100 Subject: [PATCH] LED drivers: more formatting (#22865) --- drivers/led/aw20216s.c | 3 ++- drivers/led/issi/is31fl3741-mono.h | 2 +- drivers/led/issi/is31fl3746a-mono.c | 2 +- drivers/led/issi/is31fl3746a-mono.h | 12 +++++++++++- drivers/led/issi/is31fl3746a.h | 12 +++++++++++- keyboards/input_club/k_type/is31fl3733-dual.c | 6 +++++- keyboards/input_club/k_type/is31fl3733-dual.h | 3 ++- 7 files changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/led/aw20216s.c b/drivers/led/aw20216s.c index ab7f3ccb42..49b059186d 100644 --- a/drivers/led/aw20216s.c +++ b/drivers/led/aw20216s.c @@ -134,6 +134,7 @@ void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { 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) { return; } + g_pwm_buffer[led.driver][led.r] = red; g_pwm_buffer[led.driver][led.g] = green; g_pwm_buffer[led.driver][led.b] = blue; @@ -149,8 +150,8 @@ void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { void aw20216s_update_pwm_buffers(pin_t cs_pin, uint8_t index) { if (g_pwm_buffer_update_required[index]) { aw20216s_write(cs_pin, AW20216S_PAGE_PWM, 0, g_pwm_buffer[index], AW20216S_PWM_REGISTER_COUNT); + g_pwm_buffer_update_required[index] = false; } - g_pwm_buffer_update_required[index] = false; } void aw20216s_flush(void) { diff --git a/drivers/led/issi/is31fl3741-mono.h b/drivers/led/issi/is31fl3741-mono.h index 462543a5bb..ad416b62d5 100644 --- a/drivers/led/issi/is31fl3741-mono.h +++ b/drivers/led/issi/is31fl3741-mono.h @@ -120,7 +120,7 @@ void is31fl3741_update_pwm_buffers(uint8_t addr, uint8_t index); void is31fl3741_update_led_control_registers(uint8_t addr, uint8_t index); void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t value); -void is31fl3741_set_pwm_buffer(const is31fl3741_led *pled, uint8_t value); +void is31fl3741_set_pwm_buffer(const is31fl3741_led_t *pled, uint8_t value); void is31fl3741_flush(void); diff --git a/drivers/led/issi/is31fl3746a-mono.c b/drivers/led/issi/is31fl3746a-mono.c index 3dd97833dd..f9bbdb5dba 100644 --- a/drivers/led/issi/is31fl3746a-mono.c +++ b/drivers/led/issi/is31fl3746a-mono.c @@ -165,7 +165,7 @@ void is31fl3746a_init(uint8_t addr) { wait_ms(10); } -void is31fl3746a_set_color(int index, uint8_t value) { +void is31fl3746a_set_value(int index, uint8_t value) { is31fl3746a_led_t led; if (index >= 0 && index < IS31FL3746A_LED_COUNT) { diff --git a/drivers/led/issi/is31fl3746a-mono.h b/drivers/led/issi/is31fl3746a-mono.h index eda644ad19..12bd501cb5 100644 --- a/drivers/led/issi/is31fl3746a-mono.h +++ b/drivers/led/issi/is31fl3746a-mono.h @@ -66,6 +66,16 @@ # define IS31FL3746A_LED_COUNT LED_MATRIX_LED_COUNT #endif +#if defined(IS31FL3746A_I2C_ADDRESS_4) +# define IS31FL3746A_DRIVER_COUNT 4 +#elif defined(IS31FL3746A_I2C_ADDRESS_3) +# define IS31FL3746A_DRIVER_COUNT 3 +#elif defined(IS31FL3746A_I2C_ADDRESS_2) +# define IS31FL3746A_DRIVER_COUNT 2 +#elif defined(IS31FL3746A_I2C_ADDRESS_1) +# define IS31FL3746A_DRIVER_COUNT 1 +#endif + typedef struct is31fl3746a_led_t { uint8_t driver : 2; uint8_t v; @@ -74,7 +84,7 @@ typedef struct is31fl3746a_led_t { extern const is31fl3746a_led_t PROGMEM g_is31fl3746a_leds[IS31FL3746A_LED_COUNT]; void is31fl3746a_init_drivers(void); -void is31fl3746a_init(uint8_t addr, uint8_t sync); +void is31fl3746a_init(uint8_t addr); void is31fl3746a_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3746a_select_page(uint8_t addr, uint8_t page); void is31fl3746a_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/issi/is31fl3746a.h b/drivers/led/issi/is31fl3746a.h index f335e98e82..870b6ebc88 100644 --- a/drivers/led/issi/is31fl3746a.h +++ b/drivers/led/issi/is31fl3746a.h @@ -66,6 +66,16 @@ # define IS31FL3746A_LED_COUNT RGB_MATRIX_LED_COUNT #endif +#if defined(IS31FL3746A_I2C_ADDRESS_4) +# define IS31FL3746A_DRIVER_COUNT 4 +#elif defined(IS31FL3746A_I2C_ADDRESS_3) +# define IS31FL3746A_DRIVER_COUNT 3 +#elif defined(IS31FL3746A_I2C_ADDRESS_2) +# define IS31FL3746A_DRIVER_COUNT 2 +#elif defined(IS31FL3746A_I2C_ADDRESS_1) +# define IS31FL3746A_DRIVER_COUNT 1 +#endif + typedef struct is31fl3746a_led_t { uint8_t driver : 2; uint8_t r; @@ -76,7 +86,7 @@ typedef struct is31fl3746a_led_t { extern const is31fl3746a_led_t PROGMEM g_is31fl3746a_leds[IS31FL3746A_LED_COUNT]; void is31fl3746a_init_drivers(void); -void is31fl3746a_init(uint8_t addr, uint8_t sync); +void is31fl3746a_init(uint8_t addr); void is31fl3746a_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3746a_select_page(uint8_t addr, uint8_t page); void is31fl3746a_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/keyboards/input_club/k_type/is31fl3733-dual.c b/keyboards/input_club/k_type/is31fl3733-dual.c index 33734001e0..4b40175994 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.c +++ b/keyboards/input_club/k_type/is31fl3733-dual.c @@ -125,6 +125,7 @@ bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffe 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); @@ -180,12 +181,14 @@ 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 < 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) { return; } + g_pwm_buffer[led.driver][led.r] = red; g_pwm_buffer[led.driver][led.g] = green; g_pwm_buffer[led.driver][led.b] = blue; @@ -249,8 +252,9 @@ void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index) { for (int i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) { is31fl3733_write_register(index, addr, i, g_led_control_registers[index][i]); } + + g_led_control_registers_update_required[index] = false; } - g_led_control_registers_update_required[index] = false; } void is31fl3733_flush(void) { diff --git a/keyboards/input_club/k_type/is31fl3733-dual.h b/keyboards/input_club/k_type/is31fl3733-dual.h index 3368794cba..21dd701525 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.h +++ b/keyboards/input_club/k_type/is31fl3733-dual.h @@ -21,6 +21,7 @@ #include #include #include "progmem.h" +#include "util.h" #define IS31FL3733_REG_INTERRUPT_MASK 0xF0 #define IS31FL3733_REG_INTERRUPT_STATUS 0xF1 @@ -77,7 +78,7 @@ typedef struct is31fl3733_led_t { uint8_t r; uint8_t g; uint8_t b; -} __attribute__((packed)) is31fl3733_led_t; +} PACKED is31fl3733_led_t; extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT];