diff options
author | Ryan Caltabiano <rcalt2vt@gmail.com> | 2019-05-19 23:12:29 -0500 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-07-12 07:39:35 -0700 |
commit | cf215487ba35c6754cd1c52bb900a46bb52ed3a3 (patch) | |
tree | 1eb5341becef835bb2ca34a7a3066fe8e26d803c /quantum/rgb_matrix_animations | |
parent | e717dcaa09143615ae0b46bf625621f67a7b55ce (diff) |
Switching rgb_config_t to use HSV struct
Diffstat (limited to 'quantum/rgb_matrix_animations')
31 files changed, 88 insertions, 66 deletions
diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h index 0fee19aefc..8df3356f61 100644 --- a/quantum/rgb_matrix_animations/alpha_mods_anim.h +++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h @@ -6,7 +6,7 @@ RGB_MATRIX_EFFECT(ALPHAS_MODS) bool ALPHAS_MODS(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); - HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val }; + HSV hsv = rgb_matrix_config.hsv; RGB rgb1 = hsv_to_rgb(hsv); hsv.h += rgb_matrix_config.speed; RGB rgb2 = hsv_to_rgb(hsv); diff --git a/quantum/rgb_matrix_animations/breathing_anim.h b/quantum/rgb_matrix_animations/breathing_anim.h index c357b53031..0af7b42cf3 100644 --- a/quantum/rgb_matrix_animations/breathing_anim.h +++ b/quantum/rgb_matrix_animations/breathing_anim.h @@ -5,9 +5,9 @@ RGB_MATRIX_EFFECT(BREATHING) bool BREATHING(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); + HSV hsv = rgb_matrix_config.hsv; uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8); - uint8_t val = scale8(abs8(sin8(time) - 128) * 2, rgb_matrix_config.val); - HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, val }; + hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); RGB rgb = hsv_to_rgb(hsv); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); diff --git a/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h b/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h index 3739cde1f6..4585c52716 100644 --- a/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h +++ b/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(BAND_PINWHEEL_SAT) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void BAND_PINWHEEL_SAT_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) { - hsv->s = scale8(rgb_matrix_config.sat - time - atan2_8(dy, dx) * 3, rgb_matrix_config.sat); +static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { + hsv.s = scale8(hsv.s - time - atan2_8(dy, dx) * 3, hsv.s); + return hsv; } bool BAND_PINWHEEL_SAT(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h b/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h index 6e5871d7ec..5cdb873489 100644 --- a/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h +++ b/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(BAND_PINWHEEL_VAL) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void BAND_PINWHEEL_VAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) { - hsv->v = scale8(rgb_matrix_config.val - time - atan2_8(dy, dx) * 3, rgb_matrix_config.val); +static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { + hsv.v = scale8(hsv.v - time - atan2_8(dy, dx) * 3, hsv.v); + return hsv; } bool BAND_PINWHEEL_VAL(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/colorband_sat_anim.h b/quantum/rgb_matrix_animations/colorband_sat_anim.h index bfa1085cb1..a5175f1cd9 100644 --- a/quantum/rgb_matrix_animations/colorband_sat_anim.h +++ b/quantum/rgb_matrix_animations/colorband_sat_anim.h @@ -2,9 +2,10 @@ RGB_MATRIX_EFFECT(BAND_SAT) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void BAND_SAT_math(HSV* hsv, uint8_t i, uint8_t time) { - int16_t s = rgb_matrix_config.sat - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; - hsv->s = scale8(s < 0 ? 0 : s, rgb_matrix_config.sat); +static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) { + int16_t s = hsv.s - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; + hsv.s = scale8(s < 0 ? 0 : s, hsv.s); + return hsv; } bool BAND_SAT(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h b/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h index 7db01c5f9e..096c675de8 100644 --- a/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h +++ b/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(BAND_SPIRAL_SAT) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void BAND_SPIRAL_SAT_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { - hsv->s = scale8(rgb_matrix_config.sat + dist - time - atan2_8(dy, dx), rgb_matrix_config.sat); +static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { + hsv.s = scale8(hsv.s + dist - time - atan2_8(dy, dx), hsv.s); + return hsv; } bool BAND_SPIRAL_SAT(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h b/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h index a16f8e2cea..1d4cc0c84f 100644 --- a/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h +++ b/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(BAND_SPIRAL_VAL) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void BAND_SPIRAL_VAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { - hsv->v = scale8(rgb_matrix_config.val + dist - time - atan2_8(dy, dx), rgb_matrix_config.val); +static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { + hsv.v = scale8(hsv.v + dist - time - atan2_8(dy, dx), hsv.v); + return hsv; } bool BAND_SPIRAL_VAL(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/colorband_val_anim.h b/quantum/rgb_matrix_animations/colorband_val_anim.h index 4b76924db9..de0bbb4715 100644 --- a/quantum/rgb_matrix_animations/colorband_val_anim.h +++ b/quantum/rgb_matrix_animations/colorband_val_anim.h @@ -2,9 +2,10 @@ RGB_MATRIX_EFFECT(BAND_VAL) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void BAND_VAL_math(HSV* hsv, uint8_t i, uint8_t time) { - int16_t v = rgb_matrix_config.val - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; - hsv->v = scale8(v < 0 ? 0 : v, rgb_matrix_config.val); +static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) { + int16_t v = hsv.v - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; + hsv.v = scale8(v < 0 ? 0 : v, hsv.v); + return hsv; } bool BAND_VAL(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h index 380dbe05a4..0c45aba8b1 100644 --- a/quantum/rgb_matrix_animations/cycle_all_anim.h +++ b/quantum/rgb_matrix_animations/cycle_all_anim.h @@ -2,9 +2,9 @@ RGB_MATRIX_EFFECT(CYCLE_ALL) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void CYCLE_ALL_math(HSV* hsv, uint8_t i, uint8_t time) -{ - hsv->h = time; +static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time){ + hsv.h = time; + return hsv; } bool CYCLE_ALL(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/cycle_left_right_anim.h b/quantum/rgb_matrix_animations/cycle_left_right_anim.h index f270fb42cc..d2e5b4fbdf 100644 --- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h +++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void CYCLE_LEFT_RIGHT_math(HSV* hsv, uint8_t i, uint8_t time) { - hsv->h = g_led_config.point[i].x - time; +static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) { + hsv.h = g_led_config.point[i].x - time; + return hsv; } bool CYCLE_LEFT_RIGHT(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/cycle_out_in_anim.h b/quantum/rgb_matrix_animations/cycle_out_in_anim.h index 46c7efef25..fa7c3b09cf 100644 --- a/quantum/rgb_matrix_animations/cycle_out_in_anim.h +++ b/quantum/rgb_matrix_animations/cycle_out_in_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(CYCLE_OUT_IN) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void CYCLE_OUT_IN_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { - hsv->h = 3 * dist / 2 + time; +static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { + hsv.h = 3 * dist / 2 + time; + return hsv; } bool CYCLE_OUT_IN(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h b/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h index 2fdb4ba919..74a2c9aa58 100644 --- a/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h +++ b/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h @@ -2,10 +2,11 @@ RGB_MATRIX_EFFECT(CYCLE_OUT_IN_DUAL) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void CYCLE_OUT_IN_DUAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) { +static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { dx = (k_rgb_matrix_center.x / 2) - abs8(dx); uint8_t dist = sqrt16(dx * dx + dy * dy); - hsv->h = 3 * dist + time; + hsv.h = 3 * dist + time; + return hsv; } bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h b/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h index 29e2d92c92..54e222dc2e 100644 --- a/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h +++ b/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(CYCLE_PINWHEEL) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void CYCLE_PINWHEEL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) { - hsv->h = atan2_8(dy, dx) + time; +static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { + hsv.h = atan2_8(dy, dx) + time; + return hsv; } bool CYCLE_PINWHEEL(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/cycle_spiral_anim.h b/quantum/rgb_matrix_animations/cycle_spiral_anim.h index a1354f60c1..b27d7a83c7 100644 --- a/quantum/rgb_matrix_animations/cycle_spiral_anim.h +++ b/quantum/rgb_matrix_animations/cycle_spiral_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(CYCLE_SPIRAL) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void CYCLE_SPIRAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { - hsv->h = dist - time - atan2_8(dy, dx); +static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { + hsv.h = dist - time - atan2_8(dy, dx); + return hsv; } bool CYCLE_SPIRAL(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h index b3ef4cdf2e..4bf8ef2ae4 100644 --- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h +++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(CYCLE_UP_DOWN) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void CYCLE_UP_DOWN_math(HSV* hsv, uint8_t i, uint8_t time) { - hsv->h = g_led_config.point[i].y - time; +static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) { + hsv.h = g_led_config.point[i].y - time; + return hsv; } bool CYCLE_UP_DOWN(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/dual_beacon_anim.h b/quantum/rgb_matrix_animations/dual_beacon_anim.h index d34f146a5b..336a41b2ce 100644 --- a/quantum/rgb_matrix_animations/dual_beacon_anim.h +++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(DUAL_BEACON) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void DUAL_BEACON_math(HSV* hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { - hsv->h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * sin) / 128 + rgb_matrix_config.hue; +static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { + 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; + return hsv; } bool DUAL_BEACON(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/gradient_up_down_anim.h b/quantum/rgb_matrix_animations/gradient_up_down_anim.h index d9fcd4d988..12848ab4cc 100644 --- a/quantum/rgb_matrix_animations/gradient_up_down_anim.h +++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h @@ -5,13 +5,13 @@ RGB_MATRIX_EFFECT(GRADIENT_UP_DOWN) bool GRADIENT_UP_DOWN(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); - HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; + HSV hsv = rgb_matrix_config.hsv; uint8_t scale = scale8(64, rgb_matrix_config.speed); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); // The y range will be 0..64, map this to 0..4 // Relies on hue being 8-bit and wrapping - hsv.h = rgb_matrix_config.hue + scale * (g_led_config.point[i].y >> 4); + hsv.h = rgb_matrix_config.hsv.h + scale * (g_led_config.point[i].y >> 4); RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h index 8f0b1bd914..bffa0a42d7 100644 --- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h @@ -4,7 +4,7 @@ RGB_MATRIX_EFFECT(JELLYBEAN_RAINDROPS) static void jellybean_raindrops_set_color(int i, effect_params_t* params) { if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; - HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val }; + HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.hsv.v }; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h index 061cac837c..f53c819a9e 100644 --- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(RAINBOW_BEACON) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void RAINBOW_BEACON_math(HSV* hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { - hsv->h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128 + rgb_matrix_config.hue; +static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { + 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; + return hsv; } bool RAINBOW_BEACON(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h index f406566fa1..e78c55e8dd 100644 --- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(RAINBOW_MOVING_CHEVRON) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void RAINBOW_MOVING_CHEVRON_math(HSV* hsv, uint8_t i, uint8_t time) { - hsv->h = abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time) + rgb_matrix_config.hue; +static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { + hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); + return hsv; } bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h index f19e9116d9..8298fec468 100644 --- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h @@ -2,8 +2,9 @@ RGB_MATRIX_EFFECT(PINWHEELS) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void PINWHEELS_math(HSV* hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { - hsv->h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 3 * cos + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * 3 * sin) / 128 + rgb_matrix_config.hue; +static HSV PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { + 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; + return hsv; } bool PINWHEELS(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h index 09d0d1df87..a4fed51658 100644 --- a/quantum/rgb_matrix_animations/raindrops_anim.h +++ b/quantum/rgb_matrix_animations/raindrops_anim.h @@ -4,17 +4,17 @@ RGB_MATRIX_EFFECT(RAINDROPS) static void raindrops_set_color(int i, effect_params_t* params) { if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; - HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val }; + HSV hsv = { 0 , rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v }; // Take the shortest path between hues - int16_t deltaH = ((rgb_matrix_config.hue + 180) % 360 - rgb_matrix_config.hue) / 4; + int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4; if (deltaH > 127) { deltaH -= 256; } else if (deltaH < -127) { deltaH += 256; } - hsv.h = rgb_matrix_config.hue + (deltaH * (rand() & 0x03)); + hsv.h = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03)); RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h index 9376425598..6e40638035 100644 --- a/quantum/rgb_matrix_animations/solid_color_anim.h +++ b/quantum/rgb_matrix_animations/solid_color_anim.h @@ -4,8 +4,7 @@ RGB_MATRIX_EFFECT(SOLID_COLOR) bool SOLID_COLOR(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); - HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val }; - RGB rgb = hsv_to_rgb(hsv); + RGB rgb = hsv_to_rgb(rgb_matrix_config.hsv); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index 762a95db31..dd49b6530e 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -3,8 +3,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void SOLID_REACTIVE_math(HSV* hsv, uint16_t offset) { - hsv->h = rgb_matrix_config.hue + qsub8(130, offset); +static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) { + hsv.h += qsub8(130, offset); + return hsv; } bool SOLID_REACTIVE(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h index 99f22c694e..5b9cfcbd52 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_cross.h +++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h @@ -11,7 +11,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void SOLID_REACTIVE_CROSS_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick + dist; dx = dx < 0 ? dx * -1 : dx; dy = dy < 0 ? dy * -1 : dy; @@ -20,7 +20,8 @@ static void SOLID_REACTIVE_CROSS_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t effect += dx > dy ? dy : dx; if (effect > 255) effect = 255; - hsv->v = qadd8(hsv->v, 255 - effect); + hsv.v = qadd8(hsv.v, 255 - effect); + return hsv; } #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS diff --git a/quantum/rgb_matrix_animations/solid_reactive_nexus.h b/quantum/rgb_matrix_animations/solid_reactive_nexus.h index 8bebd042d2..e90eaf4b28 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_nexus.h +++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h @@ -11,7 +11,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void SOLID_REACTIVE_NEXUS_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick - dist; if (effect > 255) effect = 255; @@ -19,8 +19,9 @@ static void SOLID_REACTIVE_NEXUS_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t effect = 255; if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255; - hsv->v = qadd8(hsv->v, 255 - effect); - hsv->h = rgb_matrix_config.hue + dy / 4; + hsv.v = qadd8(hsv.v, 255 - effect); + hsv.h = rgb_matrix_config.hsv.h + dy / 4; + return hsv; } #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h index 36c6ec5277..77c8ff6724 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h @@ -3,8 +3,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void SOLID_REACTIVE_SIMPLE_math(HSV* hsv, uint16_t offset) { - hsv->v = scale8(255 - offset, rgb_matrix_config.val); +static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) { + hsv.v = scale8(255 - offset, hsv.v); + return hsv; } bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/solid_reactive_wide.h b/quantum/rgb_matrix_animations/solid_reactive_wide.h index 36edc475c8..73779dfa74 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_wide.h +++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h @@ -11,11 +11,12 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void SOLID_REACTIVE_WIDE_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick + dist * 5; if (effect > 255) effect = 255; - hsv->v = qadd8(hsv->v, 255 - effect); + hsv.v = qadd8(hsv.v, 255 - effect); + return hsv; } #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h index 84c99ff00c..441f35576b 100644 --- a/quantum/rgb_matrix_animations/solid_splash_anim.h +++ b/quantum/rgb_matrix_animations/solid_splash_anim.h @@ -11,11 +11,12 @@ RGB_MATRIX_EFFECT(SOLID_MULTISPLASH) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -void SOLID_SPLASH_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick - dist; if (effect > 255) effect = 255; - hsv->v = qadd8(hsv->v, 255 - effect); + hsv.v = qadd8(hsv.v, 255 - effect); + return hsv; } #ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h index c4c0516535..19ccb256e9 100644 --- a/quantum/rgb_matrix_animations/splash_anim.h +++ b/quantum/rgb_matrix_animations/splash_anim.h @@ -11,12 +11,13 @@ RGB_MATRIX_EFFECT(MULTISPLASH) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -void SPLASH_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick - dist; - if (effect > 255) + if (effect > 255) effect = 255; - hsv->h += effect; - hsv->v = qadd8(hsv->v, 255 - effect); + hsv.h += effect; + hsv.v = qadd8(hsv.v, 255 - effect); + return hsv; } #ifndef DISABLE_RGB_MATRIX_SPLASH diff --git a/quantum/rgb_matrix_animations/typing_heatmap_anim.h b/quantum/rgb_matrix_animations/typing_heatmap_anim.h index e6b34717b2..374b7fea0c 100644 --- a/quantum/rgb_matrix_animations/typing_heatmap_anim.h +++ b/quantum/rgb_matrix_animations/typing_heatmap_anim.h @@ -59,7 +59,7 @@ bool TYPING_HEATMAP(effect_params_t* params) { if (!HAS_ANY_FLAGS(g_led_config.flags[led[j]], params->flags)) continue; - HSV hsv = { 170 - qsub8(val, 85), rgb_matrix_config.sat, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.val) }; + HSV hsv = { 170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v) }; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b); } |