summaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix
diff options
context:
space:
mode:
authorXelus22 <17491233+Xelus22@users.noreply.github.com>2023-06-09 10:00:22 +1000
committerGitHub <noreply@github.com>2023-06-09 01:00:22 +0100
commit806b61c2f71c085de73a93493a6624b5699d63cc (patch)
treea8ace944a9755389cbf166bca59f52b381d83a26 /quantum/rgb_matrix
parent760a976993d6e4b72a5dc6fecd72e638c189a835 (diff)
[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>
Diffstat (limited to 'quantum/rgb_matrix')
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c15
1 files changed, 13 insertions, 2 deletions
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;