aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix/animations
diff options
context:
space:
mode:
authorNick Brassel <[email protected]>2024-08-26 10:01:57 +1000
committerNick Brassel <[email protected]>2024-08-26 10:01:57 +1000
commit5d76c5280dc0aff398cdce19fa54d0e0725c418d (patch)
tree40026340f0d524a6006f18f01ef988e15d271075 /quantum/rgb_matrix/animations
parente6a898e3eea3521d3f0497ee26937d5269d78fb7 (diff)
parent81dcf2b547bacc42bd9cf8ccaccd3d7164e69926 (diff)
downloadqmk_firmware-5d76c5280dc0aff398cdce19fa54d0e0725c418d.tar.gz
qmk_firmware-5d76c5280dc0aff398cdce19fa54d0e0725c418d.zip
Merge branch 'develop'0.26.0
Diffstat (limited to 'quantum/rgb_matrix/animations')
-rw-r--r--quantum/rgb_matrix/animations/pixel_fractal_anim.h24
-rw-r--r--quantum/rgb_matrix/animations/riverflow_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/starlight_anim.h9
-rw-r--r--quantum/rgb_matrix/animations/starlight_dual_hue_anim.h11
-rw-r--r--quantum/rgb_matrix/animations/starlight_dual_sat_anim.h11
5 files changed, 30 insertions, 27 deletions
diff --git a/quantum/rgb_matrix/animations/pixel_fractal_anim.h b/quantum/rgb_matrix/animations/pixel_fractal_anim.h
index 4cd1d9b861..90a75ed321 100644
--- a/quantum/rgb_matrix/animations/pixel_fractal_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_fractal_anim.h
@@ -30,23 +30,23 @@ static bool PIXEL_FRACTAL(effect_params_t* params) {
for (uint8_t h = 0; h < MATRIX_ROWS; ++h) {
// Light and copy columns outward
for (uint8_t l = 0; l < MID_COL - 1; ++l) {
- if (led[h][l]) {
- rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b);
- rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - 1 - l], rgb.r, rgb.g, rgb.b);
- } else {
- rgb_matrix_set_color(g_led_config.matrix_co[h][l], 0, 0, 0);
- rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - 1 - l], 0, 0, 0);
+ RGB index_rgb = led[h][l] ? (RGB){rgb.r, rgb.g, rgb.b} : (RGB){0, 0, 0};
+ if (HAS_ANY_FLAGS(g_led_config.flags[g_led_config.matrix_co[h][l]], params->flags)) {
+ rgb_matrix_set_color(g_led_config.matrix_co[h][l], index_rgb.r, index_rgb.g, index_rgb.b);
+ }
+ if (HAS_ANY_FLAGS(g_led_config.flags[g_led_config.matrix_co[h][MATRIX_COLS - 1 - l]], params->flags)) {
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - 1 - l], index_rgb.r, index_rgb.g, index_rgb.b);
}
led[h][l] = led[h][l + 1];
}
// Light both middle columns
- if (led[h][MID_COL - 1]) {
- rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], rgb.r, rgb.g, rgb.b);
- rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - MID_COL], rgb.r, rgb.g, rgb.b);
- } else {
- rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], 0, 0, 0);
- rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - MID_COL], 0, 0, 0);
+ RGB index_rgb = led[h][MID_COL - 1] ? (RGB){rgb.r, rgb.g, rgb.b} : (RGB){0, 0, 0};
+ if (HAS_ANY_FLAGS(g_led_config.flags[g_led_config.matrix_co[h][MID_COL - 1]], params->flags)) {
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], index_rgb.r, index_rgb.g, index_rgb.b);
+ }
+ if (HAS_ANY_FLAGS(g_led_config.flags[g_led_config.matrix_co[h][MATRIX_COLS - MID_COL]], params->flags)) {
+ rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - MID_COL], index_rgb.r, index_rgb.g, index_rgb.b);
}
// Generate new random fractal column
diff --git a/quantum/rgb_matrix/animations/riverflow_anim.h b/quantum/rgb_matrix/animations/riverflow_anim.h
index 79a38e7f6e..195d15986d 100644
--- a/quantum/rgb_matrix/animations/riverflow_anim.h
+++ b/quantum/rgb_matrix/animations/riverflow_anim.h
@@ -7,11 +7,11 @@ RGB_MATRIX_EFFECT(RIVERFLOW)
bool RIVERFLOW(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
HSV hsv = rgb_matrix_config.hsv;
uint16_t time = scale16by8(g_rgb_timer + (i * 315), rgb_matrix_config.speed / 8);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
- RGB_MATRIX_TEST_LED_FLAGS();
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
diff --git a/quantum/rgb_matrix/animations/starlight_anim.h b/quantum/rgb_matrix/animations/starlight_anim.h
index 33f0b61a91..91626a4663 100644
--- a/quantum/rgb_matrix/animations/starlight_anim.h
+++ b/quantum/rgb_matrix/animations/starlight_anim.h
@@ -2,25 +2,26 @@
RGB_MATRIX_EFFECT(STARLIGHT)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-void set_starlight_color(int i, effect_params_t* params) {
+void set_starlight_color(uint8_t i, effect_params_t* params) {
uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
HSV hsv = rgb_matrix_config.hsv;
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
- RGB rgb = hsv_to_rgb(hsv);
+ RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
bool STARLIGHT(effect_params_t* params) {
if (!params->init) {
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0) {
- int rand_led = rand() % RGB_MATRIX_LED_COUNT;
+ uint8_t rand_led = random8_max(RGB_MATRIX_LED_COUNT);
set_starlight_color(rand_led, params);
}
return false;
}
RGB_MATRIX_USE_LIMITS(led_min, led_max);
- for (int i = led_min; i < led_max; i++) {
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
set_starlight_color(i, params);
}
return rgb_matrix_check_finished_leds(led_max);
diff --git a/quantum/rgb_matrix/animations/starlight_dual_hue_anim.h b/quantum/rgb_matrix/animations/starlight_dual_hue_anim.h
index df6461b8b7..5ef831476f 100644
--- a/quantum/rgb_matrix/animations/starlight_dual_hue_anim.h
+++ b/quantum/rgb_matrix/animations/starlight_dual_hue_anim.h
@@ -2,26 +2,27 @@
RGB_MATRIX_EFFECT(STARLIGHT_DUAL_HUE)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-void set_starlight_dual_hue_color(int i, effect_params_t* params) {
+void set_starlight_dual_hue_color(uint8_t i, effect_params_t* params) {
uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
HSV hsv = rgb_matrix_config.hsv;
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
- hsv.h = hsv.h + (rand() % (30 + 1 - -30) + -30);
- RGB rgb = hsv_to_rgb(hsv);
+ hsv.h = hsv.h + random8_max((30 + 1 - -30) + -30);
+ RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
bool STARLIGHT_DUAL_HUE(effect_params_t* params) {
if (!params->init) {
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0) {
- int rand_led = rand() % RGB_MATRIX_LED_COUNT;
+ uint8_t rand_led = random8_max(RGB_MATRIX_LED_COUNT);
set_starlight_dual_hue_color(rand_led, params);
}
return false;
}
RGB_MATRIX_USE_LIMITS(led_min, led_max);
- for (int i = led_min; i < led_max; i++) {
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
set_starlight_dual_hue_color(i, params);
}
return rgb_matrix_check_finished_leds(led_max);
diff --git a/quantum/rgb_matrix/animations/starlight_dual_sat_anim.h b/quantum/rgb_matrix/animations/starlight_dual_sat_anim.h
index f6ecd48aa1..1994aba8a8 100644
--- a/quantum/rgb_matrix/animations/starlight_dual_sat_anim.h
+++ b/quantum/rgb_matrix/animations/starlight_dual_sat_anim.h
@@ -2,26 +2,27 @@
RGB_MATRIX_EFFECT(STARLIGHT_DUAL_SAT)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-void set_starlight_dual_sat_color(int i, effect_params_t* params) {
+void set_starlight_dual_sat_color(uint8_t i, effect_params_t* params) {
uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
HSV hsv = rgb_matrix_config.hsv;
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
- hsv.s = hsv.s + (rand() % (30 + 1 - -30) + -30);
- RGB rgb = hsv_to_rgb(hsv);
+ hsv.s = hsv.s + random8_max((30 + 1 - -30) + -30);
+ RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
bool STARLIGHT_DUAL_SAT(effect_params_t* params) {
if (!params->init) {
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0) {
- int rand_led = rand() % RGB_MATRIX_LED_COUNT;
+ uint8_t rand_led = random8_max(RGB_MATRIX_LED_COUNT);
set_starlight_dual_sat_color(rand_led, params);
}
return false;
}
RGB_MATRIX_USE_LIMITS(led_min, led_max);
- for (int i = led_min; i < led_max; i++) {
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
set_starlight_dual_sat_color(i, params);
}
return rgb_matrix_check_finished_leds(led_max);