Relocate LED driver init code (#22365)
This commit is contained in:
parent
eac8e67888
commit
b52aca0af8
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user