[Core] RGB matrix ws2812 update (#21135)

* ws2812_update boolean to stop update every single cycle

* lint1

Co-authored-by: Joel Challis <git@zvecr.com>

* lint2

Co-authored-by: Joel Challis <git@zvecr.com>

* Update quantum/rgb_matrix/rgb_matrix_drivers.c

---------

Co-authored-by: Joel Challis <git@zvecr.com>
master
Xelus22 2023-06-09 10:00:22 +10:00 committed by GitHub
parent 760a976993
commit 806b61c2f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 2 deletions

View File

@ -426,11 +426,17 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
// LED color buffer
LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
bool ws2812_dirty = false;
static void init(void) {}
static void init(void) {
ws2812_dirty = false;
}
static void flush(void) {
ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT);
if (ws2812_dirty) {
ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT);
ws2812_dirty = false;
}
}
// Set an led in the buffer to a color
@ -448,6 +454,11 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
}
# endif
if (rgb_matrix_ws2812_array[i].r == r && rgb_matrix_ws2812_array[i].g == g && rgb_matrix_ws2812_array[i].b == b) {
return;
}
ws2812_dirty = true;
rgb_matrix_ws2812_array[i].r = r;
rgb_matrix_ws2812_array[i].g = g;
rgb_matrix_ws2812_array[i].b = b;