diff options
author | Ryan <fauxpark@gmail.com> | 2021-06-22 18:26:23 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 18:26:23 +1000 |
commit | d61e5c0027e289ccf48652afa4c442342e7ccf04 (patch) | |
tree | e8edc86d191a190691b4722f05e32bdc40affc58 /quantum/rgb_matrix/animations | |
parent | c03cb4edd7ff73391a0a64f0c4f5e0755e902908 (diff) | |
download | qmk_firmware-d61e5c0027e289ccf48652afa4c442342e7ccf04.tar.gz qmk_firmware-d61e5c0027e289ccf48652afa4c442342e7ccf04.zip |
Move LED/RGB Matrix code into their own directories (#13257)
Diffstat (limited to 'quantum/rgb_matrix/animations')
44 files changed, 977 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..426d88ef3 --- /dev/null +++ b/quantum/rgb_matrix/animations/alpha_mods_anim.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS | ||
2 | RGB_MATRIX_EFFECT(ALPHAS_MODS) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | // alphas = color1, mods = color2 | ||
6 | bool ALPHAS_MODS(effect_params_t* params) { | ||
7 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
8 | |||
9 | HSV hsv = rgb_matrix_config.hsv; | ||
10 | RGB rgb1 = rgb_matrix_hsv_to_rgb(hsv); | ||
11 | hsv.h += rgb_matrix_config.speed; | ||
12 | RGB rgb2 = rgb_matrix_hsv_to_rgb(hsv); | ||
13 | |||
14 | for (uint8_t i = led_min; i < led_max; i++) { | ||
15 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
16 | if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { | ||
17 | rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); | ||
18 | } else { | ||
19 | rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); | ||
20 | } | ||
21 | } | ||
22 | return led_max < DRIVER_LED_TOTAL; | ||
23 | } | ||
24 | |||
25 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
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..340bd93e5 --- /dev/null +++ b/quantum/rgb_matrix/animations/breathing_anim.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_BREATHING | ||
2 | RGB_MATRIX_EFFECT(BREATHING) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | bool BREATHING(effect_params_t* params) { | ||
6 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
7 | |||
8 | HSV hsv = rgb_matrix_config.hsv; | ||
9 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); | ||
10 | hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); | ||
11 | RGB rgb = rgb_matrix_hsv_to_rgb(hsv); | ||
12 | for (uint8_t i = led_min; i < led_max; i++) { | ||
13 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
14 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
15 | } | ||
16 | return led_max < DRIVER_LED_TOTAL; | ||
17 | } | ||
18 | |||
19 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
20 | #endif // DISABLE_RGB_MATRIX_BREATHING | ||
diff --git a/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h b/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h new file mode 100644 index 000000000..3df3cfda7 --- /dev/null +++ b/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT | ||
2 | RGB_MATRIX_EFFECT(BAND_PINWHEEL_SAT) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { | ||
6 | hsv.s = scale8(hsv.s - time - atan2_8(dy, dx) * 3, hsv.s); | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool BAND_PINWHEEL_SAT(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT | ||
diff --git a/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h b/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h new file mode 100644 index 000000000..7d80074fd --- /dev/null +++ b/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL | ||
2 | RGB_MATRIX_EFFECT(BAND_PINWHEEL_VAL) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { | ||
6 | hsv.v = scale8(hsv.v - time - atan2_8(dy, dx) * 3, hsv.v); | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool BAND_PINWHEEL_VAL(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL | ||
diff --git a/quantum/rgb_matrix/animations/colorband_sat_anim.h b/quantum/rgb_matrix/animations/colorband_sat_anim.h new file mode 100644 index 000000000..35b830af6 --- /dev/null +++ b/quantum/rgb_matrix/animations/colorband_sat_anim.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_BAND_SAT | ||
2 | RGB_MATRIX_EFFECT(BAND_SAT) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) { | ||
6 | int16_t s = hsv.s - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; | ||
7 | hsv.s = scale8(s < 0 ? 0 : s, hsv.s); | ||
8 | return hsv; | ||
9 | } | ||
10 | |||
11 | bool BAND_SAT(effect_params_t* params) { return effect_runner_i(params, &BAND_SAT_math); } | ||
12 | |||
13 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
14 | #endif // DISABLE_RGB_MATRIX_BAND_SAT | ||
diff --git a/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h b/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h new file mode 100644 index 000000000..048157aa1 --- /dev/null +++ b/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT | ||
2 | RGB_MATRIX_EFFECT(BAND_SPIRAL_SAT) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { | ||
6 | hsv.s = scale8(hsv.s + dist - time - atan2_8(dy, dx), hsv.s); | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool BAND_SPIRAL_SAT(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT | ||
diff --git a/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h b/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h new file mode 100644 index 000000000..bff2da161 --- /dev/null +++ b/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL | ||
2 | RGB_MATRIX_EFFECT(BAND_SPIRAL_VAL) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { | ||
6 | hsv.v = scale8(hsv.v + dist - time - atan2_8(dy, dx), hsv.v); | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool BAND_SPIRAL_VAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL | ||
diff --git a/quantum/rgb_matrix/animations/colorband_val_anim.h b/quantum/rgb_matrix/animations/colorband_val_anim.h new file mode 100644 index 000000000..f1aaf1d06 --- /dev/null +++ b/quantum/rgb_matrix/animations/colorband_val_anim.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_BAND_VAL | ||
2 | RGB_MATRIX_EFFECT(BAND_VAL) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) { | ||
6 | int16_t v = hsv.v - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; | ||
7 | hsv.v = scale8(v < 0 ? 0 : v, hsv.v); | ||
8 | return hsv; | ||
9 | } | ||
10 | |||
11 | bool BAND_VAL(effect_params_t* params) { return effect_runner_i(params, &BAND_VAL_math); } | ||
12 | |||
13 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
14 | #endif // DISABLE_RGB_MATRIX_BAND_VAL | ||
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..faf8598a3 --- /dev/null +++ b/quantum/rgb_matrix/animations/cycle_all_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL | ||
2 | RGB_MATRIX_EFFECT(CYCLE_ALL) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time) { | ||
6 | hsv.h = time; | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool CYCLE_ALL(effect_params_t* params) { return effect_runner_i(params, &CYCLE_ALL_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #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..cf911eb93 --- /dev/null +++ b/quantum/rgb_matrix/animations/cycle_left_right_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT | ||
2 | RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) { | ||
6 | hsv.h = g_led_config.point[i].x - time; | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool CYCLE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT | ||
diff --git a/quantum/rgb_matrix/animations/cycle_out_in_anim.h b/quantum/rgb_matrix/animations/cycle_out_in_anim.h new file mode 100644 index 000000000..d66acd4b2 --- /dev/null +++ b/quantum/rgb_matrix/animations/cycle_out_in_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_CYCLE_OUT_IN | ||
2 | RGB_MATRIX_EFFECT(CYCLE_OUT_IN) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { | ||
6 | hsv.h = 3 * dist / 2 + time; | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool CYCLE_OUT_IN(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_CYCLE_OUT_IN | ||
diff --git a/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h b/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h new file mode 100644 index 000000000..fe8396140 --- /dev/null +++ b/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL | ||
2 | RGB_MATRIX_EFFECT(CYCLE_OUT_IN_DUAL) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { | ||
6 | dx = (k_rgb_matrix_center.x / 2) - abs8(dx); | ||
7 | uint8_t dist = sqrt16(dx * dx + dy * dy); | ||
8 | hsv.h = 3 * dist + time; | ||
9 | return hsv; | ||
10 | } | ||
11 | |||
12 | bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math); } | ||
13 | |||
14 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
15 | #endif // DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL | ||
diff --git a/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h b/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h new file mode 100644 index 000000000..779988709 --- /dev/null +++ b/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_CYCLE_PINWHEEL | ||
2 | RGB_MATRIX_EFFECT(CYCLE_PINWHEEL) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { | ||
6 | hsv.h = atan2_8(dy, dx) + time; | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool CYCLE_PINWHEEL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_CYCLE_PINWHEEL | ||
diff --git a/quantum/rgb_matrix/animations/cycle_spiral_anim.h b/quantum/rgb_matrix/animations/cycle_spiral_anim.h new file mode 100644 index 000000000..80cfb0dbc --- /dev/null +++ b/quantum/rgb_matrix/animations/cycle_spiral_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_CYCLE_SPIRAL | ||
2 | RGB_MATRIX_EFFECT(CYCLE_SPIRAL) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { | ||
6 | hsv.h = dist - time - atan2_8(dy, dx); | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool CYCLE_SPIRAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_CYCLE_SPIRAL | ||
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..5016f739d --- /dev/null +++ b/quantum/rgb_matrix/animations/cycle_up_down_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN | ||
2 | RGB_MATRIX_EFFECT(CYCLE_UP_DOWN) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) { | ||
6 | hsv.h = g_led_config.point[i].y - time; | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool CYCLE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &CYCLE_UP_DOWN_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #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..1de45f8e8 --- /dev/null +++ b/quantum/rgb_matrix/animations/digital_rain_anim.h | |||
@@ -0,0 +1,75 @@ | |||
1 | #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN) | ||
2 | RGB_MATRIX_EFFECT(DIGITAL_RAIN) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | # ifndef RGB_DIGITAL_RAIN_DROPS | ||
6 | // lower the number for denser effect/wider keyboard | ||
7 | # define RGB_DIGITAL_RAIN_DROPS 24 | ||
8 | # endif | ||
9 | |||
10 | bool DIGITAL_RAIN(effect_params_t* params) { | ||
11 | // algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain | ||
12 | const uint8_t drop_ticks = 28; | ||
13 | const uint8_t pure_green_intensity = 0xd0; | ||
14 | const uint8_t max_brightness_boost = 0xc0; | ||
15 | const uint8_t max_intensity = 0xff; | ||
16 | |||
17 | static uint8_t drop = 0; | ||
18 | |||
19 | if (params->init) { | ||
20 | rgb_matrix_set_color_all(0, 0, 0); | ||
21 | memset(g_rgb_frame_buffer, 0, sizeof(g_rgb_frame_buffer)); | ||
22 | drop = 0; | ||
23 | } | ||
24 | |||
25 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
26 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
27 | if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) { | ||
28 | // top row, pixels have just fallen and we're | ||
29 | // making a new rain drop in this column | ||
30 | g_rgb_frame_buffer[row][col] = max_intensity; | ||
31 | } else if (g_rgb_frame_buffer[row][col] > 0 && g_rgb_frame_buffer[row][col] < max_intensity) { | ||
32 | // neither fully bright nor dark, decay it | ||
33 | g_rgb_frame_buffer[row][col]--; | ||
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 (g_rgb_frame_buffer[row][col] > pure_green_intensity) { | ||
42 | const uint8_t boost = (uint8_t)((uint16_t)max_brightness_boost * (g_rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity)); | ||
43 | rgb_matrix_set_color(led[0], boost, max_intensity, boost); | ||
44 | } else { | ||
45 | const uint8_t green = (uint8_t)((uint16_t)max_intensity * g_rgb_frame_buffer[row][col] / pure_green_intensity); | ||
46 | rgb_matrix_set_color(led[0], 0, green, 0); | ||
47 | } | ||
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 && g_rgb_frame_buffer[row][col] == max_intensity) { | ||
59 | g_rgb_frame_buffer[row][col]--; | ||
60 | } | ||
61 | // check if the pixel above is bright | ||
62 | if (g_rgb_frame_buffer[row - 1][col] == max_intensity) { | ||
63 | // allow old bright pixel to decay | ||
64 | g_rgb_frame_buffer[row - 1][col]--; | ||
65 | // make this pixel bright | ||
66 | g_rgb_frame_buffer[row][col] = max_intensity; | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | return false; | ||
72 | } | ||
73 | |||
74 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
75 | #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(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..ce9487168 --- /dev/null +++ b/quantum/rgb_matrix/animations/dual_beacon_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON | ||
2 | RGB_MATRIX_EFFECT(DUAL_BEACON) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { | ||
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; | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool DUAL_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #endif // DISABLE_RGB_MATRIX_DUAL_BEACON | ||
diff --git a/quantum/rgb_matrix/animations/gradient_left_right_anim.h b/quantum/rgb_matrix/animations/gradient_left_right_anim.h new file mode 100644 index 000000000..53dfd04e2 --- /dev/null +++ b/quantum/rgb_matrix/animations/gradient_left_right_anim.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT | ||
2 | RGB_MATRIX_EFFECT(GRADIENT_LEFT_RIGHT) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | bool GRADIENT_LEFT_RIGHT(effect_params_t* params) { | ||
6 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
7 | |||
8 | HSV hsv = rgb_matrix_config.hsv; | ||
9 | uint8_t scale = scale8(64, rgb_matrix_config.speed); | ||
10 | for (uint8_t i = led_min; i < led_max; i++) { | ||
11 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
12 | // The x range will be 0..224, map this to 0..7 | ||
13 | // Relies on hue being 8-bit and wrapping | ||
14 | hsv.h = rgb_matrix_config.hsv.h + (scale * g_led_config.point[i].x >> 5); | ||
15 | RGB rgb = rgb_matrix_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 // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
22 | #endif // DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT | ||
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..7e0d2898c --- /dev/null +++ b/quantum/rgb_matrix/animations/gradient_up_down_anim.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN | ||
2 | RGB_MATRIX_EFFECT(GRADIENT_UP_DOWN) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | bool GRADIENT_UP_DOWN(effect_params_t* params) { | ||
6 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
7 | |||
8 | HSV hsv = rgb_matrix_config.hsv; | ||
9 | uint8_t scale = scale8(64, rgb_matrix_config.speed); | ||
10 | for (uint8_t i = led_min; i < led_max; i++) { | ||
11 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
12 | // The y range will be 0..64, map this to 0..4 | ||
13 | // Relies on hue being 8-bit and wrapping | ||
14 | hsv.h = rgb_matrix_config.hsv.h + scale * (g_led_config.point[i].y >> 4); | ||
15 | RGB rgb = rgb_matrix_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 // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
22 | #endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN | ||
diff --git a/quantum/rgb_matrix/animations/hue_breathing_anim.h b/quantum/rgb_matrix/animations/hue_breathing_anim.h new file mode 100644 index 000000000..54dea958a --- /dev/null +++ b/quantum/rgb_matrix/animations/hue_breathing_anim.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_HUE_BREATHING | ||
2 | RGB_MATRIX_EFFECT(HUE_BREATHING) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | // Change huedelta to adjust range of hue change. 0-255. | ||
6 | // Hue Breathing - All LED's light up | ||
7 | bool HUE_BREATHING(effect_params_t* params) { | ||
8 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
9 | uint8_t huedelta = 12; | ||
10 | HSV hsv = rgb_matrix_config.hsv; | ||
11 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); | ||
12 | hsv.h = hsv.h + scale8(abs8(sin8(time) - 128) * 2, huedelta); | ||
13 | RGB rgb = hsv_to_rgb(hsv); | ||
14 | for (uint8_t i = led_min; i < led_max; i++) { | ||
15 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
16 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
17 | } | ||
18 | return led_max < DRIVER_LED_TOTAL; | ||
19 | } | ||
20 | |||
21 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
22 | #endif // DISABLE_RGB_HUE_BREATHING | ||
diff --git a/quantum/rgb_matrix/animations/hue_pendulum_anim.h b/quantum/rgb_matrix/animations/hue_pendulum_anim.h new file mode 100644 index 000000000..2d8d36174 --- /dev/null +++ b/quantum/rgb_matrix/animations/hue_pendulum_anim.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_HUE_PENDULUM | ||
2 | RGB_MATRIX_EFFECT(HUE_PENDULUM) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | // Change huedelta to adjust range of hue change. 0-255. | ||
6 | // Looks better with a low value and slow speed for subtle change. | ||
7 | // Hue Pendulum - color changes in a wave to the right before reversing direction | ||
8 | static HSV HUE_PENDULUM_math(HSV hsv, uint8_t i, uint8_t time) { | ||
9 | uint8_t huedelta = 12; | ||
10 | hsv.h = hsv.h + scale8(abs8(sin8(time) + (g_led_config.point[i].x) - 128) * 2, huedelta); | ||
11 | return hsv; | ||
12 | } | ||
13 | |||
14 | bool HUE_PENDULUM(effect_params_t* params) { return effect_runner_i(params, &HUE_PENDULUM_math); } | ||
15 | |||
16 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
17 | #endif // DISABLE_RGB_HUE_PENDULUM | ||
diff --git a/quantum/rgb_matrix/animations/hue_wave_anim.h b/quantum/rgb_matrix/animations/hue_wave_anim.h new file mode 100644 index 000000000..fd9026fc9 --- /dev/null +++ b/quantum/rgb_matrix/animations/hue_wave_anim.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_HUE_WAVE | ||
2 | RGB_MATRIX_EFFECT(HUE_WAVE) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | // Change huedelta to adjust range of hue change. 0-255. | ||
6 | // Looks better with a low value and slow speed for subtle change. | ||
7 | // Hue Wave - color changes in a wave to the right | ||
8 | static HSV HUE_WAVE_math(HSV hsv, uint8_t i, uint8_t time) { | ||
9 | uint8_t huedelta = 24; | ||
10 | hsv.h = hsv.h + scale8(abs8(g_led_config.point[i].x - time), huedelta); | ||
11 | return hsv; | ||
12 | } | ||
13 | |||
14 | bool HUE_WAVE(effect_params_t* params) { return effect_runner_i(params, &HUE_WAVE_math); } | ||
15 | |||
16 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
17 | #endif // DISABLE_RGB_HUE_WAVE | ||
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..a17e954b1 --- /dev/null +++ b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS | ||
2 | RGB_MATRIX_EFFECT(JELLYBEAN_RAINDROPS) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static void jellybean_raindrops_set_color(int i, effect_params_t* params) { | ||
6 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; | ||
7 | HSV hsv = {rand() & 0xFF, qadd8(rand() & 0x7F, 0x80), rgb_matrix_config.hsv.v}; | ||
8 | RGB rgb = rgb_matrix_hsv_to_rgb(hsv); | ||
9 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
10 | } | ||
11 | |||
12 | bool JELLYBEAN_RAINDROPS(effect_params_t* params) { | ||
13 | if (!params->init) { | ||
14 | // Change one LED every tick, make sure speed is not 0 | ||
15 | if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) { | ||
16 | jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL, params); | ||
17 | } | ||
18 | return false; | ||
19 | } | ||
20 | |||
21 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
22 | for (int i = led_min; i < led_max; i++) { | ||
23 | jellybean_raindrops_set_color(i, params); | ||
24 | } | ||
25 | return led_max < DRIVER_LED_TOTAL; | ||
26 | } | ||
27 | |||
28 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
29 | #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..977261182 --- /dev/null +++ b/quantum/rgb_matrix/animations/rainbow_beacon_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON | ||
2 | RGB_MATRIX_EFFECT(RAINBOW_BEACON) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { | ||
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; | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool RAINBOW_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #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..e51e7b251 --- /dev/null +++ b/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON | ||
2 | RGB_MATRIX_EFFECT(RAINBOW_MOVING_CHEVRON) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { | ||
6 | hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #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..1cd4ed2ac --- /dev/null +++ b/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS | ||
2 | RGB_MATRIX_EFFECT(RAINBOW_PINWHEELS) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static HSV RAINBOW_PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { | ||
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; | ||
7 | return hsv; | ||
8 | } | ||
9 | |||
10 | bool RAINBOW_PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); } | ||
11 | |||
12 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | #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..38359cdca --- /dev/null +++ b/quantum/rgb_matrix/animations/raindrops_anim.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef DISABLE_RGB_MATRIX_RAINDROPS | ||
2 | RGB_MATRIX_EFFECT(RAINDROPS) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | static void raindrops_set_color(int i, effect_params_t* params) { | ||
6 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; | ||
7 | HSV hsv = {0, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v}; | ||
8 | |||
9 | // Take the shortest path between hues | ||
10 | int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4; | ||
11 | if (deltaH > 127) { | ||
12 | deltaH -= 256; | ||
13 | } else if (deltaH < -127) { | ||
14 | deltaH += 256; | ||
15 | } | ||
16 | |||
17 | hsv.h = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03)); | ||
18 | RGB rgb = rgb_matrix_hsv_to_rgb(hsv); | ||
19 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
20 | } | ||
21 | |||
22 | bool RAINDROPS(effect_params_t* params) { | ||
23 | if (!params->init) { | ||
24 | // Change one LED every tick, make sure speed is not 0 | ||
25 | if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) { | ||
26 | raindrops_set_color(rand() % DRIVER_LED_TOTAL, params); | ||
27 | } | ||
28 | return false; | ||
29 | } | ||
30 | |||
31 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
32 | for (int i = led_min; i < led_max; i++) { | ||
33 | raindrops_set_color(i, params); | ||
34 | } | ||
35 | return led_max < DRIVER_LED_TOTAL; | ||
36 | } | ||
37 | |||
38 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
39 | #endif // DISABLE_RGB_MATRIX_RAINDROPS | ||
diff --git a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc new file mode 100644 index 000000000..302ad79c0 --- /dev/null +++ b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc | |||
@@ -0,0 +1,37 @@ | |||
1 | // Add your new core rgb matrix effect here, order determines enum order | ||
2 | #include "solid_color_anim.h" | ||
3 | #include "alpha_mods_anim.h" | ||
4 | #include "gradient_up_down_anim.h" | ||
5 | #include "gradient_left_right_anim.h" | ||
6 | #include "breathing_anim.h" | ||
7 | #include "colorband_sat_anim.h" | ||
8 | #include "colorband_val_anim.h" | ||
9 | #include "colorband_pinwheel_sat_anim.h" | ||
10 | #include "colorband_pinwheel_val_anim.h" | ||
11 | #include "colorband_spiral_sat_anim.h" | ||
12 | #include "colorband_spiral_val_anim.h" | ||
13 | #include "cycle_all_anim.h" | ||
14 | #include "cycle_left_right_anim.h" | ||
15 | #include "cycle_up_down_anim.h" | ||
16 | #include "rainbow_moving_chevron_anim.h" | ||
17 | #include "cycle_out_in_anim.h" | ||
18 | #include "cycle_out_in_dual_anim.h" | ||
19 | #include "cycle_pinwheel_anim.h" | ||
20 | #include "cycle_spiral_anim.h" | ||
21 | #include "dual_beacon_anim.h" | ||
22 | #include "rainbow_beacon_anim.h" | ||
23 | #include "rainbow_pinwheels_anim.h" | ||
24 | #include "raindrops_anim.h" | ||
25 | #include "jellybean_raindrops_anim.h" | ||
26 | #include "hue_breathing_anim.h" | ||
27 | #include "hue_pendulum_anim.h" | ||
28 | #include "hue_wave_anim.h" | ||
29 | #include "typing_heatmap_anim.h" | ||
30 | #include "digital_rain_anim.h" | ||
31 | #include "solid_reactive_simple_anim.h" | ||
32 | #include "solid_reactive_anim.h" | ||
33 | #include "solid_reactive_wide.h" | ||
34 | #include "solid_reactive_cross.h" | ||
35 | #include "solid_reactive_nexus.h" | ||
36 | #include "splash_anim.h" | ||
37 | #include "solid_splash_anim.h" | ||
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h new file mode 100644 index 000000000..4867609c8 --- /dev/null +++ b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #pragma once | ||
2 | |||
3 | typedef HSV (*dx_dy_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t time); | ||
4 | |||
5 | bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) { | ||
6 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
7 | |||
8 | uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2); | ||
9 | for (uint8_t i = led_min; i < led_max; i++) { | ||
10 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
11 | int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x; | ||
12 | int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y; | ||
13 | RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time)); | ||
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/animations/runners/effect_runner_dx_dy_dist.h b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h new file mode 100644 index 000000000..9545b418d --- /dev/null +++ b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #pragma once | ||
2 | |||
3 | typedef HSV (*dx_dy_dist_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time); | ||
4 | |||
5 | bool 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 | uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2); | ||
9 | for (uint8_t i = led_min; i < led_max; i++) { | ||
10 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
11 | int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x; | ||
12 | int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y; | ||
13 | uint8_t dist = sqrt16(dx * dx + dy * dy); | ||
14 | RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, dist, time)); | ||
15 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
16 | } | ||
17 | return led_max < DRIVER_LED_TOTAL; | ||
18 | } | ||
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_i.h b/quantum/rgb_matrix/animations/runners/effect_runner_i.h new file mode 100644 index 000000000..95bfe8b39 --- /dev/null +++ b/quantum/rgb_matrix/animations/runners/effect_runner_i.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #pragma once | ||
2 | |||
3 | typedef HSV (*i_f)(HSV hsv, uint8_t i, uint8_t time); | ||
4 | |||
5 | bool effect_runner_i(effect_params_t* params, i_f effect_func) { | ||
6 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
7 | |||
8 | uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4); | ||
9 | for (uint8_t i = led_min; i < led_max; i++) { | ||
10 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
11 | RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time)); | ||
12 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
13 | } | ||
14 | return led_max < DRIVER_LED_TOTAL; | ||
15 | } | ||
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h new file mode 100644 index 000000000..8485b61f3 --- /dev/null +++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
4 | |||
5 | typedef HSV (*reactive_f)(HSV hsv, uint16_t offset); | ||
6 | |||
7 | bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) { | ||
8 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
9 | |||
10 | uint16_t max_tick = 65535 / rgb_matrix_config.speed; | ||
11 | for (uint8_t i = led_min; i < led_max; i++) { | ||
12 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
13 | uint16_t tick = max_tick; | ||
14 | // Reverse search to find most recent key hit | ||
15 | for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) { | ||
16 | if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) { | ||
17 | tick = g_last_hit_tracker.tick[j]; | ||
18 | break; | ||
19 | } | ||
20 | } | ||
21 | |||
22 | uint16_t offset = scale16by8(tick, rgb_matrix_config.speed); | ||
23 | RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, offset)); | ||
24 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
25 | } | ||
26 | return led_max < DRIVER_LED_TOTAL; | ||
27 | } | ||
28 | |||
29 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | ||
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h new file mode 100644 index 000000000..5c69d0fbb --- /dev/null +++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
4 | |||
5 | typedef HSV (*reactive_splash_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick); | ||
6 | |||
7 | bool 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 | uint8_t count = g_last_hit_tracker.count; | ||
11 | for (uint8_t i = led_min; i < led_max; i++) { | ||
12 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
13 | HSV hsv = rgb_matrix_config.hsv; | ||
14 | hsv.v = 0; | ||
15 | for (uint8_t j = start; j < count; j++) { | ||
16 | int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; | ||
17 | int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; | ||
18 | uint8_t dist = sqrt16(dx * dx + dy * dy); | ||
19 | uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed); | ||
20 | hsv = effect_func(hsv, dx, dy, dist, tick); | ||
21 | } | ||
22 | hsv.v = scale8(hsv.v, rgb_matrix_config.hsv.v); | ||
23 | RGB rgb = rgb_matrix_hsv_to_rgb(hsv); | ||
24 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
25 | } | ||
26 | return led_max < DRIVER_LED_TOTAL; | ||
27 | } | ||
28 | |||
29 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | ||
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h b/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h new file mode 100644 index 000000000..02351de51 --- /dev/null +++ b/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #pragma once | ||
2 | |||
3 | typedef HSV (*sin_cos_i_f)(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time); | ||
4 | |||
5 | bool 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 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4); | ||
9 | int8_t cos_value = cos8(time) - 128; | ||
10 | int8_t sin_value = sin8(time) - 128; | ||
11 | for (uint8_t i = led_min; i < led_max; i++) { | ||
12 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
13 | RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time)); | ||
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/animations/runners/rgb_matrix_runners.inc b/quantum/rgb_matrix/animations/runners/rgb_matrix_runners.inc new file mode 100644 index 000000000..c09022bb0 --- /dev/null +++ b/quantum/rgb_matrix/animations/runners/rgb_matrix_runners.inc | |||
@@ -0,0 +1,6 @@ | |||
1 | #include "effect_runner_dx_dy_dist.h" | ||
2 | #include "effect_runner_dx_dy.h" | ||
3 | #include "effect_runner_i.h" | ||
4 | #include "effect_runner_sin_cos_i.h" | ||
5 | #include "effect_runner_reactive.h" | ||
6 | #include "effect_runner_reactive_splash.h" | ||
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..79d63cf13 --- /dev/null +++ b/quantum/rgb_matrix/animations/solid_color_anim.h | |||
@@ -0,0 +1,15 @@ | |||
1 | RGB_MATRIX_EFFECT(SOLID_COLOR) | ||
2 | #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
3 | |||
4 | bool SOLID_COLOR(effect_params_t* params) { | ||
5 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
6 | |||
7 | RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv); | ||
8 | for (uint8_t i = led_min; i < led_max; i++) { | ||
9 | RGB_MATRIX_TEST_LED_FLAGS(); | ||
10 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
11 | } | ||
12 | return led_max < DRIVER_LED_TOTAL; | ||
13 | } | ||
14 | |||
15 | #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 new file mode 100644 index 000000000..d45bb961b --- /dev/null +++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
2 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE | ||
3 | RGB_MATRIX_EFFECT(SOLID_REACTIVE) | ||
4 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
5 | |||
6 | static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) { | ||
7 | hsv.h += qsub8(130, offset); | ||
8 | return hsv; | ||
9 | } | ||
10 | |||
11 | bool SOLID_REACTIVE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_math); } | ||
12 | |||
13 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
14 | # endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE | ||
15 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | ||
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..f76c68e8c --- /dev/null +++ b/quantum/rgb_matrix/animations/solid_reactive_cross.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
2 | # if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) | ||
3 | |||
4 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS | ||
5 | RGB_MATRIX_EFFECT(SOLID_REACTIVE_CROSS) | ||
6 | # endif | ||
7 | |||
8 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS | ||
9 | RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS) | ||
10 | # endif | ||
11 | |||
12 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | |||
14 | static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { | ||
15 | uint16_t effect = tick + dist; | ||
16 | dx = dx < 0 ? dx * -1 : dx; | ||
17 | dy = dy < 0 ? dy * -1 : dy; | ||
18 | dx = dx * 16 > 255 ? 255 : dx * 16; | ||
19 | dy = dy * 16 > 255 ? 255 : dy * 16; | ||
20 | effect += dx > dy ? dy : dx; | ||
21 | if (effect > 255) effect = 255; | ||
22 | hsv.v = qadd8(hsv.v, 255 - effect); | ||
23 | return hsv; | ||
24 | } | ||
25 | |||
26 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS | ||
27 | bool SOLID_REACTIVE_CROSS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); } | ||
28 | # endif | ||
29 | |||
30 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS | ||
31 | bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); } | ||
32 | # endif | ||
33 | |||
34 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
35 | # endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) | ||
36 | #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..17f94e3c1 --- /dev/null +++ b/quantum/rgb_matrix/animations/solid_reactive_nexus.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
2 | # if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) | ||
3 | |||
4 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS | ||
5 | RGB_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS) | ||
6 | # endif | ||
7 | |||
8 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS | ||
9 | RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS) | ||
10 | # endif | ||
11 | |||
12 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | |||
14 | static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { | ||
15 | uint16_t effect = tick - dist; | ||
16 | if (effect > 255) effect = 255; | ||
17 | if (dist > 72) effect = 255; | ||
18 | if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255; | ||
19 | hsv.v = qadd8(hsv.v, 255 - effect); | ||
20 | hsv.h = rgb_matrix_config.hsv.h + dy / 4; | ||
21 | return hsv; | ||
22 | } | ||
23 | |||
24 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS | ||
25 | bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); } | ||
26 | # endif | ||
27 | |||
28 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS | ||
29 | bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); } | ||
30 | # endif | ||
31 | |||
32 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
33 | # endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) | ||
34 | #endif // 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..12eb248cc --- /dev/null +++ b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
2 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE | ||
3 | RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) | ||
4 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
5 | |||
6 | static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) { | ||
7 | hsv.v = scale8(255 - offset, hsv.v); | ||
8 | return hsv; | ||
9 | } | ||
10 | |||
11 | bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); } | ||
12 | |||
13 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
14 | # endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE | ||
15 | #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..1cc4dca72 --- /dev/null +++ b/quantum/rgb_matrix/animations/solid_reactive_wide.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
2 | # if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) | ||
3 | |||
4 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE | ||
5 | RGB_MATRIX_EFFECT(SOLID_REACTIVE_WIDE) | ||
6 | # endif | ||
7 | |||
8 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE | ||
9 | RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE) | ||
10 | # endif | ||
11 | |||
12 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | |||
14 | static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { | ||
15 | uint16_t effect = tick + dist * 5; | ||
16 | if (effect > 255) effect = 255; | ||
17 | hsv.v = qadd8(hsv.v, 255 - effect); | ||
18 | return hsv; | ||
19 | } | ||
20 | |||
21 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE | ||
22 | bool SOLID_REACTIVE_WIDE(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); } | ||
23 | # endif | ||
24 | |||
25 | # ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE | ||
26 | bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); } | ||
27 | # endif | ||
28 | |||
29 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
30 | # endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) | ||
31 | #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..99efb4996 --- /dev/null +++ b/quantum/rgb_matrix/animations/solid_splash_anim.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
2 | # if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) | ||
3 | |||
4 | # ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH | ||
5 | RGB_MATRIX_EFFECT(SOLID_SPLASH) | ||
6 | # endif | ||
7 | |||
8 | # ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH | ||
9 | RGB_MATRIX_EFFECT(SOLID_MULTISPLASH) | ||
10 | # endif | ||
11 | |||
12 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | |||
14 | HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { | ||
15 | uint16_t effect = tick - dist; | ||
16 | if (effect > 255) effect = 255; | ||
17 | hsv.v = qadd8(hsv.v, 255 - effect); | ||
18 | return hsv; | ||
19 | } | ||
20 | |||
21 | # ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH | ||
22 | bool SOLID_SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); } | ||
23 | # endif | ||
24 | |||
25 | # ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH | ||
26 | bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); } | ||
27 | # endif | ||
28 | |||
29 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
30 | # endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH) | ||
31 | #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..1415bcc0f --- /dev/null +++ b/quantum/rgb_matrix/animations/splash_anim.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | ||
2 | # if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) | ||
3 | |||
4 | # ifndef DISABLE_RGB_MATRIX_SPLASH | ||
5 | RGB_MATRIX_EFFECT(SPLASH) | ||
6 | # endif | ||
7 | |||
8 | # ifndef DISABLE_RGB_MATRIX_MULTISPLASH | ||
9 | RGB_MATRIX_EFFECT(MULTISPLASH) | ||
10 | # endif | ||
11 | |||
12 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
13 | |||
14 | HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { | ||
15 | uint16_t effect = tick - dist; | ||
16 | if (effect > 255) effect = 255; | ||
17 | hsv.h += effect; | ||
18 | hsv.v = qadd8(hsv.v, 255 - effect); | ||
19 | return hsv; | ||
20 | } | ||
21 | |||
22 | # ifndef DISABLE_RGB_MATRIX_SPLASH | ||
23 | bool SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); } | ||
24 | # endif | ||
25 | |||
26 | # ifndef DISABLE_RGB_MATRIX_MULTISPLASH | ||
27 | bool MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SPLASH_math); } | ||
28 | # endif | ||
29 | |||
30 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
31 | # endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) | ||
32 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | ||
diff --git a/quantum/rgb_matrix/animations/typing_heatmap_anim.h b/quantum/rgb_matrix/animations/typing_heatmap_anim.h new file mode 100644 index 000000000..e7dda11a2 --- /dev/null +++ b/quantum/rgb_matrix/animations/typing_heatmap_anim.h | |||
@@ -0,0 +1,86 @@ | |||
1 | #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) | ||
2 | RGB_MATRIX_EFFECT(TYPING_HEATMAP) | ||
3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
4 | |||
5 | # ifndef RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS | ||
6 | # define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 25 | ||
7 | # endif | ||
8 | |||
9 | void process_rgb_matrix_typing_heatmap(uint8_t row, uint8_t col) { | ||
10 | uint8_t m_row = row - 1; | ||
11 | uint8_t p_row = row + 1; | ||
12 | uint8_t m_col = col - 1; | ||
13 | uint8_t p_col = col + 1; | ||
14 | |||
15 | if (m_col < col) g_rgb_frame_buffer[row][m_col] = qadd8(g_rgb_frame_buffer[row][m_col], 16); | ||
16 | g_rgb_frame_buffer[row][col] = qadd8(g_rgb_frame_buffer[row][col], 32); | ||
17 | if (p_col < MATRIX_COLS) g_rgb_frame_buffer[row][p_col] = qadd8(g_rgb_frame_buffer[row][p_col], 16); | ||
18 | |||
19 | if (p_row < MATRIX_ROWS) { | ||
20 | if (m_col < col) g_rgb_frame_buffer[p_row][m_col] = qadd8(g_rgb_frame_buffer[p_row][m_col], 13); | ||
21 | g_rgb_frame_buffer[p_row][col] = qadd8(g_rgb_frame_buffer[p_row][col], 16); | ||
22 | if (p_col < MATRIX_COLS) g_rgb_frame_buffer[p_row][p_col] = qadd8(g_rgb_frame_buffer[p_row][p_col], 13); | ||
23 | } | ||
24 | |||
25 | if (m_row < row) { | ||
26 | if (m_col < col) g_rgb_frame_buffer[m_row][m_col] = qadd8(g_rgb_frame_buffer[m_row][m_col], 13); | ||
27 | g_rgb_frame_buffer[m_row][col] = qadd8(g_rgb_frame_buffer[m_row][col], 16); | ||
28 | if (p_col < MATRIX_COLS) g_rgb_frame_buffer[m_row][p_col] = qadd8(g_rgb_frame_buffer[m_row][p_col], 13); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | // A timer to track the last time we decremented all heatmap values. | ||
33 | static uint16_t heatmap_decrease_timer; | ||
34 | // Whether we should decrement the heatmap values during the next update. | ||
35 | static bool decrease_heatmap_values; | ||
36 | |||
37 | bool TYPING_HEATMAP(effect_params_t* params) { | ||
38 | // Modified version of RGB_MATRIX_USE_LIMITS to work off of matrix row / col size | ||
39 | uint8_t led_min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; | ||
40 | uint8_t led_max = led_min + RGB_MATRIX_LED_PROCESS_LIMIT; | ||
41 | if (led_max > sizeof(g_rgb_frame_buffer)) led_max = sizeof(g_rgb_frame_buffer); | ||
42 | |||
43 | if (params->init) { | ||
44 | rgb_matrix_set_color_all(0, 0, 0); | ||
45 | memset(g_rgb_frame_buffer, 0, sizeof g_rgb_frame_buffer); | ||
46 | } | ||
47 | |||
48 | // The heatmap animation might run in several iterations depending on | ||
49 | // `RGB_MATRIX_LED_PROCESS_LIMIT`, therefore we only want to update the | ||
50 | // timer when the animation starts. | ||
51 | if (params->iter == 0) { | ||
52 | decrease_heatmap_values = timer_elapsed(heatmap_decrease_timer) >= RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS; | ||
53 | |||
54 | // Restart the timer if we are going to decrease the heatmap this frame. | ||
55 | if (decrease_heatmap_values) { | ||
56 | heatmap_decrease_timer = timer_read(); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | // Render heatmap & decrease | ||
61 | for (int i = led_min; i < led_max; i++) { | ||
62 | uint8_t row = i % MATRIX_ROWS; | ||
63 | uint8_t col = i / MATRIX_ROWS; | ||
64 | uint8_t val = g_rgb_frame_buffer[row][col]; | ||
65 | |||
66 | // set the pixel colour | ||
67 | uint8_t led[LED_HITS_TO_REMEMBER]; | ||
68 | uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led); | ||
69 | for (uint8_t j = 0; j < led_count; ++j) { | ||
70 | if (!HAS_ANY_FLAGS(g_led_config.flags[led[j]], params->flags)) continue; | ||
71 | |||
72 | HSV hsv = {170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v)}; | ||
73 | RGB rgb = rgb_matrix_hsv_to_rgb(hsv); | ||
74 | rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b); | ||
75 | } | ||
76 | |||
77 | if (decrease_heatmap_values) { | ||
78 | g_rgb_frame_buffer[row][col] = qsub8(val, 1); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | return led_max < sizeof(g_rgb_frame_buffer); | ||
83 | } | ||
84 | |||
85 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
86 | #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) | ||