aboutsummaryrefslogtreecommitdiff
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
parentf41fc6b70c48b7fde36a4af1da99033edf4ffc74 (diff)
downloadqmk_firmware-3edc43964d35986a4cc5eb4602e1d79b8be1bf01.tar.gz
qmk_firmware-3edc43964d35986a4cc5eb4602e1d79b8be1bf01.zip
LED Matrix: Effects! (#12651)
-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 3674c9b97..58cda6413 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -27,6 +27,38 @@
27 27
28#include <lib/lib8tion/lib8tion.h> 28#include <lib/lib8tion/lib8tion.h>
29 29
30#ifndef LED_MATRIX_CENTER
31const point_t k_led_matrix_center = {112, 32};
32#else
33const point_t k_led_matrix_center = LED_MATRIX_CENTER;
34#endif
35
36// Generic effect runners
37#include "led_matrix_runners/effect_runner_dx_dy_dist.h"
38#include "led_matrix_runners/effect_runner_dx_dy.h"
39#include "led_matrix_runners/effect_runner_i.h"
40#include "led_matrix_runners/effect_runner_sin_cos_i.h"
41#include "led_matrix_runners/effect_runner_reactive.h"
42#include "led_matrix_runners/effect_runner_reactive_splash.h"
43
44// ------------------------------------------
45// -----Begin led effect includes macros-----
46#define LED_MATRIX_EFFECT(name)
47#define LED_MATRIX_CUSTOM_EFFECT_IMPLS
48
49#include "led_matrix_animations/led_matrix_effects.inc"
50#ifdef LED_MATRIX_CUSTOM_KB
51# include "led_matrix_kb.inc"
52#endif
53#ifdef LED_MATRIX_CUSTOM_USER
54# include "led_matrix_user.inc"
55#endif
56
57#undef LED_MATRIX_CUSTOM_EFFECT_IMPLS
58#undef LED_MATRIX_EFFECT
59// -----End led effect includes macros-------
60// ------------------------------------------
61
30#if defined(LED_DISABLE_AFTER_TIMEOUT) && !defined(LED_DISABLE_TIMEOUT) 62#if defined(LED_DISABLE_AFTER_TIMEOUT) && !defined(LED_DISABLE_TIMEOUT)
31# define LED_DISABLE_TIMEOUT (LED_DISABLE_AFTER_TIMEOUT * 1200UL) 63# define LED_DISABLE_TIMEOUT (LED_DISABLE_AFTER_TIMEOUT * 1200UL)
32#endif 64#endif
@@ -53,7 +85,7 @@
53#endif 85#endif
54 86
55#if !defined(LED_MATRIX_STARTUP_MODE) 87#if !defined(LED_MATRIX_STARTUP_MODE)
56# define LED_MATRIX_STARTUP_MODE LED_MATRIX_UNIFORM_BRIGHTNESS 88# define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID
57#endif 89#endif
58 90
59#if !defined(LED_MATRIX_STARTUP_VAL) 91#if !defined(LED_MATRIX_STARTUP_VAL)
@@ -216,17 +248,6 @@ static bool led_matrix_none(effect_params_t *params) {
216 return false; 248 return false;
217} 249}
218 250
219static bool led_matrix_uniform_brightness(effect_params_t *params) {
220 LED_MATRIX_USE_LIMITS(led_min, led_max);
221
222 uint8_t val = led_matrix_eeconfig.val;
223 for (uint8_t i = led_min; i < led_max; i++) {
224 LED_MATRIX_TEST_LED_FLAGS();
225 led_matrix_set_value(i, val);
226 }
227 return led_max < DRIVER_LED_TOTAL;
228}
229
230static void led_task_timers(void) { 251static void led_task_timers(void) {
231#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 252#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0
232 uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); 253 uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer);
@@ -290,9 +311,31 @@ static void led_task_render(uint8_t effect) {
290 case LED_MATRIX_NONE: 311 case LED_MATRIX_NONE:
291 rendering = led_matrix_none(&led_effect_params); 312 rendering = led_matrix_none(&led_effect_params);
292 break; 313 break;
293 case LED_MATRIX_UNIFORM_BRIGHTNESS: 314
294 rendering = led_matrix_uniform_brightness(&led_effect_params); 315// ---------------------------------------------
316// -----Begin led effect switch case macros-----
317#define LED_MATRIX_EFFECT(name, ...) \
318 case LED_MATRIX_##name: \
319 rendering = name(&led_effect_params); \
320 break;
321#include "led_matrix_animations/led_matrix_effects.inc"
322#undef LED_MATRIX_EFFECT
323
324#if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER)
325# define LED_MATRIX_EFFECT(name, ...) \
326 case LED_MATRIX_CUSTOM_##name: \
327 rendering = name(&led_effect_params); \
295 break; 328 break;
329# ifdef LED_MATRIX_CUSTOM_KB
330# include "led_matrix_kb.inc"
331# endif
332# ifdef LED_MATRIX_CUSTOM_USER
333# include "led_matrix_user.inc"
334# endif
335# undef LED_MATRIX_EFFECT
336#endif
337 // -----End led effect switch case macros-------
338 // ---------------------------------------------
296 } 339 }
297 340
298 led_effect_params.iter++; 341 led_effect_params.iter++;
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h
index a3fa552b0..0984de73b 100644
--- a/quantum/led_matrix.h
+++ b/quantum/led_matrix.h
@@ -53,8 +53,24 @@
53enum led_matrix_effects { 53enum led_matrix_effects {
54 LED_MATRIX_NONE = 0, 54 LED_MATRIX_NONE = 0,
55 55
56 LED_MATRIX_UNIFORM_BRIGHTNESS, 56// --------------------------------------
57 // All new effects go above this line 57// -----Begin led effect enum macros-----
58#define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_##name,
59#include "led_matrix_animations/led_matrix_effects.inc"
60#undef LED_MATRIX_EFFECT
61
62#if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER)
63# define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_CUSTOM_##name,
64# ifdef LED_MATRIX_CUSTOM_KB
65# include "led_matrix_kb.inc"
66# endif
67# ifdef LED_MATRIX_CUSTOM_USER
68# include "led_matrix_user.inc"
69# endif
70# undef LED_MATRIX_EFFECT
71#endif
72 // --------------------------------------
73 // -----End led effect enum macros-------
58 74
59 LED_MATRIX_EFFECT_MAX 75 LED_MATRIX_EFFECT_MAX
60}; 76};
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 000000000..a4638fde6
--- /dev/null
+++ b/quantum/led_matrix_animations/alpha_mods_anim.h
@@ -0,0 +1,24 @@
1#ifndef DISABLE_LED_MATRIX_ALPHAS_MODS
2LED_MATRIX_EFFECT(ALPHAS_MODS)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5// alphas = val1, mods = val2
6bool ALPHAS_MODS(effect_params_t* params) {
7 LED_MATRIX_USE_LIMITS(led_min, led_max);
8
9 uint8_t val1 = led_matrix_eeconfig.val;
10 uint8_t val2 = val1 + led_matrix_eeconfig.speed;
11
12 for (uint8_t i = led_min; i < led_max; i++) {
13 LED_MATRIX_TEST_LED_FLAGS();
14 if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
15 led_matrix_set_value(i, val2);
16 } else {
17 led_matrix_set_value(i, val1);
18 }
19 }
20 return led_max < DRIVER_LED_TOTAL;
21}
22
23# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
24#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 000000000..4a2b746a7
--- /dev/null
+++ b/quantum/led_matrix_animations/band_anim.h
@@ -0,0 +1,15 @@
1#ifndef DISABLE_LED_MATRIX_BAND
2LED_MATRIX_EFFECT(BAND)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t BAND_math(uint8_t val, uint8_t i, uint8_t time) {
6 int16_t v = val - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
7 return scale8(v < 0 ? 0 : v, val);
8}
9
10bool BAND(effect_params_t* params) {
11 return effect_runner_i(params, &BAND_math);
12}
13
14# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
15#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 000000000..9836320d2
--- /dev/null
+++ b/quantum/led_matrix_animations/band_pinwheel_anim.h
@@ -0,0 +1,14 @@
1#ifndef DISABLE_LED_MATRIX_BAND_PINWHEEL
2LED_MATRIX_EFFECT(BAND_PINWHEEL)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t BAND_PINWHEEL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t time) {
6 return scale8(val - time - atan2_8(dy, dx) * 3, val);
7}
8
9bool BAND_PINWHEEL(effect_params_t* params) {
10 return effect_runner_dx_dy(params, &BAND_PINWHEEL_math);
11}
12
13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
14#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 000000000..be17c03aa
--- /dev/null
+++ b/quantum/led_matrix_animations/band_spiral_anim.h
@@ -0,0 +1,14 @@
1#ifndef DISABLE_LED_MATRIX_BAND_SPIRAL
2LED_MATRIX_EFFECT(BAND_SPIRAL)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t BAND_SPIRAL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
6 return scale8(val + dist - time - atan2_8(dy, dx), val);
7}
8
9bool BAND_SPIRAL(effect_params_t* params) {
10 return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_math);
11}
12
13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
14#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 000000000..4f49f5069
--- /dev/null
+++ b/quantum/led_matrix_animations/breathing_anim.h
@@ -0,0 +1,19 @@
1#ifndef DISABLE_LED_MATRIX_BREATHING
2LED_MATRIX_EFFECT(BREATHING)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5bool BREATHING(effect_params_t* params) {
6 LED_MATRIX_USE_LIMITS(led_min, led_max);
7
8 uint8_t val = led_matrix_eeconfig.val;
9 uint16_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 8);
10 val = scale8(abs8(sin8(time) - 128) * 2, val);
11 for (uint8_t i = led_min; i < led_max; i++) {
12 LED_MATRIX_TEST_LED_FLAGS();
13 led_matrix_set_value(i, val);
14 }
15 return led_max < DRIVER_LED_TOTAL;
16}
17
18# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
19#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 000000000..404fda26f
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_left_right_anim.h
@@ -0,0 +1,14 @@
1#ifndef DISABLE_LED_MATRIX_CYCLE_LEFT_RIGHT
2LED_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t CYCLE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) {
6 return scale8(g_led_config.point[i].x - time, val);
7}
8
9bool CYCLE_LEFT_RIGHT(effect_params_t* params) {
10 return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math);
11}
12
13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
14#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 000000000..3f5fc5b18
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_out_in_anim.h
@@ -0,0 +1,14 @@
1#ifndef DISABLE_LED_MATRIX_CYCLE_OUT_IN
2LED_MATRIX_EFFECT(CYCLE_OUT_IN)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t CYCLE_OUT_IN_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
6 return scale8(3 * dist / 2 + time, val);
7}
8
9bool CYCLE_OUT_IN(effect_params_t* params) {
10 return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math);
11}
12
13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
14#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 000000000..25fc211b1
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_up_down_anim.h
@@ -0,0 +1,14 @@
1#ifndef DISABLE_LED_MATRIX_CYCLE_UP_DOWN
2LED_MATRIX_EFFECT(CYCLE_UP_DOWN)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t CYCLE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) {
6 return scale8(g_led_config.point[i].y - time, val);
7}
8
9bool CYCLE_UP_DOWN(effect_params_t* params) {
10 return effect_runner_i(params, &CYCLE_UP_DOWN_math);
11}
12
13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
14#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 000000000..1fa1df139
--- /dev/null
+++ b/quantum/led_matrix_animations/dual_beacon_anim.h
@@ -0,0 +1,14 @@
1#ifndef DISABLE_LED_MATRIX_DUAL_BEACON
2LED_MATRIX_EFFECT(DUAL_BEACON)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t DUAL_BEACON_math(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
6 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);
7}
8
9bool DUAL_BEACON(effect_params_t* params) {
10 return effect_runner_sin_cos_i(params, &DUAL_BEACON_math);
11}
12
13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
14#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 000000000..67237c568
--- /dev/null
+++ b/quantum/led_matrix_animations/led_matrix_effects.inc
@@ -0,0 +1,18 @@
1// Add your new core led matrix effect here, order determins enum order, requires "led_matrix_animations/ directory
2#include "led_matrix_animations/solid_anim.h"
3#include "led_matrix_animations/alpha_mods_anim.h"
4#include "led_matrix_animations/breathing_anim.h"
5#include "led_matrix_animations/band_anim.h"
6#include "led_matrix_animations/band_pinwheel_anim.h"
7#include "led_matrix_animations/band_spiral_anim.h"
8#include "led_matrix_animations/cycle_left_right_anim.h"
9#include "led_matrix_animations/cycle_up_down_anim.h"
10#include "led_matrix_animations/cycle_out_in_anim.h"
11#include "led_matrix_animations/dual_beacon_anim.h"
12#include "led_matrix_animations/solid_reactive_simple_anim.h"
13#include "led_matrix_animations/solid_reactive_wide.h"
14#include "led_matrix_animations/solid_reactive_cross.h"
15#include "led_matrix_animations/solid_reactive_nexus.h"
16#include "led_matrix_animations/solid_splash_anim.h"
17#include "led_matrix_animations/wave_left_right_anim.h"
18#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 000000000..4c9e43c58
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_anim.h
@@ -0,0 +1,15 @@
1LED_MATRIX_EFFECT(SOLID)
2#ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
3
4bool SOLID(effect_params_t* params) {
5 LED_MATRIX_USE_LIMITS(led_min, led_max);
6
7 uint8_t val = led_matrix_eeconfig.val;
8 for (uint8_t i = led_min; i < led_max; i++) {
9 LED_MATRIX_TEST_LED_FLAGS();
10 led_matrix_set_value(i, val);
11 }
12 return led_max < DRIVER_LED_TOTAL;
13}
14
15#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 000000000..a50d1fc62
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_cross.h
@@ -0,0 +1,39 @@
1#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
2# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS)
3
4# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
5LED_MATRIX_EFFECT(SOLID_REACTIVE_CROSS)
6# endif
7
8# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
9LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS)
10# endif
11
12# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
13
14static uint8_t SOLID_REACTIVE_CROSS_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 uint16_t effect = tick + dist;
16 dx = dx < 0 ? dx * -1 : dx;
17 dy = dy < 0 ? dy * -1 : dy;
18 dx = dx * 16 > 255 ? 255 : dx * 16;
19 dy = dy * 16 > 255 ? 255 : dy * 16;
20 effect += dx > dy ? dy : dx;
21 if (effect > 255) effect = 255;
22 return qadd8(val, 255 - effect);
23}
24
25# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
26bool SOLID_REACTIVE_CROSS(effect_params_t* params) {
27 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math);
28}
29# endif
30
31# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
32bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) {
33 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math);
34}
35# endif
36
37# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
38# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS)
39#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 000000000..4638aac5a
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_nexus.h
@@ -0,0 +1,36 @@
1#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
2# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS)
3
4# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
5LED_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS)
6# endif
7
8# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
9LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS)
10# endif
11
12# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
13
14static uint8_t SOLID_REACTIVE_NEXUS_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 uint16_t effect = tick - dist;
16 if (effect > 255) effect = 255;
17 if (dist > 72) effect = 255;
18 if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255;
19 return qadd8(val, 255 - effect);
20}
21
22# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
23bool SOLID_REACTIVE_NEXUS(effect_params_t* params) {
24 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math);
25}
26# endif
27
28# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
29bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) {
30 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math);
31}
32# endif
33
34# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
35# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS)
36#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 000000000..e1166a4fb
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_simple_anim.h
@@ -0,0 +1,16 @@
1#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
2# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
3LED_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
4# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
5
6static uint8_t SOLID_REACTIVE_SIMPLE_math(uint8_t val, uint16_t offset) {
7 return scale8(255 - offset, val);
8}
9
10bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) {
11 return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math);
12}
13
14# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
15# endif // DISABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
16#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 000000000..4bcaba331
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_wide.h
@@ -0,0 +1,34 @@
1#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
2# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE)
3
4# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
5LED_MATRIX_EFFECT(SOLID_REACTIVE_WIDE)
6# endif
7
8# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
9LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE)
10# endif
11
12# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
13
14static uint8_t SOLID_REACTIVE_WIDE_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 uint16_t effect = tick + dist * 5;
16 if (effect > 255) effect = 255;
17 return qadd8(val, 255 - effect);
18}
19
20# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
21bool SOLID_REACTIVE_WIDE(effect_params_t* params) {
22 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math);
23}
24# endif
25
26# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
27bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) {
28 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math);
29}
30# endif
31
32# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
33# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE)
34#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 000000000..3e9046640
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_splash_anim.h
@@ -0,0 +1,34 @@
1#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
2# if !defined(DISABLE_LED_MATRIX_SOLID_SPLASH) || !defined(DISABLE_LED_MATRIX_SOLID_MULTISPLASH)
3
4# ifndef DISABLE_LED_MATRIX_SOLID_SPLASH
5LED_MATRIX_EFFECT(SOLID_SPLASH)
6# endif
7
8# ifndef DISABLE_LED_MATRIX_SOLID_MULTISPLASH
9LED_MATRIX_EFFECT(SOLID_MULTISPLASH)
10# endif
11
12# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
13
14uint8_t SOLID_SPLASH_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 uint16_t effect = tick - dist;
16 if (effect > 255) effect = 255;
17 return qadd8(val, 255 - effect);
18}
19
20# ifndef DISABLE_LED_MATRIX_SOLID_SPLASH
21bool SOLID_SPLASH(effect_params_t* params) {
22 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math);
23}
24# endif
25
26# ifndef DISABLE_LED_MATRIX_SOLID_MULTISPLASH
27bool SOLID_MULTISPLASH(effect_params_t* params) {
28 return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math);
29}
30# endif
31
32# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
33# endif // !defined(DISABLE_LED_MATRIX_SPLASH) && !defined(DISABLE_LED_MATRIX_MULTISPLASH)
34#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 000000000..d547c72ce
--- /dev/null
+++ b/quantum/led_matrix_animations/wave_left_right_anim.h
@@ -0,0 +1,14 @@
1#ifndef DISABLE_LED_MATRIX_WAVE_LEFT_RIGHT
2LED_MATRIX_EFFECT(WAVE_LEFT_RIGHT)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t WAVE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) {
6 return scale8(sin8(g_led_config.point[i].x - time), val);
7}
8
9bool WAVE_LEFT_RIGHT(effect_params_t* params) {
10 return effect_runner_i(params, &WAVE_LEFT_RIGHT_math);
11}
12
13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
14#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 000000000..b68ff9bbc
--- /dev/null
+++ b/quantum/led_matrix_animations/wave_up_down_anim.h
@@ -0,0 +1,14 @@
1#ifndef DISABLE_LED_MATRIX_WAVE_UP_DOWN
2LED_MATRIX_EFFECT(WAVE_UP_DOWN)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4
5static uint8_t WAVE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) {
6 return scale8(sin8(g_led_config.point[i].y - time), val);
7}
8
9bool WAVE_UP_DOWN(effect_params_t* params) {
10 return effect_runner_i(params, &WAVE_UP_DOWN_math);
11}
12
13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
14#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 000000000..ef97631b9
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_dx_dy.h
@@ -0,0 +1,16 @@
1#pragma once
2
3typedef uint8_t (*dx_dy_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t time);
4
5bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) {
6 LED_MATRIX_USE_LIMITS(led_min, led_max);
7
8 uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 2);
9 for (uint8_t i = led_min; i < led_max; i++) {
10 LED_MATRIX_TEST_LED_FLAGS();
11 int16_t dx = g_led_config.point[i].x - k_led_matrix_center.x;
12 int16_t dy = g_led_config.point[i].y - k_led_matrix_center.y;
13 led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, dx, dy, time));
14 }
15 return led_max < DRIVER_LED_TOTAL;
16}
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 000000000..5ef5938be
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_dx_dy_dist.h
@@ -0,0 +1,17 @@
1#pragma once
2
3typedef uint8_t (*dx_dy_dist_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time);
4
5bool effect_runner_dx_dy_dist(effect_params_t* params, dx_dy_dist_f effect_func) {
6 LED_MATRIX_USE_LIMITS(led_min, led_max);
7
8 uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 2);
9 for (uint8_t i = led_min; i < led_max; i++) {
10 LED_MATRIX_TEST_LED_FLAGS();
11 int16_t dx = g_led_config.point[i].x - k_led_matrix_center.x;
12 int16_t dy = g_led_config.point[i].y - k_led_matrix_center.y;
13 uint8_t dist = sqrt16(dx * dx + dy * dy);
14 led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, dx, dy, dist, time));
15 }
16 return led_max < DRIVER_LED_TOTAL;
17}
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 000000000..b3015759b
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_i.h
@@ -0,0 +1,14 @@
1#pragma once
2
3typedef uint8_t (*i_f)(uint8_t val, uint8_t i, uint8_t time);
4
5bool effect_runner_i(effect_params_t* params, i_f effect_func) {
6 LED_MATRIX_USE_LIMITS(led_min, led_max);
7
8 uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 4);
9 for (uint8_t i = led_min; i < led_max; i++) {
10 LED_MATRIX_TEST_LED_FLAGS();
11 led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, i, time));
12 }
13 return led_max < DRIVER_LED_TOTAL;
14}
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 000000000..4369ea8c4
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_reactive.h
@@ -0,0 +1,28 @@
1#pragma once
2
3#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
4
5typedef uint8_t (*reactive_f)(uint8_t val, uint16_t offset);
6
7bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
8 LED_MATRIX_USE_LIMITS(led_min, led_max);
9
10 uint16_t max_tick = 65535 / led_matrix_eeconfig.speed;
11 for (uint8_t i = led_min; i < led_max; i++) {
12 LED_MATRIX_TEST_LED_FLAGS();
13 uint16_t tick = max_tick;
14 // Reverse search to find most recent key hit
15 for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
16 if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
17 tick = g_last_hit_tracker.tick[j];
18 break;
19 }
20 }
21
22 uint16_t offset = scale16by8(tick, led_matrix_eeconfig.speed);
23 led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, offset));
24 }
25 return led_max < DRIVER_LED_TOTAL;
26}
27
28#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 000000000..d6eb9731e
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_reactive_splash.h
@@ -0,0 +1,26 @@
1#pragma once
2
3#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
4
5typedef uint8_t (*reactive_splash_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick);
6
7bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, reactive_splash_f effect_func) {
8 LED_MATRIX_USE_LIMITS(led_min, led_max);
9
10 uint8_t count = g_last_hit_tracker.count;
11 for (uint8_t i = led_min; i < led_max; i++) {
12 LED_MATRIX_TEST_LED_FLAGS();
13 uint8_t val = 0;
14 for (uint8_t j = start; j < count; j++) {
15 int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
16 int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
17 uint8_t dist = sqrt16(dx * dx + dy * dy);
18 uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], led_matrix_eeconfig.speed);
19 val = effect_func(val, dx, dy, dist, tick);
20 }
21 led_matrix_set_value(i, scale8(val, led_matrix_eeconfig.val));
22 }
23 return led_max < DRIVER_LED_TOTAL;
24}
25
26#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 000000000..4a5219abd
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_sin_cos_i.h
@@ -0,0 +1,16 @@
1#pragma once
2
3typedef uint8_t (*sin_cos_i_f)(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time);
4
5bool effect_runner_sin_cos_i(effect_params_t* params, sin_cos_i_f effect_func) {
6 LED_MATRIX_USE_LIMITS(led_min, led_max);
7
8 uint16_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 4);
9 int8_t cos_value = cos8(time) - 128;
10 int8_t sin_value = sin8(time) - 128;
11 for (uint8_t i = led_min; i < led_max; i++) {
12 LED_MATRIX_TEST_LED_FLAGS();
13 led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, cos_value, sin_value, i, time));
14 }
15 return led_max < DRIVER_LED_TOTAL;
16}