[Core] Optimisation - Add RGB LED colour set check in drivers (#21134)

This commit is contained in:
Xelus22 2023-06-08 11:58:53 +10:00 committed by GitHub
parent 9a6056d09c
commit d1d0925cf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 41 additions and 1 deletions

View file

@ -145,6 +145,9 @@ void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
aw_led led; aw_led led;
memcpy_P(&led, (&g_aw_leds[index]), sizeof(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.r] = red;
g_pwm_buffer[led.driver][led.g] = green; g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue; g_pwm_buffer[led.driver][led.b] = blue;

View file

@ -151,6 +151,9 @@ void CKLED2001_set_value(int index, uint8_t value) {
if (index >= 0 && index < LED_MATRIX_LED_COUNT) { if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_ckled2001_leds[index]), sizeof(led)); 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[led.driver][led.v] = value;
g_pwm_buffer_update_required[led.driver] = true; g_pwm_buffer_update_required[led.driver] = true;
} }

View file

@ -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) { if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_ckled2001_leds[index]), sizeof(led)); 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.r] = red;
g_pwm_buffer[led.driver][led.g] = green; g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue; g_pwm_buffer[led.driver][led.b] = blue;

View file

@ -72,6 +72,9 @@ void IS31FL3218_init(void) {
} }
void IS31FL3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { 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 + 0] = red;
g_pwm_buffer[index * 3 + 1] = green; g_pwm_buffer[index * 3 + 1] = green;
g_pwm_buffer[index * 3 + 2] = blue; g_pwm_buffer[index * 3 + 2] = blue;

View file

@ -196,6 +196,10 @@ void IS31FL3731_set_value(int index, uint8_t value) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led)); memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
// Subtract 0x24 to get the second index of g_pwm_buffer // 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[led.driver][led.v - 0x24] = value;
g_pwm_buffer_update_required[led.driver] = true; g_pwm_buffer_update_required[led.driver] = true;
} }

View file

@ -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)); memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
// Subtract 0x24 to get the second index of g_pwm_buffer // 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.r - 0x24] = red;
g_pwm_buffer[led.driver][led.g - 0x24] = green; g_pwm_buffer[led.driver][led.g - 0x24] = green;
g_pwm_buffer[led.driver][led.b - 0x24] = blue; g_pwm_buffer[led.driver][led.b - 0x24] = blue;

View file

@ -196,6 +196,9 @@ void IS31FL3733_set_value(int index, uint8_t value) {
if (index >= 0 && index < LED_MATRIX_LED_COUNT) { if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[index]; 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[led.driver][led.v] = value;
g_pwm_buffer_update_required[led.driver] = true; g_pwm_buffer_update_required[led.driver] = true;
} }

View file

@ -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) { if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led)); 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.r] = red;
g_pwm_buffer[led.driver][led.g] = green; g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue; g_pwm_buffer[led.driver][led.b] = blue;

View file

@ -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) { if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led)); 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.r] = red;
g_pwm_buffer[led.driver][led.g] = green; g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue; g_pwm_buffer[led.driver][led.b] = blue;

View file

@ -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) { if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led)); 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.r] = red;
g_pwm_buffer[led.driver][led.g] = green; g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue; g_pwm_buffer[led.driver][led.b] = blue;

View file

@ -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) { if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led)); 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.r] = red;
g_pwm_buffer[led.driver][led.g] = green; g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue; g_pwm_buffer[led.driver][led.b] = blue;
g_pwm_buffer_update_required[led.driver] = true;
} }
} }

View file

@ -139,6 +139,9 @@ void IS31FL_set_manual_scaling_buffer(void) {
if (scale.driver >= 0 && scale.driver < RGB_MATRIX_LED_COUNT) { if (scale.driver >= 0 && scale.driver < RGB_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[scale.driver]; 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.r] = scale.r;
g_scaling_buffer[led.driver][led.g] = scale.g; g_scaling_buffer[led.driver][led.g] = scale.g;
g_scaling_buffer[led.driver][led.b] = scale.b; 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) { if (scale.driver >= 0 && scale.driver < LED_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[scale.driver]; 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; g_scaling_buffer[led.driver][led.v] = scale.v;
# endif # endif
g_scaling_buffer_update_required[led.driver] = true; g_scaling_buffer_update_required[led.driver] = true;