Skip to content

Commit

Permalink
Add _flush() functions to LED drivers (qmk#22308)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and Lorenzo Castoldi committed Dec 27, 2023
1 parent b8fba82 commit 245f73a
Show file tree
Hide file tree
Showing 72 changed files with 346 additions and 319 deletions.
7 changes: 7 additions & 0 deletions drivers/led/aw20216s.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,10 @@ void aw20216s_update_pwm_buffers(pin_t cs_pin, uint8_t index) {
}
g_pwm_buffer_update_required[index] = false;
}

void aw20216s_flush(void) {
aw20216s_update_pwm_buffers(AW20216S_CS_PIN_1, 0);
#if defined(AW20216S_CS_PIN_2)
aw20216s_update_pwm_buffers(AW20216S_CS_PIN_2, 1);
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/aw20216s.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ 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);
void aw20216s_update_pwm_buffers(pin_t cs_pin, uint8_t index);

void aw20216s_flush(void);

#define CS1_SW1 0x00
#define CS2_SW1 0x01
#define CS3_SW1 0x02
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3731-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,16 @@ void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}
}

void is31fl3731_flush(void) {
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_1, 0);
#if defined(IS31FL3731_I2C_ADDRESS_2)
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_2, 1);
# if defined(IS31FL3731_I2C_ADDRESS_3)
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_3, 2);
# if defined(IS31FL3731_I2C_ADDRESS_4)
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3731-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ void is31fl3731_set_led_control_register(uint8_t index, bool value);
void is31fl3731_update_pwm_buffers(uint8_t addr, uint8_t index);
void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index);

void is31fl3731_flush(void);

#define C1_1 0x24
#define C1_2 0x25
#define C1_3 0x26
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3731.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,16 @@ void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index) {
}
g_led_control_registers_update_required[index] = false;
}

void is31fl3731_flush(void) {
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_1, 0);
#if defined(IS31FL3731_I2C_ADDRESS_2)
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_2, 1);
# if defined(IS31FL3731_I2C_ADDRESS_3)
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_3, 2);
# if defined(IS31FL3731_I2C_ADDRESS_4)
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3731.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ void is31fl3731_set_led_control_register(uint8_t index, bool red, bool green, bo
void is31fl3731_update_pwm_buffers(uint8_t addr, uint8_t index);
void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index);

void is31fl3731_flush(void);

#define C1_1 0x24
#define C1_2 0x25
#define C1_3 0x26
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3733-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,16 @@ void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}
}

void is31fl3733_flush(void) {
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_1, 0);
#if defined(IS31FL3733_I2C_ADDRESS_2)
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_2, 1);
# if defined(IS31FL3733_I2C_ADDRESS_3)
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_3, 2);
# if defined(IS31FL3733_I2C_ADDRESS_4)
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3733-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void is31fl3733_set_led_control_register(uint8_t index, bool value);
void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index);
void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index);

void is31fl3733_flush(void);

#define IS31FL3733_PUR_0R 0x00 // No PUR resistor
#define IS31FL3733_PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL
#define IS31FL3733_PUR_3KR 0x03 // 3.0k Ohm resistor on all the time
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3733.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,16 @@ void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}
}

void is31fl3733_flush(void) {
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_1, 0);
#if defined(IS31FL3733_I2C_ADDRESS_2)
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_2, 1);
# if defined(IS31FL3733_I2C_ADDRESS_3)
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_3, 2);
# if defined(IS31FL3733_I2C_ADDRESS_4)
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3733.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ void is31fl3733_set_led_control_register(uint8_t index, bool red, bool green, bo
void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index);
void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index);

void is31fl3733_flush(void);

#define IS31FL3733_PUR_0R 0x00 // No PUR resistor
#define IS31FL3733_PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL
#define IS31FL3733_PUR_3KR 0x03 // 3.0k Ohm resistor on all the time
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3736-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,16 @@ void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}
}

void is31fl3736_flush(void) {
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_1, 0);
#if defined(IS31FL3736_I2C_ADDRESS_2)
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_2, 1);
# if defined(IS31FL3736_I2C_ADDRESS_3)
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_3, 2);
# if defined(IS31FL3736_I2C_ADDRESS_4)
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3736-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ void is31fl3736_set_led_control_register(uint8_t index, bool value);
void is31fl3736_update_pwm_buffers(uint8_t addr, uint8_t index);
void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index);

void is31fl3736_flush(void);

#define IS31FL3736_PUR_0R 0x00 // No PUR resistor
#define IS31FL3736_PUR_05KR 0x01 // 0.5k Ohm resistor
#define IS31FL3736_PUR_1KR 0x02 // 1.0k Ohm resistor
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3736.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,16 @@ void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}
}

void is31fl3736_flush(void) {
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_1, 0);
#if defined(IS31FL3736_I2C_ADDRESS_2)
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_2, 1);
# if defined(IS31FL3736_I2C_ADDRESS_3)
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_3, 2);
# if defined(IS31FL3736_I2C_ADDRESS_4)
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3736.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ void is31fl3736_set_led_control_register(uint8_t index, bool red, bool green, bo
void is31fl3736_update_pwm_buffers(uint8_t addr, uint8_t index);
void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index);

void is31fl3736_flush(void);

#define IS31FL3736_PUR_0R 0x00 // No PUR resistor
#define IS31FL3736_PUR_05KR 0x01 // 0.5k Ohm resistor
#define IS31FL3736_PUR_1KR 0x02 // 1.0k Ohm resistor
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3737-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,16 @@ void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}
}

void is31fl3737_flush(void) {
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_1, 0);
#if defined(IS31FL3737_I2C_ADDRESS_2)
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_2, 1);
# if defined(IS31FL3737_I2C_ADDRESS_3)
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_3, 2);
# if defined(IS31FL3737_I2C_ADDRESS_4)
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3737-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ void is31fl3737_set_led_control_register(uint8_t index, bool value);
void is31fl3737_update_pwm_buffers(uint8_t addr, uint8_t index);
void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index);

void is31fl3737_flush(void);

#define IS31FL3737_PUR_0R 0x00 // No PUR resistor
#define IS31FL3737_PUR_05KR 0x01 // 0.5k Ohm resistor in t_NOL
#define IS31FL3737_PUR_1KR 0x02 // 1.0k Ohm resistor in t_NOL
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3737.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,16 @@ void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}
}

void is31fl3737_flush(void) {
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_1, 0);
#if defined(IS31FL3737_I2C_ADDRESS_2)
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_2, 1);
# if defined(IS31FL3737_I2C_ADDRESS_3)
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_3, 2);
# if defined(IS31FL3737_I2C_ADDRESS_4)
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3737.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ void is31fl3737_set_led_control_register(uint8_t index, bool red, bool green, bo
void is31fl3737_update_pwm_buffers(uint8_t addr, uint8_t index);
void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index);

void is31fl3737_flush(void);

#define IS31FL3737_PUR_0R 0x00 // No PUR resistor
#define IS31FL3737_PUR_05KR 0x01 // 0.5k Ohm resistor in t_NOL
#define IS31FL3737_PUR_1KR 0x02 // 1.0k Ohm resistor in t_NOL
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3741-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,16 @@ void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t valu

g_scaling_registers_update_required[pled->driver] = true;
}

void is31fl3741_flush(void) {
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_1, 0);
#if defined(IS31FL3741_I2C_ADDRESS_2)
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_2, 1);
# if defined(IS31FL3741_I2C_ADDRESS_3)
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_3, 2);
# if defined(IS31FL3741_I2C_ADDRESS_4)
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3741-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t valu

void is31fl3741_set_pwm_buffer(const is31fl3741_led *pled, uint8_t value);

void is31fl3741_flush(void);

#define IS31FL3741_PUR_0R 0x00 // No PUR resistor
#define IS31FL3741_PUR_05KR 0x01 // 0.5k Ohm resistor
#define IS31FL3741_PUR_1KR 0x02 // 1.0k Ohm resistor
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31fl3741.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,16 @@ void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t red,

g_scaling_registers_update_required[pled->driver] = true;
}

void is31fl3741_flush(void) {
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_1, 0);
#if defined(IS31FL3741_I2C_ADDRESS_2)
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_2, 1);
# if defined(IS31FL3741_I2C_ADDRESS_3)
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_3, 2);
# if defined(IS31FL3741_I2C_ADDRESS_4)
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
2 changes: 2 additions & 0 deletions drivers/led/issi/is31fl3741.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t red,

void is31fl3741_set_pwm_buffer(const is31fl3741_led_t *pled, uint8_t red, uint8_t green, uint8_t blue);

void is31fl3741_flush(void);

#define IS31FL3741_PUR_0R 0x00 // No PUR resistor
#define IS31FL3741_PUR_05KR 0x01 // 0.5k Ohm resistor
#define IS31FL3741_PUR_1KR 0x02 // 1.0k Ohm resistor
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/issi/is31flcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ void IS31FL_common_update_scaling_register(uint8_t addr, uint8_t index) {
}
}

void IS31FL_common_flush(void) {
IS31FL_common_update_pwm_register(DRIVER_ADDR_1, 0);
#if defined(DRIVER_ADDR_2)
IS31FL_common_update_pwm_register(DRIVER_ADDR_2, 1);
# if defined(DRIVER_ADDR_3)
IS31FL_common_update_pwm_register(DRIVER_ADDR_3, 2);
# if defined(DRIVER_ADDR_4)
IS31FL_common_update_pwm_register(DRIVER_ADDR_4, 3);
# endif
# endif
#endif
}

#ifdef RGB_MATRIX_ENABLE
// Colour is set by adjusting PWM register
void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
Expand Down
2 changes: 2 additions & 0 deletions drivers/led/issi/is31flcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ void IS31FL_common_init(uint8_t addr, uint8_t ssr);
void IS31FL_common_update_pwm_register(uint8_t addr, uint8_t index);
void IS31FL_common_update_scaling_register(uint8_t addr, uint8_t index);

void IS31FL_common_flush(void);

#ifdef RGB_MATRIX_ENABLE
// RGB Matrix Specific scripts
void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
Expand Down
13 changes: 13 additions & 0 deletions drivers/led/snled27351-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ void snled27351_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}

void snled27351_flush(void) {
snled27351_update_pwm_buffers(SNLED27351_I2C_ADDRESS_1, 0);
#if defined(SNLED27351_I2C_ADDRESS_2)
snled27351_update_pwm_buffers(SNLED27351_I2C_ADDRESS_2, 1);
# if defined(SNLED27351_I2C_ADDRESS_3)
snled27351_update_pwm_buffers(SNLED27351_I2C_ADDRESS_3, 2);
# if defined(SNLED27351_I2C_ADDRESS_4)
snled27351_update_pwm_buffers(SNLED27351_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}

void snled27351_sw_return_normal(uint8_t addr) {
// Select to function page
snled27351_write_register(addr, SNLED27351_REG_CONFIGURE_CMD_PAGE, SNLED27351_FUNCTION_PAGE);
Expand Down
2 changes: 2 additions & 0 deletions drivers/led/snled27351-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ void snled27351_set_led_control_register(uint8_t index, bool value);
void snled27351_update_pwm_buffers(uint8_t addr, uint8_t index);
void snled27351_update_led_control_registers(uint8_t addr, uint8_t index);

void snled27351_flush(void);

void snled27351_sw_return_normal(uint8_t addr);
void snled27351_sw_shutdown(uint8_t addr);

Expand Down
13 changes: 13 additions & 0 deletions drivers/led/snled27351.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ void snled27351_update_led_control_registers(uint8_t addr, uint8_t index) {
g_led_control_registers_update_required[index] = false;
}

void snled27351_flush(void) {
snled27351_update_pwm_buffers(SNLED27351_I2C_ADDRESS_1, 0);
#if defined(SNLED27351_I2C_ADDRESS_2)
snled27351_update_pwm_buffers(SNLED27351_I2C_ADDRESS_2, 1);
# if defined(SNLED27351_I2C_ADDRESS_3)
snled27351_update_pwm_buffers(SNLED27351_I2C_ADDRESS_3, 2);
# if defined(SNLED27351_I2C_ADDRESS_4)
snled27351_update_pwm_buffers(SNLED27351_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}

void snled27351_sw_return_normal(uint8_t addr) {
// Select to function page
snled27351_write_register(addr, SNLED27351_REG_CONFIGURE_CMD_PAGE, SNLED27351_FUNCTION_PAGE);
Expand Down
2 changes: 2 additions & 0 deletions drivers/led/snled27351.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ void snled27351_set_led_control_register(uint8_t index, bool red, bool green, bo
void snled27351_update_pwm_buffers(uint8_t addr, uint8_t index);
void snled27351_update_led_control_registers(uint8_t addr, uint8_t index);

void snled27351_flush(void);

void snled27351_sw_return_normal(uint8_t addr);
void snled27351_sw_shutdown(uint8_t addr);

Expand Down
Loading

0 comments on commit 245f73a

Please sign in to comment.