summaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix')
-rw-r--r--quantum/rgb_matrix/animations/pixel_fractal_anim.h6
-rw-r--r--quantum/rgb_matrix/animations/pixel_rain_anim.h10
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c5
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h3
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c15
5 files changed, 27 insertions, 12 deletions
diff --git a/quantum/rgb_matrix/animations/pixel_fractal_anim.h b/quantum/rgb_matrix/animations/pixel_fractal_anim.h
index 875b4ceb3d..4cd1d9b861 100644
--- a/quantum/rgb_matrix/animations/pixel_fractal_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_fractal_anim.h
@@ -7,7 +7,11 @@ RGB_MATRIX_EFFECT(PIXEL_FRACTAL)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static bool PIXEL_FRACTAL(effect_params_t* params) {
-# define MID_COL MATRIX_COLS / 2
+# if MATRIX_COLS < 2
+# define MID_COL 1
+# else
+# define MID_COL MATRIX_COLS / 2
+# endif
static bool led[MATRIX_ROWS][MID_COL];
static uint32_t wait_timer = 0;
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.c b/quantum/rgb_matrix/rgb_matrix.c
index 1f3912cf7e..1680389793 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -428,7 +428,10 @@ void rgb_matrix_task(void) {
case RENDERING:
rgb_task_render(effect);
if (effect) {
- rgb_matrix_indicators();
+ // Only run the basic indicators in the last render iteration (default there are 5 iterations)
+ if (rgb_effect_params.iter == RGB_MATRIX_LED_PROCESS_MAX_ITERATIONS) {
+ rgb_matrix_indicators();
+ }
rgb_matrix_indicators_advanced(&rgb_effect_params);
}
break;
diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h
index 9ea248b66d..83851d8995 100644
--- a/quantum/rgb_matrix/rgb_matrix.h
+++ b/quantum/rgb_matrix/rgb_matrix.h
@@ -49,8 +49,9 @@
#endif
#ifndef RGB_MATRIX_LED_PROCESS_LIMIT
-# define RGB_MATRIX_LED_PROCESS_LIMIT (RGB_MATRIX_LED_COUNT + 4) / 5
+# define RGB_MATRIX_LED_PROCESS_LIMIT ((RGB_MATRIX_LED_COUNT + 4) / 5)
#endif
+#define RGB_MATRIX_LED_PROCESS_MAX_ITERATIONS ((RGB_MATRIX_LED_COUNT + RGB_MATRIX_LED_PROCESS_LIMIT - 1) / RGB_MATRIX_LED_PROCESS_LIMIT)
#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT
# if defined(RGB_MATRIX_SPLIT)
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;