summaryrefslogtreecommitdiff
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/jellybean_raindrops_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/pixel_flow_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/pixel_rain_anim.h21
-rw-r--r--quantum/rgb_matrix/animations/raindrops_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_cross.h2
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_nexus.h5
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_simple_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_wide.h2
9 files changed, 16 insertions, 28 deletions
diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h
index 69bf265d14..6bde60053b 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, qadd8(rand() & 0x7F, 0x80), rgb_matrix_config.hsv.v};
+ HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v};
RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
@@ -13,7 +13,7 @@ bool JELLYBEAN_RAINDROPS(effect_params_t* params) {
if (!params->init) {
// Change one LED every tick, make sure speed is not 0
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
- jellybean_raindrops_set_color(rand() % RGB_MATRIX_LED_COUNT, params);
+ jellybean_raindrops_set_color(random8_max(RGB_MATRIX_LED_COUNT), params);
}
return false;
}
diff --git a/quantum/rgb_matrix/animations/pixel_flow_anim.h b/quantum/rgb_matrix/animations/pixel_flow_anim.h
index 8628c3c2ec..27567b4f3a 100644
--- a/quantum/rgb_matrix/animations/pixel_flow_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_flow_anim.h
@@ -22,7 +22,7 @@ static bool PIXEL_FLOW(effect_params_t* params) {
// Clear LEDs and fill the state array
rgb_matrix_set_color_all(0, 0, 0);
for (uint8_t j = 0; j < RGB_MATRIX_LED_COUNT; ++j) {
- led[j] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v});
+ led[j] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v});
}
}
@@ -39,7 +39,7 @@ static bool PIXEL_FLOW(effect_params_t* params) {
led[j] = led[j + 1];
}
// Fill last LED
- led[led_max - 1] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v});
+ led[led_max - 1] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v});
// Set pulse timer
wait_timer = g_rgb_timer + interval();
}
diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h
index fded60340f..ccea8d976a 100644
--- a/quantum/rgb_matrix/animations/pixel_rain_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h
@@ -1,18 +1,5 @@
-/* Copyright (C) 2021 @filterpaper
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2022 @filterpaper
+// SPDX-License-Identifier: GPL-2.0+
#ifdef ENABLE_RGB_MATRIX_PIXEL_RAIN
RGB_MATRIX_EFFECT(PIXEL_RAIN)
@@ -32,7 +19,7 @@ static bool PIXEL_RAIN(effect_params_t* params) {
if (off) {
rgb_matrix_set_color(i, 0, 0, 0);
} else {
- HSV hsv = {random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v};
+ HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v};
RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
@@ -41,7 +28,7 @@ static bool PIXEL_RAIN(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
if (g_rgb_timer > wait_timer) {
- rain_pixel(mod8(random8(), RGB_MATRIX_LED_COUNT), params, random8() & 2);
+ rain_pixel(random8_max(RGB_MATRIX_LED_COUNT), params, random8() & 2);
}
return rgb_matrix_check_finished_leds(led_max);
}
diff --git a/quantum/rgb_matrix/animations/raindrops_anim.h b/quantum/rgb_matrix/animations/raindrops_anim.h
index 6b92d649ad..e8e1f6de04 100644
--- a/quantum/rgb_matrix/animations/raindrops_anim.h
+++ b/quantum/rgb_matrix/animations/raindrops_anim.h
@@ -24,7 +24,7 @@ bool RAINDROPS(effect_params_t* params) {
if (!params->init) {
// Change one LED every tick, make sure speed is not 0
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
- raindrops_set_color(random8() % RGB_MATRIX_LED_COUNT, params);
+ raindrops_set_color(random8_max(RGB_MATRIX_LED_COUNT), params);
}
} else {
for (int i = led_min; i < led_max; i++) {
diff --git a/quantum/rgb_matrix/animations/solid_reactive_anim.h b/quantum/rgb_matrix/animations/solid_reactive_anim.h
index 052bfb22fd..edf6041350 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_anim.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h
@@ -5,7 +5,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE)
static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) {
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
- hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+ hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4);
# endif
hsv.h += qsub8(130, offset);
return hsv;
diff --git a/quantum/rgb_matrix/animations/solid_reactive_cross.h b/quantum/rgb_matrix/animations/solid_reactive_cross.h
index 9e5703a0ea..a18d6b03dd 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_cross.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_cross.h
@@ -20,7 +20,7 @@ static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di
effect += dx > dy ? dy : dx;
if (effect > 255) effect = 255;
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
- hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+ hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4);
# endif
hsv.v = qadd8(hsv.v, 255 - effect);
return hsv;
diff --git a/quantum/rgb_matrix/animations/solid_reactive_nexus.h b/quantum/rgb_matrix/animations/solid_reactive_nexus.h
index 64f5064cf9..53cc008616 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_nexus.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_nexus.h
@@ -17,10 +17,11 @@ static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di
if (dist > 72) effect = 255;
if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255;
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
- hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+ hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4) + dy / 4;
+# else
+ hsv.h = rgb_matrix_config.hsv.h + dy / 4;
# endif
hsv.v = qadd8(hsv.v, 255 - effect);
- hsv.h = rgb_matrix_config.hsv.h + dy / 4;
return hsv;
}
diff --git a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
index bd3ce0817d..7f4e48747a 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
@@ -5,7 +5,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) {
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
- hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+ hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4);
# endif
hsv.v = scale8(255 - offset, hsv.v);
return hsv;
diff --git a/quantum/rgb_matrix/animations/solid_reactive_wide.h b/quantum/rgb_matrix/animations/solid_reactive_wide.h
index 24fedc2020..feca126648 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_wide.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_wide.h
@@ -15,7 +15,7 @@ static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dis
uint16_t effect = tick + dist * 5;
if (effect > 255) effect = 255;
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
- hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
+ hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4);
# endif
hsv.v = qadd8(hsv.v, 255 - effect);
return hsv;