1
0
Fork 0
forked from forks/qmk_firmware

LED drivers: more formatting (#22865)

This commit is contained in:
Ryan 2024-01-08 17:28:40 +11:00 committed by GitHub
parent 7467231158
commit 8b95dc6e00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 7 deletions

View file

@ -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) {

View file

@ -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);

View file

@ -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) {

View file

@ -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);

View file

@ -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);

View file

@ -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) {

View file

@ -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
@ -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];