aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix_animations/solid_reactive_cross.h
diff options
context:
space:
mode:
authorRyan Caltabiano <rcalt2vt@gmail.com>2019-05-19 08:34:25 -0500
committerDrashna Jaelre <drashna@live.com>2019-05-19 15:23:01 -0700
commitc9a7161d934979770792ff1e91ccfcc3508d240b (patch)
tree6d31cfad88b4124a0d3e3b10ed2bf4c404cf7064 /quantum/rgb_matrix_animations/solid_reactive_cross.h
parente7af23788fbcff8e5bea896b458fb8da1639e66d (diff)
downloadqmk_firmware-c9a7161d934979770792ff1e91ccfcc3508d240b.tar.gz
qmk_firmware-c9a7161d934979770792ff1e91ccfcc3508d240b.zip
Reduce rgb matrix firmware size
Diffstat (limited to 'quantum/rgb_matrix_animations/solid_reactive_cross.h')
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_cross.h50
1 files changed, 17 insertions, 33 deletions
diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h
index 62210f82d..99f22c694 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_cross.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h
@@ -11,45 +11,29 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS)
11 11
12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 12#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13 13
14static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_params_t* params) { 14static void SOLID_REACTIVE_CROSS_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
15 RGB_MATRIX_USE_LIMITS(led_min, led_max); 15 uint16_t effect = tick + dist;
16 16 dx = dx < 0 ? dx * -1 : dx;
17 HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; 17 dy = dy < 0 ? dy * -1 : dy;
18 uint8_t count = g_last_hit_tracker.count; 18 dx = dx * 16 > 255 ? 255 : dx * 16;
19 for (uint8_t i = led_min; i < led_max; i++) { 19 dy = dy * 16 > 255 ? 255 : dy * 16;
20 hsv.v = 0; 20 effect += dx > dy ? dy : dx;
21 for (uint8_t j = start; j < count; j++) { 21 if (effect > 255)
22 RGB_MATRIX_TEST_LED_FLAGS();
23 int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
24 int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
25 uint8_t dist = sqrt16(dx * dx + dy * dy);
26 int16_t dist2 = 16;
27 uint8_t dist3;
28 uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist;
29 dx = dx < 0 ? dx * -1 : dx;
30 dy = dy < 0 ? dy * -1 : dy;
31 dx = dx * dist2 > 255 ? 255 : dx * dist2;
32 dy = dy * dist2 > 255 ? 255 : dy * dist2;
33 dist3 = dx > dy ? dy : dx;
34 effect += dist3;
35 if (effect > 255)
36 effect = 255; 22 effect = 255;
37 hsv.v = qadd8(hsv.v, 255 - effect); 23 hsv->v = qadd8(hsv->v, 255 - effect);
38 }
39 hsv.v = scale8(hsv.v, rgb_matrix_config.val);
40 RGB rgb = hsv_to_rgb(hsv);
41 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
42 }
43 return led_max < DRIVER_LED_TOTAL;
44} 24}
45 25
46bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { 26#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
47 return rgb_matrix_solid_reactive_multicross_range(0, params); 27bool SOLID_REACTIVE_CROSS(effect_params_t* params) {
28 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math);
48} 29}
30#endif
49 31
50bool SOLID_REACTIVE_CROSS(effect_params_t* params) { 32#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
51 return rgb_matrix_solid_reactive_multicross_range(qsub8(g_last_hit_tracker.count, 1), params); 33bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) {
34 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math);
52} 35}
36#endif
53 37
54#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 38#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
55#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) 39#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)