Skip to content

Commit

Permalink
LED drivers: more formatting (#22865)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Jan 8, 2024
1 parent 7467231 commit 8b95dc6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
3 changes: 2 additions & 1 deletion drivers/led/aw20216s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/led/issi/is31fl3741-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/led/issi/is31fl3746a-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 11 additions & 1 deletion drivers/led/issi/is31fl3746a-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion drivers/led/issi/is31fl3746a.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion keyboards/input_club/k_type/is31fl3733-dual.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion keyboards/input_club/k_type/is31fl3733-dual.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "progmem.h"
#include "util.h"

#define IS31FL3733_REG_INTERRUPT_MASK 0xF0
#define IS31FL3733_REG_INTERRUPT_STATUS 0xF1
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit 8b95dc6

Please sign in to comment.