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