From 806b61c2f71c085de73a93493a6624b5699d63cc Mon Sep 17 00:00:00 2001 From: Xelus22 <17491233+Xelus22@users.noreply.github.com> Date: Fri, 9 Jun 2023 10:00:22 +1000 Subject: [Core] RGB matrix ws2812 update (#21135) * ws2812_update boolean to stop update every single cycle * lint1 Co-authored-by: Joel Challis * lint2 Co-authored-by: Joel Challis * Update quantum/rgb_matrix/rgb_matrix_drivers.c --------- Co-authored-by: Joel Challis --- quantum/rgb_matrix/rgb_matrix_drivers.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'quantum/rgb_matrix') diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index d66fc801dd..6de20ac8a5 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -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; -- cgit v1.2.3