aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix_animations
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix_animations')
-rw-r--r--quantum/rgb_matrix_animations/alpha_mods_anim.h26
-rw-r--r--quantum/rgb_matrix_animations/breathing_anim.h19
-rw-r--r--quantum/rgb_matrix_animations/cycle_all_anim.h21
-rw-r--r--quantum/rgb_matrix_animations/cycle_left_right_anim.h22
-rw-r--r--quantum/rgb_matrix_animations/cycle_up_down_anim.h22
-rw-r--r--quantum/rgb_matrix_animations/digital_rain_anim.h74
-rw-r--r--quantum/rgb_matrix_animations/dual_beacon_anim.h24
-rw-r--r--quantum/rgb_matrix_animations/gradient_up_down_anim.h22
-rw-r--r--quantum/rgb_matrix_animations/jellybean_raindrops_anim.h30
-rw-r--r--quantum/rgb_matrix_animations/rainbow_beacon_anim.h24
-rw-r--r--quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h22
-rw-r--r--quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h24
-rw-r--r--quantum/rgb_matrix_animations/raindrops_anim.h40
-rw-r--r--quantum/rgb_matrix_animations/solid_color_anim.h14
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_anim.h33
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_simple_anim.h32
-rw-r--r--quantum/rgb_matrix_animations/solid_splash_anim.h42
-rw-r--r--quantum/rgb_matrix_animations/splash_anim.h44
18 files changed, 535 insertions, 0 deletions
diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h
new file mode 100644
index 000000000..cc1914d7f
--- /dev/null
+++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h
@@ -0,0 +1,26 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
3
4extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
5extern rgb_config_t rgb_matrix_config;
6
7// alphas = color1, mods = color2
8bool rgb_matrix_alphas_mods(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
12 RGB rgb1 = hsv_to_rgb(hsv);
13 hsv.h += rgb_matrix_config.speed;
14 RGB rgb2 = hsv_to_rgb(hsv);
15
16 for (uint8_t i = led_min; i < led_max; i++) {
17 if (g_rgb_leds[i].modifier) {
18 rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b);
19 } else {
20 rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b);
21 }
22 }
23 return led_max < DRIVER_LED_TOTAL;
24}
25
26#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS
diff --git a/quantum/rgb_matrix_animations/breathing_anim.h b/quantum/rgb_matrix_animations/breathing_anim.h
new file mode 100644
index 000000000..fb90b66bd
--- /dev/null
+++ b/quantum/rgb_matrix_animations/breathing_anim.h
@@ -0,0 +1,19 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_BREATHING
3
4extern rgb_config_t rgb_matrix_config;
5
6bool rgb_matrix_breathing(effect_params_t* params) {
7 RGB_MATRIX_USE_LIMITS(led_min, led_max);
8
9 uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
10 uint8_t val = scale8(abs8(sin8(time) - 128) * 2, rgb_matrix_config.val);
11 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, val };
12 RGB rgb = hsv_to_rgb(hsv);
13 for (uint8_t i = led_min; i < led_max; i++) {
14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
15 }
16 return led_max < DRIVER_LED_TOTAL;
17}
18
19#endif // DISABLE_RGB_MATRIX_BREATHING
diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h
new file mode 100644
index 000000000..5c18cfa0c
--- /dev/null
+++ b/quantum/rgb_matrix_animations/cycle_all_anim.h
@@ -0,0 +1,21 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
3
4extern rgb_counters_t g_rgb_counters;
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7
8bool rgb_matrix_cycle_all(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
12 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
13 for (uint8_t i = led_min; i < led_max; i++) {
14 hsv.h = 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}
20
21#endif // DISABLE_RGB_MATRIX_CYCLE_ALL
diff --git a/quantum/rgb_matrix_animations/cycle_left_right_anim.h b/quantum/rgb_matrix_animations/cycle_left_right_anim.h
new file mode 100644
index 000000000..f519aeb47
--- /dev/null
+++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h
@@ -0,0 +1,22 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
3
4extern rgb_counters_t g_rgb_counters;
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7
8bool rgb_matrix_cycle_left_right(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
12 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
13 for (uint8_t i = led_min; i < led_max; i++) {
14 point_t point = g_rgb_leds[i].point;
15 hsv.h = point.x - 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}
21
22#endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h
new file mode 100644
index 000000000..8b91d890d
--- /dev/null
+++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h
@@ -0,0 +1,22 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
3
4extern rgb_counters_t g_rgb_counters;
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7
8bool rgb_matrix_cycle_up_down(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
12 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
13 for (uint8_t i = led_min; i < led_max; i++) {
14 point_t point = g_rgb_leds[i].point;
15 hsv.h = point.y - 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}
21
22#endif // DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
diff --git a/quantum/rgb_matrix_animations/digital_rain_anim.h b/quantum/rgb_matrix_animations/digital_rain_anim.h
new file mode 100644
index 000000000..4ba3c1c87
--- /dev/null
+++ b/quantum/rgb_matrix_animations/digital_rain_anim.h
@@ -0,0 +1,74 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
3
4#ifndef RGB_DIGITAL_RAIN_DROPS
5 // lower the number for denser effect/wider keyboard
6 #define RGB_DIGITAL_RAIN_DROPS 24
7#endif
8
9bool rgb_matrix_digital_rain(effect_params_t* params) {
10 // algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain
11 const uint8_t drop_ticks = 28;
12 const uint8_t pure_green_intensity = 0xd0;
13 const uint8_t max_brightness_boost = 0xc0;
14 const uint8_t max_intensity = 0xff;
15
16 static uint8_t map[MATRIX_COLS][MATRIX_ROWS] = {{0}};
17 static uint8_t drop = 0;
18
19 if (params->init) {
20 rgb_matrix_set_color_all(0, 0, 0);
21 memset(map, 0, sizeof map);
22 drop = 0;
23 }
24 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
25 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
26 if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) {
27 // top row, pixels have just fallen and we're
28 // making a new rain drop in this column
29 map[col][row] = max_intensity;
30 }
31 else if (map[col][row] > 0 && map[col][row] < max_intensity) {
32 // neither fully bright nor dark, decay it
33 map[col][row]--;
34 }
35 // set the pixel colour
36 uint8_t led[LED_HITS_TO_REMEMBER];
37 uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led);
38
39 // TODO: multiple leds are supported mapped to the same row/column
40 if (led_count > 0) {
41 if (map[col][row] > pure_green_intensity) {
42 const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost * (map[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity));
43 rgb_matrix_set_color(led[0], boost, max_intensity, boost);
44 }
45 else {
46 const uint8_t green = (uint8_t) ((uint16_t) max_intensity * map[col][row] / pure_green_intensity);
47 rgb_matrix_set_color(led[0], 0, green, 0);
48 }
49 }
50 }
51 }
52 if (++drop > drop_ticks) {
53 // reset drop timer
54 drop = 0;
55 for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) {
56 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
57 // if ths is on the bottom row and bright allow decay
58 if (row == MATRIX_ROWS - 1 && map[col][row] == max_intensity) {
59 map[col][row]--;
60 }
61 // check if the pixel above is bright
62 if (map[col][row - 1] == max_intensity) {
63 // allow old bright pixel to decay
64 map[col][row - 1]--;
65 // make this pixel bright
66 map[col][row] = max_intensity;
67 }
68 }
69 }
70 }
71 return false;
72}
73
74#endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN
diff --git a/quantum/rgb_matrix_animations/dual_beacon_anim.h b/quantum/rgb_matrix_animations/dual_beacon_anim.h
new file mode 100644
index 000000000..dda315780
--- /dev/null
+++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h
@@ -0,0 +1,24 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
3
4extern rgb_counters_t g_rgb_counters;
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7
8bool rgb_matrix_dual_beacon(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
12 uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
13 int8_t cos_value = cos8(time) - 128;
14 int8_t sin_value = sin8(time) - 128;
15 for (uint8_t i = led_min; i < led_max; i++) {
16 point_t point = g_rgb_leds[i].point;
17 hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue;
18 RGB rgb = hsv_to_rgb(hsv);
19 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
20 }
21 return led_max < DRIVER_LED_TOTAL;
22}
23
24#endif // DISABLE_RGB_MATRIX_DUAL_BEACON
diff --git a/quantum/rgb_matrix_animations/gradient_up_down_anim.h b/quantum/rgb_matrix_animations/gradient_up_down_anim.h
new file mode 100644
index 000000000..11498e22f
--- /dev/null
+++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h
@@ -0,0 +1,22 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
3
4extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
5extern rgb_config_t rgb_matrix_config;
6
7bool rgb_matrix_gradient_up_down(effect_params_t* params) {
8 RGB_MATRIX_USE_LIMITS(led_min, led_max);
9
10 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
11 uint8_t scale = scale8(64, rgb_matrix_config.speed);
12 for (uint8_t i = led_min; i < led_max; i++) {
13 point_t point = g_rgb_leds[i].point;
14 // The y range will be 0..64, map this to 0..4
15 // Relies on hue being 8-bit and wrapping
16 hsv.h = rgb_matrix_config.hue + scale * (point.y >> 4);
17 RGB rgb = hsv_to_rgb(hsv);
18 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
19 }
20 return led_max < DRIVER_LED_TOTAL;
21}
22#endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
new file mode 100644
index 000000000..01ff5c230
--- /dev/null
+++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
@@ -0,0 +1,30 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
3
4extern rgb_counters_t g_rgb_counters;
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7
8static void jellybean_raindrops_set_color(int i) {
9 HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val };
10 RGB rgb = hsv_to_rgb(hsv);
11 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
12}
13
14bool rgb_matrix_jellybean_raindrops(effect_params_t* params) {
15 if (!params->init) {
16 // Change one LED every tick, make sure speed is not 0
17 if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
18 jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL);
19 }
20 return false;
21 }
22
23 RGB_MATRIX_USE_LIMITS(led_min, led_max);
24 for (int i = led_min; i < led_max; i++) {
25 jellybean_raindrops_set_color(i);
26 }
27 return led_max < DRIVER_LED_TOTAL;
28}
29
30#endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
new file mode 100644
index 000000000..3c15e64ab
--- /dev/null
+++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
@@ -0,0 +1,24 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
3
4extern rgb_counters_t g_rgb_counters;
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7
8bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
12 uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
13 int16_t cos_value = 2 * (cos8(time) - 128);
14 int16_t sin_value = 2 * (sin8(time) - 128);
15 for (uint8_t i = led_min; i < led_max; i++) {
16 point_t point = g_rgb_leds[i].point;
17 hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue;
18 RGB rgb = hsv_to_rgb(hsv);
19 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
20 }
21 return led_max < DRIVER_LED_TOTAL;
22}
23
24#endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON
diff --git a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
new file mode 100644
index 000000000..0d11d5280
--- /dev/null
+++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
@@ -0,0 +1,22 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
3
4extern rgb_counters_t g_rgb_counters;
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7
8bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
12 uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
13 for (uint8_t i = led_min; i < led_max; i++) {
14 point_t point = g_rgb_leds[i].point;
15 hsv.h = abs8(point.y - 32) + (point.x - time) + rgb_matrix_config.hue;
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}
21
22#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
diff --git a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
new file mode 100644
index 000000000..d7cd42cbe
--- /dev/null
+++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
@@ -0,0 +1,24 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
3
4extern rgb_counters_t g_rgb_counters;
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7
8bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
12 uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
13 int16_t cos_value = 3 * (cos8(time) - 128);
14 int16_t sin_value = 3 * (sin8(time) - 128);
15 for (uint8_t i = led_min; i < led_max; i++) {
16 point_t point = g_rgb_leds[i].point;
17 hsv.h = ((point.y - 32) * cos_value + (56 - abs8(point.x - 112)) * sin_value) / 128 + rgb_matrix_config.hue;
18 RGB rgb = hsv_to_rgb(hsv);
19 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
20 }
21 return led_max < DRIVER_LED_TOTAL;
22}
23
24#endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h
new file mode 100644
index 000000000..fc721375b
--- /dev/null
+++ b/quantum/rgb_matrix_animations/raindrops_anim.h
@@ -0,0 +1,40 @@
1#pragma once
2#ifndef DISABLE_RGB_MATRIX_RAINDROPS
3#include "rgb_matrix_types.h"
4
5extern rgb_counters_t g_rgb_counters;
6extern rgb_config_t rgb_matrix_config;
7
8static void raindrops_set_color(int i) {
9 HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val };
10
11 // Take the shortest path between hues
12 int16_t deltaH = ((rgb_matrix_config.hue + 180) % 360 - rgb_matrix_config.hue) / 4;
13 if (deltaH > 127) {
14 deltaH -= 256;
15 } else if (deltaH < -127) {
16 deltaH += 256;
17 }
18
19 hsv.h = rgb_matrix_config.hue + (deltaH * (rand() & 0x03));
20 RGB rgb = hsv_to_rgb(hsv);
21 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
22}
23
24bool rgb_matrix_raindrops(effect_params_t* params) {
25 if (!params->init) {
26 // Change one LED every tick, make sure speed is not 0
27 if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
28 raindrops_set_color(rand() % DRIVER_LED_TOTAL);
29 }
30 return false;
31 }
32
33 RGB_MATRIX_USE_LIMITS(led_min, led_max);
34 for (int i = led_min; i < led_max; i++) {
35 raindrops_set_color(i);
36 }
37 return led_max < DRIVER_LED_TOTAL;
38}
39
40#endif // DISABLE_RGB_MATRIX_RAINDROPS
diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h
new file mode 100644
index 000000000..24a197beb
--- /dev/null
+++ b/quantum/rgb_matrix_animations/solid_color_anim.h
@@ -0,0 +1,14 @@
1#pragma once
2
3extern rgb_config_t rgb_matrix_config;
4
5bool rgb_matrix_solid_color(effect_params_t* params) {
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 RGB rgb = hsv_to_rgb(hsv);
10 for (uint8_t i = led_min; i < led_max; i++) {
11 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
12 }
13 return led_max < DRIVER_LED_TOTAL;
14}
diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h
new file mode 100644
index 000000000..220e54233
--- /dev/null
+++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h
@@ -0,0 +1,33 @@
1#pragma once
2#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
3#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
4
5extern rgb_config_t rgb_matrix_config;
6extern last_hit_t g_last_hit_tracker;
7
8bool rgb_matrix_solid_reactive(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { rgb_matrix_config.hue, 255, rgb_matrix_config.val };
12 // Max tick based on speed scale ensures results from scale16by8 with rgb_matrix_config.speed are no greater than 255
13 uint16_t max_tick = 65535 / rgb_matrix_config.speed;
14 // Relies on hue being 8-bit and wrapping
15 for (uint8_t i = led_min; i < led_max; i++) {
16 uint16_t tick = max_tick;
17 for(uint8_t j = 0; j < g_last_hit_tracker.count; 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
24 uint16_t offset = scale16by8(tick, rgb_matrix_config.speed);
25 hsv.h = rgb_matrix_config.hue + qsub8(130, offset);
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}
31
32#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
33#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
new file mode 100644
index 000000000..e84cd6939
--- /dev/null
+++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
@@ -0,0 +1,32 @@
1#pragma once
2#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
3#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
4
5extern rgb_config_t rgb_matrix_config;
6extern last_hit_t g_last_hit_tracker;
7
8bool rgb_matrix_solid_reactive_simple(effect_params_t* params) {
9 RGB_MATRIX_USE_LIMITS(led_min, led_max);
10
11 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
12 // Max tick based on speed scale ensures results from scale16by8 with rgb_matrix_config.speed are no greater than 255
13 uint16_t max_tick = 65535 / rgb_matrix_config.speed;
14 for (uint8_t i = led_min; i < led_max; i++) {
15 uint16_t tick = max_tick;
16 for(uint8_t j = 0; j < g_last_hit_tracker.count; 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 hsv.v = scale8(255 - offset, rgb_matrix_config.val);
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 // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
32#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h
new file mode 100644
index 000000000..82ac055b8
--- /dev/null
+++ b/quantum/rgb_matrix_animations/solid_splash_anim.h
@@ -0,0 +1,42 @@
1#pragma once
2#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
3#if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH)
4
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7extern last_hit_t g_last_hit_tracker;
8
9static bool rgb_matrix_solid_multisplash_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;
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
33bool rgb_matrix_solid_multisplash(effect_params_t* params) {
34 return rgb_matrix_solid_multisplash_range(0, params);
35}
36
37bool rgb_matrix_solid_splash(effect_params_t* params) {
38 return rgb_matrix_solid_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params);
39}
40
41#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
42#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h
new file mode 100644
index 000000000..829d30eef
--- /dev/null
+++ b/quantum/rgb_matrix_animations/splash_anim.h
@@ -0,0 +1,44 @@
1#pragma once
2#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
3#if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
4
5extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
6extern rgb_config_t rgb_matrix_config;
7extern last_hit_t g_last_hit_tracker;
8
9static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) {
10 RGB_MATRIX_USE_LIMITS(led_min, led_max);
11
12 HSV hsv = { 0, 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.h = rgb_matrix_config.hue;
16 hsv.v = 0;
17 point_t point = g_rgb_leds[i].point;
18 for (uint8_t j = start; j < count; j++) {
19 int16_t dx = point.x - g_last_hit_tracker.x[j];
20 int16_t dy = point.y - g_last_hit_tracker.y[j];
21 uint8_t dist = sqrt16(dx * dx + dy * dy);
22 uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
23 if (effect > 255)
24 effect = 255;
25 hsv.h += effect;
26 hsv.v = qadd8(hsv.v, 255 - effect);
27 }
28 hsv.v = scale8(hsv.v, rgb_matrix_config.val);
29 RGB rgb = hsv_to_rgb(hsv);
30 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
31 }
32 return led_max < DRIVER_LED_TOTAL;
33}
34
35bool rgb_matrix_multisplash(effect_params_t* params) {
36 return rgb_matrix_multisplash_range(0, params);
37}
38
39bool rgb_matrix_splash(effect_params_t* params) {
40 return rgb_matrix_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params);
41}
42
43#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
44#endif // RGB_MATRIX_KEYREACTIVE_ENABLED