aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quantum/rgb_matrix.c8
-rw-r--r--quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/colorband_sat_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h19
-rw-r--r--quantum/rgb_matrix_animations/colorband_spiral_val_anim.h19
-rw-r--r--quantum/rgb_matrix_animations/colorband_val_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/cycle_all_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/cycle_left_right_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/cycle_out_in_anim.h19
-rw-r--r--quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h21
-rw-r--r--quantum/rgb_matrix_animations/cycle_pinwheel_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/cycle_spiral_anim.h19
-rw-r--r--quantum/rgb_matrix_animations/cycle_up_down_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/dual_beacon_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/rainbow_beacon_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_anim.h28
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_cross.h50
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_nexus.h44
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_simple_anim.h27
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_wide.h37
-rw-r--r--quantum/rgb_matrix_animations/solid_splash_anim.h37
-rw-r--r--quantum/rgb_matrix_animations/splash_anim.h39
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_dx_dy.h19
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h20
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_i.h17
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_reactive.h31
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_reactive_splash.h30
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h19
31 files changed, 312 insertions, 399 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index a6a9549af..98baf5cb5 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -32,6 +32,14 @@
32 const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; 32 const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
33#endif 33#endif
34 34
35// Generic effect runners
36#include "rgb_matrix_runners/effect_runner_dx_dy_dist.h"
37#include "rgb_matrix_runners/effect_runner_dx_dy.h"
38#include "rgb_matrix_runners/effect_runner_i.h"
39#include "rgb_matrix_runners/effect_runner_sin_cos_i.h"
40#include "rgb_matrix_runners/effect_runner_reactive.h"
41#include "rgb_matrix_runners/effect_runner_reactive_splash.h"
42
35// ------------------------------------------ 43// ------------------------------------------
36// -----Begin rgb effect includes macros----- 44// -----Begin rgb effect includes macros-----
37#define RGB_MATRIX_EFFECT(name) 45#define RGB_MATRIX_EFFECT(name)
diff --git a/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h b/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h
index 3e6df1fbe..cf9c0784a 100644
--- a/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h
@@ -2,20 +2,12 @@
2RGB_MATRIX_EFFECT(BAND_PINWHEEL_SAT) 2RGB_MATRIX_EFFECT(BAND_PINWHEEL_SAT)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool BAND_PINWHEEL_SAT(effect_params_t* params) { 5static void BAND_PINWHEEL_SAT_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->s = rgb_matrix_config.sat - time - atan2_8(dy, dx) * 3;
7}
7 8
8 HSV hsv = { rgb_matrix_config.hue, 0, rgb_matrix_config.val }; 9bool BAND_PINWHEEL_SAT(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2); 10 return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - 112;
13 int16_t dy = g_led_config.point[i].y - 32;
14 hsv.s = rgb_matrix_config.sat - time - atan2_8(dy, dx) * 3;
15 RGB rgb = hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 }
18 return led_max < DRIVER_LED_TOTAL;
19} 11}
20 12
21#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h b/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h
index 88cc7d1f2..05ad0ee32 100644
--- a/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h
@@ -2,20 +2,12 @@
2RGB_MATRIX_EFFECT(BAND_PINWHEEL_VAL) 2RGB_MATRIX_EFFECT(BAND_PINWHEEL_VAL)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool BAND_PINWHEEL_VAL(effect_params_t* params) { 5static void BAND_PINWHEEL_VAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->v = rgb_matrix_config.val - time - atan2_8(dy, dx) * 3;
7}
7 8
8 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; 9bool BAND_PINWHEEL_VAL(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2); 10 return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - 112;
13 int16_t dy = g_led_config.point[i].y - 32;
14 hsv.v = rgb_matrix_config.val - time - atan2_8(dy, dx) * 3;
15 RGB rgb = hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 }
18 return led_max < DRIVER_LED_TOTAL;
19} 11}
20 12
21#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/colorband_sat_anim.h b/quantum/rgb_matrix_animations/colorband_sat_anim.h
index 89773b6ce..8a40473e4 100644
--- a/quantum/rgb_matrix_animations/colorband_sat_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_sat_anim.h
@@ -2,19 +2,13 @@
2RGB_MATRIX_EFFECT(BAND_SAT) 2RGB_MATRIX_EFFECT(BAND_SAT)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool BAND_SAT(effect_params_t* params) { 5static void BAND_SAT_math(HSV* hsv, uint8_t i, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max);
7
8 HSV hsv = { rgb_matrix_config.hue, 0, rgb_matrix_config.val };
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t s = rgb_matrix_config.sat - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; 6 int16_t s = rgb_matrix_config.sat - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
13 hsv.s = s < 0 ? 0 : s; 7 hsv->s = s < 0 ? 0 : s;
14 RGB rgb = hsv_to_rgb(hsv); 8}
15 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 9
16 } 10bool BAND_SAT(effect_params_t* params) {
17 return led_max < DRIVER_LED_TOTAL; 11 return effect_runner_i(params, &BAND_SAT_math);
18} 12}
19 13
20#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h b/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h
index 44955900a..4af6c60b0 100644
--- a/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h
@@ -2,21 +2,12 @@
2RGB_MATRIX_EFFECT(BAND_SPIRAL_SAT) 2RGB_MATRIX_EFFECT(BAND_SPIRAL_SAT)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool BAND_SPIRAL_SAT(effect_params_t* params) { 5static void BAND_SPIRAL_SAT_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->s = rgb_matrix_config.sat + dist - time - atan2_8(dy, dx);
7}
7 8
8 HSV hsv = { rgb_matrix_config.hue, 0, rgb_matrix_config.val }; 9bool BAND_SPIRAL_SAT(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2); 10 return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - 112;
13 int16_t dy = g_led_config.point[i].y - 32;
14 uint8_t dist = sqrt16(dx * dx + dy * dy);
15 hsv.s = rgb_matrix_config.sat + dist - time - atan2_8(dy, dx);
16 RGB rgb = hsv_to_rgb(hsv);
17 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
18 }
19 return led_max < DRIVER_LED_TOTAL;
20} 11}
21 12
22#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h b/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h
index 5aea0c8da..e787956a7 100644
--- a/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h
@@ -2,21 +2,12 @@
2RGB_MATRIX_EFFECT(BAND_SPIRAL_VAL) 2RGB_MATRIX_EFFECT(BAND_SPIRAL_VAL)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool BAND_SPIRAL_VAL(effect_params_t* params) { 5static void BAND_SPIRAL_VAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->v = rgb_matrix_config.val + dist - time - atan2_8(dy, dx);
7}
7 8
8 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; 9bool BAND_SPIRAL_VAL(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2); 10 return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - 112;
13 int16_t dy = g_led_config.point[i].y - 32;
14 uint8_t dist = sqrt16(dx * dx + dy * dy);
15 hsv.v = rgb_matrix_config.val + dist - time - atan2_8(dy, dx);
16 RGB rgb = hsv_to_rgb(hsv);
17 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
18 }
19 return led_max < DRIVER_LED_TOTAL;
20} 11}
21 12
22#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/colorband_val_anim.h b/quantum/rgb_matrix_animations/colorband_val_anim.h
index bf41cec91..1e3740cea 100644
--- a/quantum/rgb_matrix_animations/colorband_val_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_val_anim.h
@@ -2,19 +2,13 @@
2RGB_MATRIX_EFFECT(BAND_VAL) 2RGB_MATRIX_EFFECT(BAND_VAL)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool BAND_VAL(effect_params_t* params) { 5static void BAND_VAL_math(HSV* hsv, uint8_t i, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max);
7
8 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t v = rgb_matrix_config.val - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; 6 int16_t v = rgb_matrix_config.val - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
13 hsv.v = v < 0 ? 0 : v; 7 hsv->v = v < 0 ? 0 : v;
14 RGB rgb = hsv_to_rgb(hsv); 8}
15 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 9
16 } 10bool BAND_VAL(effect_params_t* params) {
17 return led_max < DRIVER_LED_TOTAL; 11 return effect_runner_i(params, &BAND_VAL_math);
18} 12}
19 13
20#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h
index e6319cad7..380dbe05a 100644
--- a/quantum/rgb_matrix_animations/cycle_all_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_all_anim.h
@@ -2,17 +2,13 @@
2RGB_MATRIX_EFFECT(CYCLE_ALL) 2RGB_MATRIX_EFFECT(CYCLE_ALL)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool CYCLE_ALL(effect_params_t* params) { 5static void CYCLE_ALL_math(HSV* hsv, uint8_t i, uint8_t time)
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6{
7 hsv->h = time;
8}
7 9
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 10bool CYCLE_ALL(effect_params_t* params) {
9 hsv.h = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 11 return effect_runner_i(params, &CYCLE_ALL_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 RGB rgb = hsv_to_rgb(hsv);
13 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
14 }
15 return led_max < DRIVER_LED_TOTAL;
16} 12}
17 13
18#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/cycle_left_right_anim.h b/quantum/rgb_matrix_animations/cycle_left_right_anim.h
index d9a00530a..f270fb42c 100644
--- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h
@@ -2,18 +2,12 @@
2RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT) 2RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool CYCLE_LEFT_RIGHT(effect_params_t* params) { 5static void CYCLE_LEFT_RIGHT_math(HSV* hsv, uint8_t i, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = g_led_config.point[i].x - time;
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool CYCLE_LEFT_RIGHT(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 10 return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 hsv.h = g_led_config.point[i].x - time;
13 RGB rgb = hsv_to_rgb(hsv);
14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
15 }
16 return led_max < DRIVER_LED_TOTAL;
17} 11}
18 12
19#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/cycle_out_in_anim.h b/quantum/rgb_matrix_animations/cycle_out_in_anim.h
index 29209e4d7..46c7efef2 100644
--- a/quantum/rgb_matrix_animations/cycle_out_in_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_out_in_anim.h
@@ -2,21 +2,12 @@
2RGB_MATRIX_EFFECT(CYCLE_OUT_IN) 2RGB_MATRIX_EFFECT(CYCLE_OUT_IN)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool CYCLE_OUT_IN(effect_params_t* params) { 5static void CYCLE_OUT_IN_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = 3 * dist / 2 + time;
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool CYCLE_OUT_IN(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 10 return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x;
13 int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y;
14 uint8_t dist = sqrt16(dx * dx + dy * dy);
15 hsv.h = 3 * dist / 2 + time;
16 RGB rgb = hsv_to_rgb(hsv);
17 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
18 }
19 return led_max < DRIVER_LED_TOTAL;
20} 11}
21 12
22#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h b/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h
index b2f79ceea..2fdb4ba91 100644
--- a/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h
@@ -2,21 +2,14 @@
2RGB_MATRIX_EFFECT(CYCLE_OUT_IN_DUAL) 2RGB_MATRIX_EFFECT(CYCLE_OUT_IN_DUAL)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { 5static void CYCLE_OUT_IN_DUAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 dx = (k_rgb_matrix_center.x / 2) - abs8(dx);
7
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = (k_rgb_matrix_center.x / 2) - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x);
13 int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y;
14 uint8_t dist = sqrt16(dx * dx + dy * dy); 7 uint8_t dist = sqrt16(dx * dx + dy * dy);
15 hsv.h = 3 * dist + time; 8 hsv->h = 3 * dist + time;
16 RGB rgb = hsv_to_rgb(hsv); 9}
17 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 10
18 } 11bool CYCLE_OUT_IN_DUAL(effect_params_t* params) {
19 return led_max < DRIVER_LED_TOTAL; 12 return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math);
20} 13}
21 14
22#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 15#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h b/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h
index 59d60ac07..29e2d92c9 100644
--- a/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h
@@ -2,20 +2,12 @@
2RGB_MATRIX_EFFECT(CYCLE_PINWHEEL) 2RGB_MATRIX_EFFECT(CYCLE_PINWHEEL)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool CYCLE_PINWHEEL(effect_params_t* params) { 5static void CYCLE_PINWHEEL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = atan2_8(dy, dx) + time;
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool CYCLE_PINWHEEL(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 10 return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - 112;
13 int16_t dy = g_led_config.point[i].y - 32;
14 hsv.h = atan2_8(dy, dx) + time;
15 RGB rgb = hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 }
18 return led_max < DRIVER_LED_TOTAL;
19} 11}
20 12
21#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/cycle_spiral_anim.h b/quantum/rgb_matrix_animations/cycle_spiral_anim.h
index 865309c25..a1354f60c 100644
--- a/quantum/rgb_matrix_animations/cycle_spiral_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_spiral_anim.h
@@ -2,21 +2,12 @@
2RGB_MATRIX_EFFECT(CYCLE_SPIRAL) 2RGB_MATRIX_EFFECT(CYCLE_SPIRAL)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool CYCLE_SPIRAL(effect_params_t* params) { 5static void CYCLE_SPIRAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = dist - time - atan2_8(dy, dx);
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool CYCLE_SPIRAL(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2); 10 return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - 112;
13 int16_t dy = g_led_config.point[i].y - 32;
14 uint8_t dist = sqrt16(dx * dx + dy * dy);
15 hsv.h = dist - time - atan2_8(dy, dx);
16 RGB rgb = hsv_to_rgb(hsv);
17 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
18 }
19 return led_max < DRIVER_LED_TOTAL;
20} 11}
21 12
22#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h
index f2b31d9da..b3ef4cdf2 100644
--- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h
@@ -2,18 +2,12 @@
2RGB_MATRIX_EFFECT(CYCLE_UP_DOWN) 2RGB_MATRIX_EFFECT(CYCLE_UP_DOWN)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool CYCLE_UP_DOWN(effect_params_t* params) { 5static void CYCLE_UP_DOWN_math(HSV* hsv, uint8_t i, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = g_led_config.point[i].y - time;
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool CYCLE_UP_DOWN(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 10 return effect_runner_i(params, &CYCLE_UP_DOWN_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 hsv.h = g_led_config.point[i].y - time;
13 RGB rgb = hsv_to_rgb(hsv);
14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
15 }
16 return led_max < DRIVER_LED_TOTAL;
17} 11}
18 12
19#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/dual_beacon_anim.h b/quantum/rgb_matrix_animations/dual_beacon_anim.h
index 59c91046d..d34f146a5 100644
--- a/quantum/rgb_matrix_animations/dual_beacon_anim.h
+++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h
@@ -2,20 +2,12 @@
2RGB_MATRIX_EFFECT(DUAL_BEACON) 2RGB_MATRIX_EFFECT(DUAL_BEACON)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool DUAL_BEACON(effect_params_t* params) { 5static void DUAL_BEACON_math(HSV* hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * sin) / 128 + rgb_matrix_config.hue;
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool DUAL_BEACON(effect_params_t* params) {
9 uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 10 return effect_runner_sin_cos_i(params, &DUAL_BEACON_math);
10 int8_t cos_value = cos8(time) - 128;
11 int8_t sin_value = sin8(time) - 128;
12 for (uint8_t i = led_min; i < led_max; i++) {
13 RGB_MATRIX_TEST_LED_FLAGS();
14 hsv.h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos_value + (g_led_config.point[i].x - k_rgb_matrix_center.x) * sin_value) / 128 + rgb_matrix_config.hue;
15 RGB rgb = hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 }
18 return led_max < DRIVER_LED_TOTAL;
19} 11}
20 12
21#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
index 564e3c480..061cac837 100644
--- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
@@ -2,20 +2,12 @@
2RGB_MATRIX_EFFECT(RAINBOW_BEACON) 2RGB_MATRIX_EFFECT(RAINBOW_BEACON)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool RAINBOW_BEACON(effect_params_t* params) { 5static void RAINBOW_BEACON_math(HSV* hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128 + rgb_matrix_config.hue;
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool RAINBOW_BEACON(effect_params_t* params) {
9 uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 10 return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math);
10 int16_t cos_value = 2 * (cos8(time) - 128);
11 int16_t sin_value = 2 * (sin8(time) - 128);
12 for (uint8_t i = led_min; i < led_max; i++) {
13 RGB_MATRIX_TEST_LED_FLAGS();
14 hsv.h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos_value + (g_led_config.point[i].x - k_rgb_matrix_center.x) * sin_value) / 128 + rgb_matrix_config.hue;
15 RGB rgb = hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 }
18 return led_max < DRIVER_LED_TOTAL;
19} 11}
20 12
21#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
index 39352b0c1..f406566fa 100644
--- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
@@ -2,18 +2,12 @@
2RGB_MATRIX_EFFECT(RAINBOW_MOVING_CHEVRON) 2RGB_MATRIX_EFFECT(RAINBOW_MOVING_CHEVRON)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { 5static void RAINBOW_MOVING_CHEVRON_math(HSV* hsv, uint8_t i, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time) + rgb_matrix_config.hue;
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) {
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 10 return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 hsv.h = abs8(g_led_config.point[i].y - 32) + (g_led_config.point[i].x - time) + rgb_matrix_config.hue;
13 RGB rgb = hsv_to_rgb(hsv);
14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
15 }
16 return led_max < DRIVER_LED_TOTAL;
17} 11}
18 12
19#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
index 7d189b927..f19e9116d 100644
--- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
@@ -2,20 +2,12 @@
2RGB_MATRIX_EFFECT(PINWHEELS) 2RGB_MATRIX_EFFECT(PINWHEELS)
3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 3#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5bool PINWHEELS(effect_params_t* params) { 5static void PINWHEELS_math(HSV* hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max); 6 hsv->h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 3 * cos + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * 3 * sin) / 128 + rgb_matrix_config.hue;
7}
7 8
8 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; 9bool PINWHEELS(effect_params_t* params) {
9 uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); 10 return effect_runner_sin_cos_i(params, &PINWHEELS_math);
10 int16_t cos_value = 3 * (cos8(time) - 128);
11 int16_t sin_value = 3 * (sin8(time) - 128);
12 for (uint8_t i = led_min; i < led_max; i++) {
13 RGB_MATRIX_TEST_LED_FLAGS();
14 hsv.h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos_value + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * sin_value) / 128 + rgb_matrix_config.hue;
15 RGB rgb = hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 }
18 return led_max < DRIVER_LED_TOTAL;
19} 11}
20 12
21#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 13#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h
index 37e339907..762a95db3 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_anim.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h
@@ -3,30 +3,12 @@
3RGB_MATRIX_EFFECT(SOLID_REACTIVE) 3RGB_MATRIX_EFFECT(SOLID_REACTIVE)
4#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 4#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
5 5
6bool SOLID_REACTIVE(effect_params_t* params) { 6static void SOLID_REACTIVE_math(HSV* hsv, uint16_t offset) {
7 RGB_MATRIX_USE_LIMITS(led_min, led_max); 7 hsv->h = rgb_matrix_config.hue + qsub8(130, offset);
8 8}
9 HSV hsv = { rgb_matrix_config.hue, 255, rgb_matrix_config.val };
10 // Max tick based on speed scale ensures results from scale16by8 with rgb_matrix_config.speed are no greater than 255
11 uint16_t max_tick = 65535 / rgb_matrix_config.speed;
12 // Relies on hue being 8-bit and wrapping
13 for (uint8_t i = led_min; i < led_max; i++) {
14 RGB_MATRIX_TEST_LED_FLAGS();
15 uint16_t tick = max_tick;
16 // Reverse search to find most recent key hit
17 for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
18 if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
19 tick = g_last_hit_tracker.tick[j];
20 break;
21 }
22 }
23 9
24 uint16_t offset = scale16by8(tick, rgb_matrix_config.speed); 10bool SOLID_REACTIVE(effect_params_t* params) {
25 hsv.h = rgb_matrix_config.hue + qsub8(130, offset); 11 return effect_runner_reactive(params, &SOLID_REACTIVE_math);
26 RGB rgb = hsv_to_rgb(hsv);
27 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
28 }
29 return led_max < DRIVER_LED_TOTAL;
30} 12}
31 13
32#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h
index 62210f82d..99f22c694 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_cross.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h
@@ -11,45 +11,29 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS)
11 11
12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13 13
14static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_params_t* params) { 14static void SOLID_REACTIVE_CROSS_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 RGB_MATRIX_USE_LIMITS(led_min, led_max); 15 uint16_t effect = tick + dist;
16 16 dx = dx < 0 ? dx * -1 : dx;
17 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; 17 dy = dy < 0 ? dy * -1 : dy;
18 uint8_t count = g_last_hit_tracker.count; 18 dx = dx * 16 > 255 ? 255 : dx * 16;
19 for (uint8_t i = led_min; i < led_max; i++) { 19 dy = dy * 16 > 255 ? 255 : dy * 16;
20 hsv.v = 0; 20 effect += dx > dy ? dy : dx;
21 for (uint8_t j = start; j < count; j++) { 21 if (effect > 255)
22 RGB_MATRIX_TEST_LED_FLAGS();
23 int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
24 int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
25 uint8_t dist = sqrt16(dx * dx + dy * dy);
26 int16_t dist2 = 16;
27 uint8_t dist3;
28 uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist;
29 dx = dx < 0 ? dx * -1 : dx;
30 dy = dy < 0 ? dy * -1 : dy;
31 dx = dx * dist2 > 255 ? 255 : dx * dist2;
32 dy = dy * dist2 > 255 ? 255 : dy * dist2;
33 dist3 = dx > dy ? dy : dx;
34 effect += dist3;
35 if (effect > 255)
36 effect = 255; 22 effect = 255;
37 hsv.v = qadd8(hsv.v, 255 - effect); 23 hsv->v = qadd8(hsv->v, 255 - effect);
38 }
39 hsv.v = scale8(hsv.v, rgb_matrix_config.val);
40 RGB rgb = hsv_to_rgb(hsv);
41 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
42 }
43 return led_max < DRIVER_LED_TOTAL;
44} 24}
45 25
46bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { 26#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
47 return rgb_matrix_solid_reactive_multicross_range(0, params); 27bool SOLID_REACTIVE_CROSS(effect_params_t* params) {
28 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math);
48} 29}
30#endif
49 31
50bool SOLID_REACTIVE_CROSS(effect_params_t* params) { 32#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
51 return rgb_matrix_solid_reactive_multicross_range(qsub8(g_last_hit_tracker.count, 1), params); 33bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) {
34 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math);
52} 35}
36#endif
53 37
54#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 38#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
55#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) 39#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
diff --git a/quantum/rgb_matrix_animations/solid_reactive_nexus.h b/quantum/rgb_matrix_animations/solid_reactive_nexus.h
index 33f478ac7..8bebd042d 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_nexus.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h
@@ -11,43 +11,29 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS)
11 11
12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13 13
14static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_params_t* params) { 14static void SOLID_REACTIVE_NEXUS_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 RGB_MATRIX_USE_LIMITS(led_min, led_max); 15 uint16_t effect = tick - dist;
16 16 if (effect > 255)
17 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
18 uint8_t count = g_last_hit_tracker.count;
19 for (uint8_t i = led_min; i < led_max; i++) {
20 hsv.v = 0;
21 for (uint8_t j = start; j < count; j++) {
22 RGB_MATRIX_TEST_LED_FLAGS();
23 int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
24 int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
25 uint8_t dist = sqrt16(dx * dx + dy * dy);
26 int16_t dist2 = 8;
27 uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
28 if (effect > 255)
29 effect = 255; 17 effect = 255;
30 if (dist > 72) 18 if (dist > 72)
31 effect = 255; 19 effect = 255;
32 if ((dx > dist2 || dx < -dist2) && (dy > dist2 || dy < -dist2)) 20 if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8))
33 effect = 255; 21 effect = 255;
34 hsv.v = qadd8(hsv.v, 255 - effect); 22 hsv->v = qadd8(hsv->v, 255 - effect);
35 hsv.h = rgb_matrix_config.hue + dy / 4; 23 hsv->h = rgb_matrix_config.hue + dy / 4;
36 }
37 hsv.v = scale8(hsv.v, rgb_matrix_config.val);
38 RGB rgb = hsv_to_rgb(hsv);
39 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
40 }
41 return led_max < DRIVER_LED_TOTAL;
42} 24}
43 25
44bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { 26#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
45 return rgb_matrix_solid_reactive_multinexus_range(0, params); 27bool SOLID_REACTIVE_NEXUS(effect_params_t* params) {
28 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math);
46} 29}
30#endif
47 31
48bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { 32#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
49 return rgb_matrix_solid_reactive_multinexus_range(qsub8(g_last_hit_tracker.count, 1), params); 33bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) {
34 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math);
50} 35}
36#endif
51 37
52#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 38#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
53#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) 39#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
index f235824e2..36c6ec527 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
@@ -3,29 +3,12 @@
3RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) 3RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
4#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 4#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
5 5
6bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { 6static void SOLID_REACTIVE_SIMPLE_math(HSV* hsv, uint16_t offset) {
7 RGB_MATRIX_USE_LIMITS(led_min, led_max); 7 hsv->v = scale8(255 - offset, rgb_matrix_config.val);
8 8}
9 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
10 // Max tick based on speed scale ensures results from scale16by8 with rgb_matrix_config.speed are no greater than 255
11 uint16_t max_tick = 65535 / rgb_matrix_config.speed;
12 for (uint8_t i = led_min; i < led_max; i++) {
13 RGB_MATRIX_TEST_LED_FLAGS();
14 uint16_t tick = max_tick;
15 // Reverse search to find most recent key hit
16 for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
17 if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
18 tick = g_last_hit_tracker.tick[j];
19 break;
20 }
21 }
22 9
23 uint16_t offset = scale16by8(tick, rgb_matrix_config.speed); 10bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) {
24 hsv.v = scale8(255 - offset, rgb_matrix_config.val); 11 return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math);
25 RGB rgb = hsv_to_rgb(hsv);
26 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
27 }
28 return led_max < DRIVER_LED_TOTAL;
29} 12}
30 13
31#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix_animations/solid_reactive_wide.h b/quantum/rgb_matrix_animations/solid_reactive_wide.h
index ff0f6f5ec..36edc475c 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_wide.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h
@@ -11,37 +11,24 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE)
11 11
12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13 13
14static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_params_t* params) { 14static void SOLID_REACTIVE_WIDE_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 RGB_MATRIX_USE_LIMITS(led_min, led_max); 15 uint16_t effect = tick + dist * 5;
16 16 if (effect > 255)
17 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
18 uint8_t count = g_last_hit_tracker.count;
19 for (uint8_t i = led_min; i < led_max; i++) {
20 hsv.v = 0;
21 for (uint8_t j = start; j < count; j++) {
22 RGB_MATRIX_TEST_LED_FLAGS();
23 int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
24 int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
25 uint8_t dist = sqrt16(dx * dx + dy * dy);
26 uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist * 5;
27 if (effect > 255)
28 effect = 255; 17 effect = 255;
29 hsv.v = qadd8(hsv.v, 255 - effect); 18 hsv->v = qadd8(hsv->v, 255 - effect);
30 }
31 hsv.v = scale8(hsv.v, rgb_matrix_config.val);
32 RGB rgb = hsv_to_rgb(hsv);
33 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
34 }
35 return led_max < DRIVER_LED_TOTAL;
36} 19}
37 20
38bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { 21#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
39 return rgb_matrix_solid_reactive_multiwide_range(0, params); 22bool SOLID_REACTIVE_WIDE(effect_params_t* params) {
23 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math);
40} 24}
25#endif
41 26
42bool SOLID_REACTIVE_WIDE(effect_params_t* params) { 27#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
43 return rgb_matrix_solid_reactive_multiwide_range(qsub8(g_last_hit_tracker.count, 1), params); 28bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) {
29 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math);
44} 30}
31#endif
45 32
46#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 33#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
47#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) 34#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h
index d439bd888..84c99ff00 100644
--- a/quantum/rgb_matrix_animations/solid_splash_anim.h
+++ b/quantum/rgb_matrix_animations/solid_splash_anim.h
@@ -11,37 +11,24 @@ RGB_MATRIX_EFFECT(SOLID_MULTISPLASH)
11 11
12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13 13
14static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* params) { 14void SOLID_SPLASH_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 RGB_MATRIX_USE_LIMITS(led_min, led_max); 15 uint16_t effect = tick - dist;
16 16 if (effect > 255)
17 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
18 uint8_t count = g_last_hit_tracker.count;
19 for (uint8_t i = led_min; i < led_max; i++) {
20 RGB_MATRIX_TEST_LED_FLAGS();
21 hsv.v = 0;
22 for (uint8_t j = start; j < count; j++) {
23 int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
24 int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
25 uint8_t dist = sqrt16(dx * dx + dy * dy);
26 uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
27 if (effect > 255)
28 effect = 255; 17 effect = 255;
29 hsv.v = qadd8(hsv.v, 255 - effect); 18 hsv->v = qadd8(hsv->v, 255 - effect);
30 }
31 hsv.v = scale8(hsv.v, rgb_matrix_config.val);
32 RGB rgb = hsv_to_rgb(hsv);
33 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
34 }
35 return led_max < DRIVER_LED_TOTAL;
36} 19}
37 20
38bool SOLID_MULTISPLASH(effect_params_t* params) { 21#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
39 return rgb_matrix_solid_multisplash_range(0, params); 22bool SOLID_SPLASH(effect_params_t* params) {
23 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math);
40} 24}
25#endif
41 26
42bool SOLID_SPLASH(effect_params_t* params) { 27#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
43 return rgb_matrix_solid_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params); 28bool SOLID_MULTISPLASH(effect_params_t* params) {
29 return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math);
44} 30}
31#endif
45 32
46#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 33#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
47#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH) 34#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h
index 214dab68d..c4c051653 100644
--- a/quantum/rgb_matrix_animations/splash_anim.h
+++ b/quantum/rgb_matrix_animations/splash_anim.h
@@ -11,40 +11,25 @@ RGB_MATRIX_EFFECT(MULTISPLASH)
11 11
12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13 13
14 14void SPLASH_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) { 15 uint16_t effect = tick - dist;
16 RGB_MATRIX_USE_LIMITS(led_min, led_max);
17
18 HSV hsv = { 0, rgb_matrix_config.sat, 0 };
19 uint8_t count = g_last_hit_tracker.count;
20 for (uint8_t i = led_min; i < led_max; i++) {
21 RGB_MATRIX_TEST_LED_FLAGS();
22 hsv.h = rgb_matrix_config.hue;
23 hsv.v = 0;
24 for (uint8_t j = start; j < count; j++) {
25 int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
26 int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
27 uint8_t dist = sqrt16(dx * dx + dy * dy);
28 uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
29 if (effect > 255) 16 if (effect > 255)
30 effect = 255; 17 effect = 255;
31 hsv.h += effect; 18 hsv->h += effect;
32 hsv.v = qadd8(hsv.v, 255 - effect); 19 hsv->v = qadd8(hsv->v, 255 - effect);
33 }
34 hsv.v = scale8(hsv.v, rgb_matrix_config.val);
35 RGB rgb = hsv_to_rgb(hsv);
36 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
37 }
38 return led_max < DRIVER_LED_TOTAL;
39} 20}
40 21
41bool MULTISPLASH(effect_params_t* params) { 22#ifndef DISABLE_RGB_MATRIX_SPLASH
42 return rgb_matrix_multisplash_range(0, params); 23bool SPLASH(effect_params_t* params) {
24 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math);
43} 25}
26#endif
44 27
45bool SPLASH(effect_params_t* params) { 28#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
46 return rgb_matrix_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params); 29bool MULTISPLASH(effect_params_t* params) {
30 return effect_runner_reactive_splash(0, params, &SPLASH_math);
47} 31}
32#endif
48 33
49#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 34#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
50#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) 35#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
diff --git a/quantum/rgb_matrix_runners/effect_runner_dx_dy.h b/quantum/rgb_matrix_runners/effect_runner_dx_dy.h
new file mode 100644
index 000000000..43312629d
--- /dev/null
+++ b/quantum/rgb_matrix_runners/effect_runner_dx_dy.h
@@ -0,0 +1,19 @@
1#pragma once
2
3typedef void (*dx_dy_f)(HSV* hsv, 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 RGB_MATRIX_USE_LIMITS(led_min, led_max);
7
8 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x;
13 int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y;
14 effect_func(&hsv, dx, dy, time);
15 RGB rgb = hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 }
18 return led_max < DRIVER_LED_TOTAL;
19}
diff --git a/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h b/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h
new file mode 100644
index 000000000..a7310c853
--- /dev/null
+++ b/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h
@@ -0,0 +1,20 @@
1#pragma once
2
3typedef void (*dx_dy_dist_f)(HSV* hsv, 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 RGB_MATRIX_USE_LIMITS(led_min, led_max);
7
8 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x;
13 int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y;
14 uint8_t dist = sqrt16(dx * dx + dy * dy);
15 effect_func(&hsv, dx, dy, dist, time);
16 RGB rgb = hsv_to_rgb(hsv);
17 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
18 }
19 return led_max < DRIVER_LED_TOTAL;
20}
diff --git a/quantum/rgb_matrix_runners/effect_runner_i.h b/quantum/rgb_matrix_runners/effect_runner_i.h
new file mode 100644
index 000000000..85405ba1b
--- /dev/null
+++ b/quantum/rgb_matrix_runners/effect_runner_i.h
@@ -0,0 +1,17 @@
1#pragma once
2
3typedef void (*i_f)(HSV* hsv, uint8_t i, uint8_t time);
4
5bool effect_runner_i(effect_params_t* params, i_f effect_func) {
6 RGB_MATRIX_USE_LIMITS(led_min, led_max);
7
8 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
9 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 RGB_MATRIX_TEST_LED_FLAGS();
12 effect_func(&hsv, i, time);
13 RGB rgb = hsv_to_rgb(hsv);
14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
15 }
16 return led_max < DRIVER_LED_TOTAL;
17}
diff --git a/quantum/rgb_matrix_runners/effect_runner_reactive.h b/quantum/rgb_matrix_runners/effect_runner_reactive.h
new file mode 100644
index 000000000..94cd7d545
--- /dev/null
+++ b/quantum/rgb_matrix_runners/effect_runner_reactive.h
@@ -0,0 +1,31 @@
1#pragma once
2
3#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
4
5typedef void (*reactive_f)(HSV* hsv, uint16_t offset);
6
7bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
8 RGB_MATRIX_USE_LIMITS(led_min, led_max);
9
10 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
11 uint16_t max_tick = 65535 / rgb_matrix_config.speed;
12 for (uint8_t i = led_min; i < led_max; i++) {
13 RGB_MATRIX_TEST_LED_FLAGS();
14 uint16_t tick = max_tick;
15 // Reverse search to find most recent key hit
16 for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
17 if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
18 tick = g_last_hit_tracker.tick[j];
19 break;
20 }
21 }
22
23 uint16_t offset = scale16by8(tick, rgb_matrix_config.speed);
24 effect_func(&hsv, offset);
25 RGB rgb = hsv_to_rgb(hsv);
26 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
27 }
28 return led_max < DRIVER_LED_TOTAL;
29}
30
31#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_runners/effect_runner_reactive_splash.h b/quantum/rgb_matrix_runners/effect_runner_reactive_splash.h
new file mode 100644
index 000000000..cb2b0d794
--- /dev/null
+++ b/quantum/rgb_matrix_runners/effect_runner_reactive_splash.h
@@ -0,0 +1,30 @@
1#pragma once
2
3#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
4
5typedef void (*reactive_splash_f)(HSV* hsv, 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 RGB_MATRIX_USE_LIMITS(led_min, led_max);
9
10 HSV hsv = { 0, rgb_matrix_config.sat, 0 };
11 uint8_t count = g_last_hit_tracker.count;
12 for (uint8_t i = led_min; i < led_max; i++) {
13 RGB_MATRIX_TEST_LED_FLAGS();
14 hsv.h = rgb_matrix_config.hue;
15 hsv.v = 0;
16 for (uint8_t j = start; j < count; j++) {
17 int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
18 int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
19 uint8_t dist = sqrt16(dx * dx + dy * dy);
20 uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed);
21 effect_func(&hsv, dx, dy, dist, tick);
22 }
23 hsv.v = scale8(hsv.v, rgb_matrix_config.val);
24 RGB rgb = hsv_to_rgb(hsv);
25 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
26 }
27 return led_max < DRIVER_LED_TOTAL;
28}
29
30#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h b/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h
new file mode 100644
index 000000000..54e4c6d86
--- /dev/null
+++ b/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h
@@ -0,0 +1,19 @@
1#pragma once
2
3typedef void (*sin_cos_i_f)(HSV* hsv, 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 RGB_MATRIX_USE_LIMITS(led_min, led_max);
7
8 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
9 uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
10 int8_t cos_value = cos8(time) - 128;
11 int8_t sin_value = sin8(time) - 128;
12 for (uint8_t i = led_min; i < led_max; i++) {
13 RGB_MATRIX_TEST_LED_FLAGS();
14 effect_func(&hsv, cos_value, sin_value, i, time);
15 RGB rgb = hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 }
18 return led_max < DRIVER_LED_TOTAL;
19}