Relocate LED driver init code (#22365)
This commit is contained in:
		
							parent
							
								
									eac8e67888
								
							
						
					
					
						commit
						b52aca0af8
					
				
					 100 changed files with 795 additions and 798 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue