Browse Source

Refactor Riverflow matrix effect with runner (#24520)

Co-authored-by: Ryan <fauxpark@gmail.com>
フィルターペーパー 1 year ago
parent
commit
644588baef
1 changed files with 7 additions and 11 deletions
  1. 7 11
      quantum/rgb_matrix/animations/riverflow_anim.h

+ 7 - 11
quantum/rgb_matrix/animations/riverflow_anim.h

@@ -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_math(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_math);
 }
 
 #    endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS