summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-05-11 13:41:06 +1000
committerGitHub <noreply@github.com>2021-05-11 13:41:06 +1000
commit3edc43964d35986a4cc5eb4602e1d79b8be1bf01 (patch)
tree710e7e74e33d85ceda14f3b422f0debc0ace2c5c /quantum
parentf41fc6b70c48b7fde36a4af1da99033edf4ffc74 (diff)
LED Matrix: Effects! (#12651)
Diffstat (limited to 'quantum')
-rw-r--r--quantum/led_matrix.c71
-rw-r--r--quantum/led_matrix.h20
-rw-r--r--quantum/led_matrix_animations/alpha_mods_anim.h24
-rw-r--r--quantum/led_matrix_animations/band_anim.h15
-rw-r--r--quantum/led_matrix_animations/band_pinwheel_anim.h14
-rw-r--r--quantum/led_matrix_animations/band_spiral_anim.h14
-rw-r--r--quantum/led_matrix_animations/breathing_anim.h19
-rw-r--r--quantum/led_matrix_animations/cycle_left_right_anim.h14
-rw-r--r--quantum/led_matrix_animations/cycle_out_in_anim.h14
-rw-r--r--quantum/led_matrix_animations/cycle_up_down_anim.h14
-rw-r--r--quantum/led_matrix_animations/dual_beacon_anim.h14
-rw-r--r--quantum/led_matrix_animations/led_matrix_effects.inc18
-rw-r--r--quantum/led_matrix_animations/solid_anim.h15
-rw-r--r--quantum/led_matrix_animations/solid_reactive_cross.h39
-rw-r--r--quantum/led_matrix_animations/solid_reactive_nexus.h36
-rw-r--r--quantum/led_matrix_animations/solid_reactive_simple_anim.h16
-rw-r--r--quantum/led_matrix_animations/solid_reactive_wide.h34
-rw-r--r--quantum/led_matrix_animations/solid_splash_anim.h34
-rw-r--r--quantum/led_matrix_animations/wave_left_right_anim.h14
-rw-r--r--quantum/led_matrix_animations/wave_up_down_anim.h14
-rw-r--r--quantum/led_matrix_runners/effect_runner_dx_dy.h16
-rw-r--r--quantum/led_matrix_runners/effect_runner_dx_dy_dist.h17
-rw-r--r--quantum/led_matrix_runners/effect_runner_i.h14
-rw-r--r--quantum/led_matrix_runners/effect_runner_reactive.h28
-rw-r--r--quantum/led_matrix_runners/effect_runner_reactive_splash.h26
-rw-r--r--quantum/led_matrix_runners/effect_runner_sin_cos_i.h16
26 files changed, 554 insertions, 16 deletions
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c
index 3674c9b97e..58cda64130 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -27,6 +27,38 @@
#include <lib/lib8tion/lib8tion.h>
+#ifndef LED_MATRIX_CENTER
+const point_t k_led_matrix_center = {112, 32};
+#else
+const point_t k_led_matrix_center = LED_MATRIX_CENTER;
+#endif
+
+// Generic effect runners
+#include "led_matrix_runners/effect_runner_dx_dy_dist.h"
+#include "led_matrix_runners/effect_runner_dx_dy.h"
+#include "led_matrix_runners/effect_runner_i.h"
+#include "led_matrix_runners/effect_runner_sin_cos_i.h"
+#include "led_matrix_runners/effect_runner_reactive.h"
+#include "led_matrix_runners/effect_runner_reactive_splash.h"
+
+// ------------------------------------------
+// -----Begin led effect includes macros-----
+#define LED_MATRIX_EFFECT(name)
+#define LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+#include "led_matrix_animations/led_matrix_effects.inc"
+#ifdef LED_MATRIX_CUSTOM_KB
+# include "led_matrix_kb.inc"
+#endif
+#ifdef LED_MATRIX_CUSTOM_USER
+# include "led_matrix_user.inc"
+#endif
+
+#undef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#undef LED_MATRIX_EFFECT
+// -----End led effect includes macros-------
+// ------------------------------------------
+
#if defined(LED_DISABLE_AFTER_TIMEOUT) && !defined(LED_DISABLE_TIMEOUT)
# define LED_DISABLE_TIMEOUT (LED_DISABLE_AFTER_TIMEOUT * 1200UL)
#endif
@@ -53,7 +85,7 @@
#endif
#if !defined(LED_MATRIX_STARTUP_MODE)
-# define LED_MATRIX_STARTUP_MODE LED_MATRIX_UNIFORM_BRIGHTNESS
+# define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID
#endif
#if !defined(LED_MATRIX_STARTUP_VAL)
@@ -216,17 +248,6 @@ static bool led_matrix_none(effect_params_t *params) {
return false;
}
-static bool led_matrix_uniform_brightness(effect_params_t *params) {
- LED_MATRIX_USE_LIMITS(led_min, led_max);
-
- uint8_t val = led_matrix_eeconfig.val;
- for (uint8_t i = led_min; i < led_max; i++) {
- LED_MATRIX_TEST_LED_FLAGS();
- led_matrix_set_value(i, val);
- }
- return led_max < DRIVER_LED_TOTAL;
-}
-
static void led_task_timers(void) {
#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0
uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer);
@@ -290,9 +311,31 @@ static void led_task_render(uint8_t effect) {
case LED_MATRIX_NONE:
rendering = led_matrix_none(&led_effect_params);
break;
- case LED_MATRIX_UNIFORM_BRIGHTNESS:
- rendering = led_matrix_uniform_brightness(&led_effect_params);
+
+// ---------------------------------------------
+// -----Begin led effect switch case macros-----
+#define LED_MATRIX_EFFECT(name, ...) \
+ case LED_MATRIX_##name: \
+ rendering = name(&led_effect_params); \
+ break;
+#include "led_matrix_animations/led_matrix_effects.inc"
+#undef LED_MATRIX_EFFECT
+
+#if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER)
+# define LED_MATRIX_EFFECT(name, ...) \
+ case LED_MATRIX_CUSTOM_##name: \
+ rendering = name(&led_effect_params); \
break;
+# ifdef LED_MATRIX_CUSTOM_KB
+# include "led_matrix_kb.inc"
+# endif
+# ifdef LED_MATRIX_CUSTOM_USER
+# include "led_matrix_user.inc"
+# endif
+# undef LED_MATRIX_EFFECT
+#endif
+ // -----End led effect switch case macros-------
+ // ---------------------------------------------
}
led_effect_params.iter++;
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h
index a3fa552b0a..0984de73b3 100644
--- a/quantum/led_matrix.h
+++ b/quantum/led_matrix.h
@@ -53,8 +53,24 @@
enum led_matrix_effects {
LED_MATRIX_NONE = 0,
- LED_MATRIX_UNIFORM_BRIGHTNESS,
- // All new effects go above this line
+// --------------------------------------
+// -----Begin led effect enum macros-----
+#define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_##name,
+#include "led_matrix_animations/led_matrix_effects.inc"
+#undef LED_MATRIX_EFFECT
+
+#if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER)
+# define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_CUSTOM_##name,
+# ifdef LED_MATRIX_CUSTOM_KB
+# include "led_matrix_kb.inc"
+# endif
+# ifdef LED_MATRIX_CUSTOM_USER
+# include "led_matrix_user.inc"
+# endif
+# undef LED_MATRIX_EFFECT
+#endif
+ // --------------------------------------
+ // -----End led effect enum macros-------
LED_MATRIX_EFFECT_MAX
};
diff --git a/quantum/led_matrix_animations/alpha_mods_anim.h b/quantum/led_matrix_animations/alpha_mods_anim.h
new file mode 100644
index 0000000000..a4638fde69
--- /dev/null
+++ b/quantum/led_matrix_animations/alpha_mods_anim.h
@@ -0,0 +1,24 @@
+#ifndef DISABLE_LED_MATRIX_ALPHAS_MODS
+LED_MATRIX_EFFECT(ALPHAS_MODS)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+// alphas = val1, mods = val2
+bool ALPHAS_MODS(effect_params_t* params) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t val1 = led_matrix_eeconfig.val;
+ uint8_t val2 = val1 + led_matrix_eeconfig.speed;
+
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
+ led_matrix_set_value(i, val2);
+ } else {
+ led_matrix_set_value(i, val1);
+ }
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_ALPHAS_MODS
diff --git a/quantum/led_matrix_animations/band_anim.h b/quantum/led_matrix_animations/band_anim.h
new file mode 100644
index 0000000000..4a2b746a76
--- /dev/null
+++ b/quantum/led_matrix_animations/band_anim.h
@@ -0,0 +1,15 @@
+#ifndef DISABLE_LED_MATRIX_BAND
+LED_MATRIX_EFFECT(BAND)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t BAND_math(uint8_t val, uint8_t i, uint8_t time) {
+ int16_t v = val - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
+ return scale8(v < 0 ? 0 : v, val);
+}
+
+bool BAND(effect_params_t* params) {
+ return effect_runner_i(params, &BAND_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_BAND
diff --git a/quantum/led_matrix_animations/band_pinwheel_anim.h b/quantum/led_matrix_animations/band_pinwheel_anim.h
new file mode 100644
index 0000000000..9836320d2a
--- /dev/null
+++ b/quantum/led_matrix_animations/band_pinwheel_anim.h
@@ -0,0 +1,14 @@
+#ifndef DISABLE_LED_MATRIX_BAND_PINWHEEL
+LED_MATRIX_EFFECT(BAND_PINWHEEL)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t BAND_PINWHEEL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t time) {
+ return scale8(val - time - atan2_8(dy, dx) * 3, val);
+}
+
+bool BAND_PINWHEEL(effect_params_t* params) {
+ return effect_runner_dx_dy(params, &BAND_PINWHEEL_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_BAND_PINWHEEL
diff --git a/quantum/led_matrix_animations/band_spiral_anim.h b/quantum/led_matrix_animations/band_spiral_anim.h
new file mode 100644
index 0000000000..be17c03aad
--- /dev/null
+++ b/quantum/led_matrix_animations/band_spiral_anim.h
@@ -0,0 +1,14 @@
+#ifndef DISABLE_LED_MATRIX_BAND_SPIRAL
+LED_MATRIX_EFFECT(BAND_SPIRAL)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t BAND_SPIRAL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
+ return scale8(val + dist - time - atan2_8(dy, dx), val);
+}
+
+bool BAND_SPIRAL(effect_params_t* params) {
+ return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_BAND_SPIRAL
diff --git a/quantum/led_matrix_animations/breathing_anim.h b/quantum/led_matrix_animations/breathing_anim.h
new file mode 100644
index 0000000000..4f49f50690
--- /dev/null
+++ b/quantum/led_matrix_animations/breathing_anim.h
@@ -0,0 +1,19 @@
+#ifndef DISABLE_LED_MATRIX_BREATHING
+LED_MATRIX_EFFECT(BREATHING)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+bool BREATHING(effect_params_t* params) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t val = led_matrix_eeconfig.val;
+ uint16_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 8);
+ val = scale8(abs8(sin8(time) - 128) * 2, val);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ led_matrix_set_value(i, val);
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_BREATHING
diff --git a/quantum/led_matrix_animations/cycle_left_right_anim.h b/quantum/led_matrix_animations/cycle_left_right_anim.h
new file mode 100644
index 0000000000..404fda26f5
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_left_right_anim.h
@@ -0,0 +1,14 @@
+#ifndef DISABLE_LED_MATRIX_CYCLE_LEFT_RIGHT
+LED_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t CYCLE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) {
+ return scale8(g_led_config.point[i].x - time, val);
+}
+
+bool CYCLE_LEFT_RIGHT(effect_params_t* params) {
+ return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_CYCLE_LEFT_RIGHT
diff --git a/quantum/led_matrix_animations/cycle_out_in_anim.h b/quantum/led_matrix_animations/cycle_out_in_anim.h
new file mode 100644
index 0000000000..3f5fc5b187
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_out_in_anim.h
@@ -0,0 +1,14 @@
+#ifndef DISABLE_LED_MATRIX_CYCLE_OUT_IN
+LED_MATRIX_EFFECT(CYCLE_OUT_IN)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t CYCLE_OUT_IN_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
+ return scale8(3 * dist / 2 + time, val);
+}
+
+bool CYCLE_OUT_IN(effect_params_t* params) {
+ return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_CYCLE_OUT_IN
diff --git a/quantum/led_matrix_animations/cycle_up_down_anim.h b/quantum/led_matrix_animations/cycle_up_down_anim.h
new file mode 100644
index 0000000000..25fc211b17
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_up_down_anim.h
@@ -0,0 +1,14 @@
+#ifndef DISABLE_LED_MATRIX_CYCLE_UP_DOWN
+LED_MATRIX_EFFECT(CYCLE_UP_DOWN)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t CYCLE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) {
+ return scale8(g_led_config.point[i].y - time, val);
+}
+
+bool CYCLE_UP_DOWN(effect_params_t* params) {
+ return effect_runner_i(params, &CYCLE_UP_DOWN_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_CYCLE_UP_DOWN
diff --git a/quantum/led_matrix_animations/dual_beacon_anim.h b/quantum/led_matrix_animations/dual_beacon_anim.h
new file mode 100644
index 0000000000..1fa1df1395
--- /dev/null
+++ b/quantum/led_matrix_animations/dual_beacon_anim.h
@@ -0,0 +1,14 @@
+#ifndef DISABLE_LED_MATRIX_DUAL_BEACON
+LED_MATRIX_EFFECT(DUAL_BEACON)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t DUAL_BEACON_math(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
+ return scale8(((g_led_config.point[i].y - k_led_matrix_center.y) * cos + (g_led_config.point[i].x - k_led_matrix_center.x) * sin) / 128, val);
+}
+
+bool DUAL_BEACON(effect_params_t* params) {
+ return effect_runner_sin_cos_i(params, &DUAL_BEACON_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_DUAL_BEACON
diff --git a/quantum/led_matrix_animations/led_matrix_effects.inc b/quantum/led_matrix_animations/led_matrix_effects.inc
new file mode 100644
index 0000000000..67237c5683
--- /dev/null
+++ b/quantum/led_matrix_animations/led_matrix_effects.inc
@@ -0,0 +1,18 @@
+// Add your new core led matrix effect here, order determins enum order, requires "led_matrix_animations/ directory
+#include "led_matrix_animations/solid_anim.h"
+#include "led_matrix_animations/alpha_mods_anim.h"
+#include "led_matrix_animations/breathing_anim.h"
+#include "led_matrix_animations/band_anim.h"
+#include "led_matrix_animations/band_pinwheel_anim.h"
+#include "led_matrix_animations/band_spiral_anim.h"
+#include "led_matrix_animations/cycle_left_right_anim.h"
+#include "led_matrix_animations/cycle_up_down_anim.h"
+#include "led_matrix_animations/cycle_out_in_anim.h"
+#include "led_matrix_animations/dual_beacon_anim.h"
+#include "led_matrix_animations/solid_reactive_simple_anim.h"
+#include "led_matrix_animations/solid_reactive_wide.h"
+#include "led_matrix_animations/solid_reactive_cross.h"
+#include "led_matrix_animations/solid_reactive_nexus.h"
+#include "led_matrix_animations/solid_splash_anim.h"
+#include "led_matrix_animations/wave_left_right_anim.h"
+#include "led_matrix_animations/wave_up_down_anim.h"
diff --git a/quantum/led_matrix_animations/solid_anim.h b/quantum/led_matrix_animations/solid_anim.h
new file mode 100644
index 0000000000..4c9e43c581
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_anim.h
@@ -0,0 +1,15 @@
+LED_MATRIX_EFFECT(SOLID)
+#ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+bool SOLID(effect_params_t* params) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t val = led_matrix_eeconfig.val;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ led_matrix_set_value(i, val);
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/led_matrix_animations/solid_reactive_cross.h b/quantum/led_matrix_animations/solid_reactive_cross.h
new file mode 100644
index 0000000000..a50d1fc629
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_cross.h
@@ -0,0 +1,39 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS)
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
+LED_MATRIX_EFFECT(SOLID_REACTIVE_CROSS)
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
+LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS)
+# endif
+
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t SOLID_REACTIVE_CROSS_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+ uint16_t effect = tick + dist;
+ dx = dx < 0 ? dx * -1 : dx;
+ dy = dy < 0 ? dy * -1 : dy;
+ dx = dx * 16 > 255 ? 255 : dx * 16;
+ dy = dy * 16 > 255 ? 255 : dy * 16;
+ effect += dx > dy ? dy : dx;
+ if (effect > 255) effect = 255;
+ return qadd8(val, 255 - effect);
+}
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
+bool SOLID_REACTIVE_CROSS(effect_params_t* params) {
+ return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math);
+}
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
+bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) {
+ return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math);
+}
+# endif
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS)
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/solid_reactive_nexus.h b/quantum/led_matrix_animations/solid_reactive_nexus.h
new file mode 100644
index 0000000000..4638aac5a4
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_nexus.h
@@ -0,0 +1,36 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS)
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
+LED_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS)
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
+LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS)
+# endif
+
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t SOLID_REACTIVE_NEXUS_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+ uint16_t effect = tick - dist;
+ if (effect > 255) effect = 255;
+ if (dist > 72) effect = 255;
+ if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255;
+ return qadd8(val, 255 - effect);
+}
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
+bool SOLID_REACTIVE_NEXUS(effect_params_t* params) {
+ return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math);
+}
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
+bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) {
+ return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math);
+}
+# endif
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS)
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/solid_reactive_simple_anim.h b/quantum/led_matrix_animations/solid_reactive_simple_anim.h
new file mode 100644
index 0000000000..e1166a4fb6
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_simple_anim.h
@@ -0,0 +1,16 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
+LED_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t SOLID_REACTIVE_SIMPLE_math(uint8_t val, uint16_t offset) {
+ return scale8(255 - offset, val);
+}
+
+bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) {
+ return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // DISABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/solid_reactive_wide.h b/quantum/led_matrix_animations/solid_reactive_wide.h
new file mode 100644
index 0000000000..4bcaba331e
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_wide.h
@@ -0,0 +1,34 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE)
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
+LED_MATRIX_EFFECT(SOLID_REACTIVE_WIDE)
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
+LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE)
+# endif
+
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t SOLID_REACTIVE_WIDE_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+ uint16_t effect = tick + dist * 5;
+ if (effect > 255) effect = 255;
+ return qadd8(val, 255 - effect);
+}
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
+bool SOLID_REACTIVE_WIDE(effect_params_t* params) {
+ return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math);
+}
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
+bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) {
+ return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math);
+}
+# endif
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE)
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/solid_splash_anim.h b/quantum/led_matrix_animations/solid_splash_anim.h
new file mode 100644
index 0000000000..3e9046640e
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_splash_anim.h
@@ -0,0 +1,34 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# if !defined(DISABLE_LED_MATRIX_SOLID_SPLASH) || !defined(DISABLE_LED_MATRIX_SOLID_MULTISPLASH)
+
+# ifndef DISABLE_LED_MATRIX_SOLID_SPLASH
+LED_MATRIX_EFFECT(SOLID_SPLASH)
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_MULTISPLASH
+LED_MATRIX_EFFECT(SOLID_MULTISPLASH)
+# endif
+
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+uint8_t SOLID_SPLASH_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+ uint16_t effect = tick - dist;
+ if (effect > 255) effect = 255;
+ return qadd8(val, 255 - effect);
+}
+
+# ifndef DISABLE_LED_MATRIX_SOLID_SPLASH
+bool SOLID_SPLASH(effect_params_t* params) {
+ return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math);
+}
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_MULTISPLASH
+bool SOLID_MULTISPLASH(effect_params_t* params) {
+ return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math);
+}
+# endif
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_LED_MATRIX_SPLASH) && !defined(DISABLE_LED_MATRIX_MULTISPLASH)
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/wave_left_right_anim.h b/quantum/led_matrix_animations/wave_left_right_anim.h
new file mode 100644
index 0000000000..d547c72cee
--- /dev/null
+++ b/quantum/led_matrix_animations/wave_left_right_anim.h
@@ -0,0 +1,14 @@
+#ifndef DISABLE_LED_MATRIX_WAVE_LEFT_RIGHT
+LED_MATRIX_EFFECT(WAVE_LEFT_RIGHT)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t WAVE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) {
+ return scale8(sin8(g_led_config.point[i].x - time), val);
+}
+
+bool WAVE_LEFT_RIGHT(effect_params_t* params) {
+ return effect_runner_i(params, &WAVE_LEFT_RIGHT_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_WAVE_LEFT_RIGHT
diff --git a/quantum/led_matrix_animations/wave_up_down_anim.h b/quantum/led_matrix_animations/wave_up_down_anim.h
new file mode 100644
index 0000000000..b68ff9bbc6
--- /dev/null
+++ b/quantum/led_matrix_animations/wave_up_down_anim.h
@@ -0,0 +1,14 @@
+#ifndef DISABLE_LED_MATRIX_WAVE_UP_DOWN
+LED_MATRIX_EFFECT(WAVE_UP_DOWN)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t WAVE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) {
+ return scale8(sin8(g_led_config.point[i].y - time), val);
+}
+
+bool WAVE_UP_DOWN(effect_params_t* params) {
+ return effect_runner_i(params, &WAVE_UP_DOWN_math);
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_WAVE_UP_DOWN
diff --git a/quantum/led_matrix_runners/effect_runner_dx_dy.h b/quantum/led_matrix_runners/effect_runner_dx_dy.h
new file mode 100644
index 0000000000..ef97631b90
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_dx_dy.h
@@ -0,0 +1,16 @@
+#pragma once
+
+typedef uint8_t (*dx_dy_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t time);
+
+bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 2);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ int16_t dx = g_led_config.point[i].x - k_led_matrix_center.x;
+ int16_t dy = g_led_config.point[i].y - k_led_matrix_center.y;
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, dx, dy, time));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
diff --git a/quantum/led_matrix_runners/effect_runner_dx_dy_dist.h b/quantum/led_matrix_runners/effect_runner_dx_dy_dist.h
new file mode 100644
index 0000000000..5ef5938be0
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_dx_dy_dist.h
@@ -0,0 +1,17 @@
+#pragma once
+
+typedef uint8_t (*dx_dy_dist_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time);
+
+bool effect_runner_dx_dy_dist(effect_params_t* params, dx_dy_dist_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 2);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ int16_t dx = g_led_config.point[i].x - k_led_matrix_center.x;
+ int16_t dy = g_led_config.point[i].y - k_led_matrix_center.y;
+ uint8_t dist = sqrt16(dx * dx + dy * dy);
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, dx, dy, dist, time));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
diff --git a/quantum/led_matrix_runners/effect_runner_i.h b/quantum/led_matrix_runners/effect_runner_i.h
new file mode 100644
index 0000000000..b3015759be
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_i.h
@@ -0,0 +1,14 @@
+#pragma once
+
+typedef uint8_t (*i_f)(uint8_t val, uint8_t i, uint8_t time);
+
+bool effect_runner_i(effect_params_t* params, i_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 4);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, i, time));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
diff --git a/quantum/led_matrix_runners/effect_runner_reactive.h b/quantum/led_matrix_runners/effect_runner_reactive.h
new file mode 100644
index 0000000000..4369ea8c49
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_reactive.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+
+typedef uint8_t (*reactive_f)(uint8_t val, uint16_t offset);
+
+bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint16_t max_tick = 65535 / led_matrix_eeconfig.speed;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ uint16_t tick = max_tick;
+ // Reverse search to find most recent key hit
+ for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
+ if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
+ tick = g_last_hit_tracker.tick[j];
+ break;
+ }
+ }
+
+ uint16_t offset = scale16by8(tick, led_matrix_eeconfig.speed);
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, offset));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_runners/effect_runner_reactive_splash.h b/quantum/led_matrix_runners/effect_runner_reactive_splash.h
new file mode 100644
index 0000000000..d6eb9731ee
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_reactive_splash.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+
+typedef uint8_t (*reactive_splash_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick);
+
+bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, reactive_splash_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t count = g_last_hit_tracker.count;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ uint8_t val = 0;
+ for (uint8_t j = start; j < count; j++) {
+ int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
+ int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
+ uint8_t dist = sqrt16(dx * dx + dy * dy);
+ uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], led_matrix_eeconfig.speed);
+ val = effect_func(val, dx, dy, dist, tick);
+ }
+ led_matrix_set_value(i, scale8(val, led_matrix_eeconfig.val));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_runners/effect_runner_sin_cos_i.h b/quantum/led_matrix_runners/effect_runner_sin_cos_i.h
new file mode 100644
index 0000000000..4a5219abd1
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_sin_cos_i.h
@@ -0,0 +1,16 @@
+#pragma once
+
+typedef uint8_t (*sin_cos_i_f)(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time);
+
+bool effect_runner_sin_cos_i(effect_params_t* params, sin_cos_i_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint16_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 4);
+ int8_t cos_value = cos8(time) - 128;
+ int8_t sin_value = sin8(time) - 128;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, cos_value, sin_value, i, time));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}