| 116 | void clearLeds() { fl::memset(leds, 0, NUM_LEDS * sizeof(fl::CRGB)); } |
| 117 | |
| 118 | void loop() { |
| 119 | // Your code here |
| 120 | clearLeds(); |
| 121 | const uint32_t now = millis(); |
| 122 | uint32_t now_warped = time_warp.update(now); |
| 123 | |
| 124 | // Apply UI stencil choice to both wave layers. |
| 125 | const fl::LaplacianStencil stencil = isotropicStencil |
| 126 | ? fl::LaplacianStencil::NinePointIsotropic |
| 127 | : fl::LaplacianStencil::FivePoint; |
| 128 | wave_fx.wave_fx_low->setStencil(stencil); |
| 129 | wave_fx.wave_fx_high->setStencil(stencil); |
| 130 | |
| 131 | auto shape = getShape(whichShape.as<int>()); |
| 132 | shape->setScale(scale.value()); |
| 133 | |
| 134 | float curr_alpha = getAnimationTime(now_warped); |
| 135 | static float s_prev_alpha = 0.0f; // okay static in header |
| 136 | |
| 137 | // unconditionally apply the circle. |
| 138 | if (trigger) { |
| 139 | // trigger the transition |
| 140 | time_warp.reset(now); |
| 141 | now_warped = time_warp.update(now); |
| 142 | shapeProgress.trigger(now_warped); |
| 143 | FL_WARN("Transition triggered on " << shape->name()); |
| 144 | curr_alpha = getAnimationTime(now_warped); |
| 145 | s_prev_alpha = curr_alpha; |
| 146 | } |
| 147 | |
| 148 | // FL_WARN("Current alpha: " << curr_alpha); |
| 149 | // FL_WARN("maxAnimation: " << maxAnimation.value()); |
| 150 | |
| 151 | const bool is_active = |
| 152 | true || curr_alpha < maxAnimation.value() && curr_alpha > 0.0f; |
| 153 | |
| 154 | // if (shapeProgress.isActive(now)) { |
| 155 | static uint32_t frame = 0; |
| 156 | frame++; |
| 157 | clearLeds(); |
| 158 | const fl::CRGB purple = fl::CRGB(255, 0, 255); |
| 159 | const int number_of_steps = numberOfSteps.value(); |
| 160 | raster.reset(); |
| 161 | // float factor = s_prev_alpha; // 0->1.f |
| 162 | // factor = fl::min(factor/4.0f, 0.05f); |
| 163 | |
| 164 | float diff = curr_alpha - s_prev_alpha; |
| 165 | diff *= 1.0f; |
| 166 | float factor = fl::max(s_prev_alpha - diff, 0.f); |
| 167 | |
| 168 | for (int i = 0; i < number_of_steps; ++i) { |
| 169 | float a = |
| 170 | fl::map_range<float>(i, 0, number_of_steps - 1, factor, curr_alpha); |
| 171 | if (a < .04) { |
| 172 | // shorter tails at first. |
| 173 | a = map_range<float>(a, 0.0f, .04f, 0.0f, .04f); |
| 174 | } |
| 175 | float diff_max_alpha = maxAnimation.value() - curr_alpha; |
nothing calls this directly
no test coverage detected