diff options
author | M-AS <matthewtransformer@hotmail.com> | 2019-04-22 11:37:40 -0400 |
---|---|---|
committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-04-22 08:37:40 -0700 |
commit | bb52119a6dfe9c6f0314d1bcd948efda59626a70 (patch) | |
tree | a385f30d3eee0bf585e1089f0907c24fa64523dc | |
parent | b61baf4281bde34bfe28aaa1109bd5d5c6471116 (diff) | |
download | qmk_firmware-bb52119a6dfe9c6f0314d1bcd948efda59626a70.tar.gz qmk_firmware-bb52119a6dfe9c6f0314d1bcd948efda59626a70.zip |
RGB Matrix Animations: Three/six new reactive effects (wide, cross, nexus) (#5602)
* added 3 new RGB_Matrix effects
* made cross effect behavior smoother
* removed dead code
* added effect descriptions
-rw-r--r-- | docs/feature_rgb_matrix.md | 54 | ||||
-rw-r--r-- | quantum/rgb_matrix.c | 33 | ||||
-rw-r--r-- | quantum/rgb_matrix.h | 18 | ||||
-rw-r--r-- | quantum/rgb_matrix_animations/solid_reactive_cross.h | 50 | ||||
-rw-r--r-- | quantum/rgb_matrix_animations/solid_reactive_nexus.h | 48 | ||||
-rw-r--r-- | quantum/rgb_matrix_animations/solid_reactive_wide.h | 42 |
6 files changed, 224 insertions, 21 deletions
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 5309e749c..f2168ab16 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md | |||
@@ -189,6 +189,12 @@ enum rgb_matrix_effects { | |||
189 | #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) | 189 | #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) |
190 | RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out | 190 | RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out |
191 | RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue | 191 | RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue |
192 | RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out | ||
193 | RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out | ||
194 | RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out | ||
195 | RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out | ||
196 | RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out | ||
197 | RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out | ||
192 | RGB_MATRIX_SPLASH, // Full gradient & value pulse away from a single key hit then fades value out | 198 | RGB_MATRIX_SPLASH, // Full gradient & value pulse away from a single key hit then fades value out |
193 | RGB_MATRIX_MULTISPLASH, // Full gradient & value pulse away from multiple key hits then fades value out | 199 | RGB_MATRIX_MULTISPLASH, // Full gradient & value pulse away from multiple key hits then fades value out |
194 | RGB_MATRIX_SOLID_SPLASH, // Hue & value pulse away from a single key hit then fades value out | 200 | RGB_MATRIX_SOLID_SPLASH, // Hue & value pulse away from a single key hit then fades value out |
@@ -201,27 +207,33 @@ enum rgb_matrix_effects { | |||
201 | You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`: | 207 | You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`: |
202 | 208 | ||
203 | 209 | ||
204 | |Define |Description | | 210 | |Define |Description | |
205 | |---------------------------------------------------|--------------------------------------------| | 211 | |-------------------------------------------------------|-----------------------------------------------| |
206 | |`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` | | 212 | |`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` | |
207 | |`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` | | 213 | |`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` | |
208 | |`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` | | 214 | |`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` | |
209 | |`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` | | 215 | |`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` | |
210 | |`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` | | 216 | |`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` | |
211 | |`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` | | 217 | |`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` | |
212 | |`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON`|Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON`| | 218 | |`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON` | |
213 | |`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` | | 219 | |`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` | |
214 | |`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` | | 220 | |`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` | |
215 | |`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` | | 221 | |`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` | |
216 | |`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` | | 222 | |`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` | |
217 | |`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` | | 223 | |`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` | |
218 | |`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` | | 224 | |`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` | |
219 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` | | 225 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` | |
220 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLEE`| | 226 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLE` | |
221 | |`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` | | 227 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_WIDE` | |
222 | |`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` | | 228 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` | |
223 | |`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` | | 229 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_CROSS` | |
224 | |`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` | | 230 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTICROSS`| |
231 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_NEXUS` | | ||
232 | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS`| | ||
233 | |`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` | | ||
234 | |`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` | | ||
235 | |`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` | | ||
236 | |`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` | | ||
225 | 237 | ||
226 | 238 | ||
227 | ## Custom layer effects | 239 | ## Custom layer effects |
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index a1193d4c0..41ed8983e 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
@@ -41,6 +41,9 @@ | |||
41 | #include "rgb_matrix_animations/digital_rain_anim.h" | 41 | #include "rgb_matrix_animations/digital_rain_anim.h" |
42 | #include "rgb_matrix_animations/solid_reactive_simple_anim.h" | 42 | #include "rgb_matrix_animations/solid_reactive_simple_anim.h" |
43 | #include "rgb_matrix_animations/solid_reactive_anim.h" | 43 | #include "rgb_matrix_animations/solid_reactive_anim.h" |
44 | #include "rgb_matrix_animations/solid_reactive_wide.h" | ||
45 | #include "rgb_matrix_animations/solid_reactive_cross.h" | ||
46 | #include "rgb_matrix_animations/solid_reactive_nexus.h" | ||
44 | #include "rgb_matrix_animations/splash_anim.h" | 47 | #include "rgb_matrix_animations/splash_anim.h" |
45 | #include "rgb_matrix_animations/solid_splash_anim.h" | 48 | #include "rgb_matrix_animations/solid_splash_anim.h" |
46 | #include "rgb_matrix_animations/breathing_anim.h" | 49 | #include "rgb_matrix_animations/breathing_anim.h" |
@@ -380,6 +383,36 @@ static void rgb_task_render(uint8_t effect) { | |||
380 | rendering = rgb_matrix_solid_reactive(&rgb_effect_params); // Max 4ms Avg 3ms | 383 | rendering = rgb_matrix_solid_reactive(&rgb_effect_params); // Max 4ms Avg 3ms |
381 | break; | 384 | break; |
382 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE | 385 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE |
386 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE | ||
387 | case RGB_MATRIX_SOLID_REACTIVE_WIDE: | ||
388 | rendering = rgb_matrix_solid_reactive_wide(&rgb_effect_params); // Max ?? ms Avg ?? ms | ||
389 | break; | ||
390 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE | ||
391 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE | ||
392 | case RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE: | ||
393 | rendering = rgb_matrix_solid_reactive_multiwide(&rgb_effect_params); // Max ?? ms Avg ?? ms | ||
394 | break; | ||
395 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE | ||
396 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS | ||
397 | case RGB_MATRIX_SOLID_REACTIVE_CROSS: | ||
398 | rendering = rgb_matrix_solid_reactive_cross(&rgb_effect_params); // Max ?? ms Avg ?? ms | ||
399 | break; | ||
400 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS | ||
401 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS | ||
402 | case RGB_MATRIX_SOLID_REACTIVE_MULTICROSS: | ||
403 | rendering = rgb_matrix_solid_reactive_multicross(&rgb_effect_params); // Max ?? ms Avg ?? ms | ||
404 | break; | ||
405 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS | ||
406 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS | ||
407 | case RGB_MATRIX_SOLID_REACTIVE_NEXUS: | ||
408 | rendering = rgb_matrix_solid_reactive_nexus(&rgb_effect_params); // Max ?? ms Avg ?? ms | ||
409 | break; | ||
410 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS | ||
411 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS | ||
412 | case RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS: | ||
413 | rendering = rgb_matrix_solid_reactive_multinexus(&rgb_effect_params); // Max ?? ms Avg ?? ms | ||
414 | break; | ||
415 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS | ||
383 | #ifndef DISABLE_RGB_MATRIX_SPLASH | 416 | #ifndef DISABLE_RGB_MATRIX_SPLASH |
384 | case RGB_MATRIX_SPLASH: | 417 | case RGB_MATRIX_SPLASH: |
385 | rendering = rgb_matrix_splash(&rgb_effect_params); // Max 5ms Avg 3ms | 418 | rendering = rgb_matrix_splash(&rgb_effect_params); // Max 5ms Avg 3ms |
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index f5be49435..5fdc854f0 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h | |||
@@ -111,6 +111,24 @@ enum rgb_matrix_effects { | |||
111 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE | 111 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE |
112 | RGB_MATRIX_SOLID_REACTIVE, | 112 | RGB_MATRIX_SOLID_REACTIVE, |
113 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE | 113 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE |
114 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE | ||
115 | RGB_MATRIX_SOLID_REACTIVE_WIDE, | ||
116 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE | ||
117 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE | ||
118 | RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE, | ||
119 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE | ||
120 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS | ||
121 | RGB_MATRIX_SOLID_REACTIVE_CROSS, | ||
122 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS | ||
123 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS | ||
124 | RGB_MATRIX_SOLID_REACTIVE_MULTICROSS, | ||
125 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS | ||
126 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS | ||
127 | RGB_MATRIX_SOLID_REACTIVE_NEXUS, | ||
128 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS | ||
129 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS | ||
130 | RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS, | ||
131 | #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS | ||
114 | #ifndef DISABLE_RGB_MATRIX_SPLASH | 132 | #ifndef DISABLE_RGB_MATRIX_SPLASH |
115 | RGB_MATRIX_SPLASH, | 133 | RGB_MATRIX_SPLASH, |
116 | #endif // DISABLE_RGB_MATRIX_SPLASH | 134 | #endif // DISABLE_RGB_MATRIX_SPLASH |
diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h new file mode 100644 index 000000000..af602cba1 --- /dev/null +++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h | |||
@@ -0,0 +1,50 @@ | |||
1 | #pragma once | ||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) | ||
4 | |||
5 | extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | ||
6 | extern rgb_config_t rgb_matrix_config; | ||
7 | extern last_hit_t g_last_hit_tracker; | ||
8 | |||
9 | static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_params_t* params) { | ||
10 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
11 | |||
12 | HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; | ||
13 | uint8_t count = g_last_hit_tracker.count; | ||
14 | for (uint8_t i = led_min; i < led_max; i++) { | ||
15 | hsv.v = 0; | ||
16 | point_t point = g_rgb_leds[i].point; | ||
17 | for (uint8_t j = start; j < count; j++) { | ||
18 | int16_t dx = point.x - g_last_hit_tracker.x[j]; | ||
19 | int16_t dy = point.y - g_last_hit_tracker.y[j]; | ||
20 | uint8_t dist = sqrt16(dx * dx + dy * dy); | ||
21 | int16_t dist2 = 16; | ||
22 | uint8_t dist3; | ||
23 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist; | ||
24 | dx = dx < 0 ? dx * -1 : dx; | ||
25 | dy = dy < 0 ? dy * -1 : dy; | ||
26 | dx = dx * dist2 > 255 ? 255 : dx * dist2; | ||
27 | dy = dy * dist2 > 255 ? 255 : dy * dist2; | ||
28 | dist3 = dx > dy ? dy : dx; | ||
29 | effect += dist3; | ||
30 | if (effect > 255) | ||
31 | effect = 255; | ||
32 | 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 | } | ||
40 | |||
41 | bool rgb_matrix_solid_reactive_multicross(effect_params_t* params) { | ||
42 | return rgb_matrix_solid_reactive_multicross_range(0, params); | ||
43 | } | ||
44 | |||
45 | bool rgb_matrix_solid_reactive_cross(effect_params_t* params) { | ||
46 | return rgb_matrix_solid_reactive_multicross_range(qsub8(g_last_hit_tracker.count, 1), params); | ||
47 | } | ||
48 | |||
49 | #endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) | ||
50 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | ||
diff --git a/quantum/rgb_matrix_animations/solid_reactive_nexus.h b/quantum/rgb_matrix_animations/solid_reactive_nexus.h new file mode 100644 index 000000000..8b4a139dc --- /dev/null +++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #pragma once | ||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) | ||
4 | |||
5 | extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | ||
6 | extern rgb_config_t rgb_matrix_config; | ||
7 | extern last_hit_t g_last_hit_tracker; | ||
8 | |||
9 | static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_params_t* params) { | ||
10 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
11 | |||
12 | HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; | ||
13 | uint8_t count = g_last_hit_tracker.count; | ||
14 | for (uint8_t i = led_min; i < led_max; i++) { | ||
15 | hsv.v = 0; | ||
16 | point_t point = g_rgb_leds[i].point; | ||
17 | for (uint8_t j = start; j < count; j++) { | ||
18 | int16_t dx = point.x - g_last_hit_tracker.x[j]; | ||
19 | int16_t dy = point.y - g_last_hit_tracker.y[j]; | ||
20 | uint8_t dist = sqrt16(dx * dx + dy * dy); | ||
21 | int16_t dist2 = 8; | ||
22 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; | ||
23 | if (effect > 255) | ||
24 | effect = 255; | ||
25 | if (dist > 72) | ||
26 | effect = 255; | ||
27 | if ((dx > dist2 || dx < -dist2) && (dy > dist2 || dy < -dist2)) | ||
28 | effect = 255; | ||
29 | hsv.v = qadd8(hsv.v, 255 - effect); | ||
30 | hsv.h = rgb_matrix_config.hue + dy / 4; | ||
31 | } | ||
32 | hsv.v = scale8(hsv.v, rgb_matrix_config.val); | ||
33 | RGB rgb = hsv_to_rgb(hsv); | ||
34 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
35 | } | ||
36 | return led_max < DRIVER_LED_TOTAL; | ||
37 | } | ||
38 | |||
39 | bool rgb_matrix_solid_reactive_multinexus(effect_params_t* params) { | ||
40 | return rgb_matrix_solid_reactive_multinexus_range(0, params); | ||
41 | } | ||
42 | |||
43 | bool rgb_matrix_solid_reactive_nexus(effect_params_t* params) { | ||
44 | return rgb_matrix_solid_reactive_multinexus_range(qsub8(g_last_hit_tracker.count, 1), params); | ||
45 | } | ||
46 | |||
47 | #endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) | ||
48 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | ||
diff --git a/quantum/rgb_matrix_animations/solid_reactive_wide.h b/quantum/rgb_matrix_animations/solid_reactive_wide.h new file mode 100644 index 000000000..abb01892e --- /dev/null +++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #pragma once | ||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) | ||
4 | |||
5 | extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | ||
6 | extern rgb_config_t rgb_matrix_config; | ||
7 | extern last_hit_t g_last_hit_tracker; | ||
8 | |||
9 | static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_params_t* params) { | ||
10 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
11 | |||
12 | HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; | ||
13 | uint8_t count = g_last_hit_tracker.count; | ||
14 | for (uint8_t i = led_min; i < led_max; i++) { | ||
15 | hsv.v = 0; | ||
16 | point_t point = g_rgb_leds[i].point; | ||
17 | for (uint8_t j = start; j < count; j++) { | ||
18 | int16_t dx = point.x - g_last_hit_tracker.x[j]; | ||
19 | int16_t dy = point.y - g_last_hit_tracker.y[j]; | ||
20 | uint8_t dist = sqrt16(dx * dx + dy * dy); | ||
21 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist * 5; | ||
22 | if (effect > 255) | ||
23 | effect = 255; | ||
24 | hsv.v = qadd8(hsv.v, 255 - effect); | ||
25 | } | ||
26 | hsv.v = scale8(hsv.v, rgb_matrix_config.val); | ||
27 | RGB rgb = hsv_to_rgb(hsv); | ||
28 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
29 | } | ||
30 | return led_max < DRIVER_LED_TOTAL; | ||
31 | } | ||
32 | |||
33 | bool rgb_matrix_solid_reactive_multiwide(effect_params_t* params) { | ||
34 | return rgb_matrix_solid_reactive_multiwide_range(0, params); | ||
35 | } | ||
36 | |||
37 | bool rgb_matrix_solid_reactive_wide(effect_params_t* params) { | ||
38 | return rgb_matrix_solid_reactive_multiwide_range(qsub8(g_last_hit_tracker.count, 1), params); | ||
39 | } | ||
40 | |||
41 | #endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) | ||
42 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | ||