Skip to content

Commit

Permalink
[Core] RGB matrix ws2812 update (qmk#21135)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Xelus22 and zvecr authored Jun 9, 2023
1 parent 760a976 commit 806b61c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions quantum/rgb_matrix/rgb_matrix_drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 806b61c

Please sign in to comment.