diff options
Diffstat (limited to 'quantum/rgb_matrix')
| -rw-r--r-- | quantum/rgb_matrix/animations/pixel_rain_anim.h | 10 | ||||
| -rw-r--r-- | quantum/rgb_matrix/rgb_matrix_drivers.c | 15 | 
2 files changed, 16 insertions, 9 deletions
| diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h index 9d63f451e2..26cd73b578 100644 --- a/quantum/rgb_matrix/animations/pixel_rain_anim.h +++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h @@ -16,13 +16,9 @@ static bool PIXEL_RAIN(effect_params_t* params) {          if (!HAS_ANY_FLAGS(g_led_config.flags[led_index], params->flags)) {              return;          } -        if (random8() & 2) { -            rgb_matrix_set_color(led_index, 0, 0, 0); -        } else { -            HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}; -            RGB rgb = rgb_matrix_hsv_to_rgb(hsv); -            rgb_matrix_set_color(led_index, rgb.r, rgb.g, rgb.b); -        } +        HSV hsv = (random8() & 2) ? (HSV){0, 0, 0} : (HSV){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}; +        RGB rgb = rgb_matrix_hsv_to_rgb(hsv); +        rgb_matrix_set_color(led_index, rgb.r, rgb.g, rgb.b);          wait_timer = g_rgb_timer + interval();      } 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; | 
