Skip to content

Commit

Permalink
Refactor Riverflow matrix effect
Browse files Browse the repository at this point in the history
Simplify effect by reusing an existing runner
  • Loading branch information
filterpaper committed Oct 25, 2024
1 parent d316331 commit 849db0a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions quantum/rgb_matrix/animations/riverflow_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ RGB_MATRIX_EFFECT(RIVERFLOW)

// inspired by @PleasureTek's Massdrop Alt LED animation

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_t 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_t rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
hsv_t RIVERFLOW_maths(hsv_t hsv, uint8_t i, uint8_t time) {
time = scale16by8(g_rgb_timer + (i * 315), rgb_matrix_config.speed / 8);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
return hsv;
}

return rgb_matrix_check_finished_leds(led_max);
bool RIVERFLOW(effect_params_t* params) {
return effect_runner_i(params, &RIVERFLOW_maths);
}

# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
Expand Down

0 comments on commit 849db0a

Please sign in to comment.