[Core] Optimisation - Add RGB LED colour set check in drivers (#21134)
This commit is contained in:
parent
9a6056d09c
commit
d1d0925cf9
|
@ -145,6 +145,9 @@ void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
aw_led led;
|
||||
memcpy_P(&led, (&g_aw_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;
|
||||
|
|
|
@ -151,6 +151,9 @@ void CKLED2001_set_value(int index, uint8_t value) {
|
|||
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_ckled2001_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.v] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.v] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
|
|
|
@ -150,6 +150,9 @@ void CKLED2001_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_ckled2001_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;
|
||||
|
|
|
@ -72,6 +72,9 @@ void IS31FL3218_init(void) {
|
|||
}
|
||||
|
||||
void IS31FL3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (g_pwm_buffer[index * 3 + 0] == red && g_pwm_buffer[index * 3 + 1] == green && g_pwm_buffer[index * 3 + 2] == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[index * 3 + 0] = red;
|
||||
g_pwm_buffer[index * 3 + 1] = green;
|
||||
g_pwm_buffer[index * 3 + 2] = blue;
|
||||
|
|
|
@ -196,6 +196,10 @@ void IS31FL3731_set_value(int index, uint8_t value) {
|
|||
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
|
||||
|
||||
// Subtract 0x24 to get the second index of g_pwm_buffer
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.v - 0x24] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.v - 0x24] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
|
|
|
@ -184,6 +184,9 @@ void IS31FL3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
|
||||
|
||||
// Subtract 0x24 to get the second index of g_pwm_buffer
|
||||
if (g_pwm_buffer[led.driver][led.r - 0x24] == red && g_pwm_buffer[led.driver][led.g - 0x24] == green && g_pwm_buffer[led.driver][led.b - 0x24] == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.r - 0x24] = red;
|
||||
g_pwm_buffer[led.driver][led.g - 0x24] = green;
|
||||
g_pwm_buffer[led.driver][led.b - 0x24] = blue;
|
||||
|
|
|
@ -196,6 +196,9 @@ void IS31FL3733_set_value(int index, uint8_t value) {
|
|||
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.v] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.v] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
|
|
|
@ -189,6 +189,9 @@ void IS31FL3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31_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;
|
||||
|
|
|
@ -169,6 +169,9 @@ void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31_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;
|
||||
|
|
|
@ -176,6 +176,9 @@ void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31_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;
|
||||
|
|
|
@ -180,10 +180,13 @@ void IS31FL3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31_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_update_required[led.driver] = true;
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,9 @@ void IS31FL_set_manual_scaling_buffer(void) {
|
|||
if (scale.driver >= 0 && scale.driver < RGB_MATRIX_LED_COUNT) {
|
||||
is31_led led = g_is31_leds[scale.driver];
|
||||
|
||||
if (g_scaling_buffer[led.driver][led.r] = scale.r && g_scaling_buffer[led.driver][led.g] = scale.g && g_scaling_buffer[led.driver][led.b] = scale.b) {
|
||||
return;
|
||||
}
|
||||
g_scaling_buffer[led.driver][led.r] = scale.r;
|
||||
g_scaling_buffer[led.driver][led.g] = scale.g;
|
||||
g_scaling_buffer[led.driver][led.b] = scale.b;
|
||||
|
@ -146,6 +149,9 @@ void IS31FL_set_manual_scaling_buffer(void) {
|
|||
if (scale.driver >= 0 && scale.driver < LED_MATRIX_LED_COUNT) {
|
||||
is31_led led = g_is31_leds[scale.driver];
|
||||
|
||||
if (g_scaling_buffer[led.driver][led.v] == scale.v) {
|
||||
return;
|
||||
}
|
||||
g_scaling_buffer[led.driver][led.v] = scale.v;
|
||||
# endif
|
||||
g_scaling_buffer_update_required[led.driver] = true;
|
||||
|
|
Loading…
Reference in New Issue