87 {
90
91 if (iterations < 1) iterations = 1;
93 if (num_leds < 2) num_leds = 2;
95 r.num_leds = num_leds;
96
98 for (int i = 0; i < num_leds; ++i) {
100 }
101
102
103
104 {
106 if (!probe.valid()) {
107 return r;
108 }
109 }
110
111
112
114
115 LegacyClocklessProxy proxy(pin,
leds, num_leds);
116 r.valid_pin = true;
117
118#if defined(ARDUINO_ARCH_ESP32)
119 r.cpu_mhz = getCpuFrequencyMhz();
120#endif
121
122
125
126 constexpr uint32_t kFastLedUpdateMs = 5;
129
130 ms_delay_post.
start(0);
131 ms_fast_led.start(kFastLedUpdateMs);
132
133 int i_post_fade = 255;
135 int completed = 0;
136
137 r.show_min_us = 0xFFFFFFFFu;
138
139 auto timedShow = [&]() {
143 r.show_count++;
144 r.show_total_us += dt;
145 if (dt < r.show_min_us) r.show_min_us = dt;
146 if (dt > r.show_max_us) r.show_max_us = dt;
147 };
148
150 if (ms_fast_led.justFinished()) {
151 timedShow();
152 ms_fast_led.start(kFastLedUpdateMs);
153 }
154 };
155
156 const int i_ring_start = 0;
157 const int i_ring_end = num_leds - 1;
158 const int i_ring_divisor = 7;
159
160
161
162
164 constexpr uint32_t kWdtFeedIntervalMs = 1000;
165 auto maybeFeedWatchdog = [&]() {
167 if (now - last_wdt_feed_ms >= kWdtFeedIntervalMs) {
169 last_wdt_feed_ms = now;
170 }
171 };
172
173
174
175 while (completed < iterations) {
176 if (i_post_fade > 0 && ms_delay_post.justFinished()) {
177 const int i_ring_counter =
178 ((255 - i_post_fade) / i_ring_divisor) + i_ring_start;
179
180 if (i_ring_counter <= i_ring_end) {
182 }
183 if (i_ring_counter - 1 >= i_ring_start &&
184 i_ring_counter - 1 <= i_ring_end) {
186 }
187
188 i_post_fade--;
189
190 if (i_post_fade == 0) {
192 r.iter_ms[completed] = now - i_iteration_time;
193 completed++;
194 i_iteration_time = now;
195 ms_delay_post.stop();
196
197 for (int i = i_ring_start; i <= i_ring_end; i++) {
199 }
200
205 last_wdt_feed_ms =
millis();
206 i_post_fade = 255;
207 ms_delay_post.start(225);
208 continue;
209 } else {
210 ms_delay_post.start(5);
211 }
212 }
214 maybeFeedWatchdog();
215 }
216
217 r.iterations = completed;
218 if (r.show_count == 0) {
219 r.show_min_us = 0;
220 }
221
222
223
225 return r;
226}
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
void setMaxRefreshRate(fl::u16 refresh, bool constrain=false)
Set the maximum refresh rate.
void show(fl::u8 scale)
Update all our controllers with the current led colors, using the passed in brightness.
static fl::Watchdog & watchdog()
Access the unified cross-platform watchdog timer.
void clear(bool writeData=false)
Clear the leds, wiping the local array of data.
Proxy that creates a legacy clockless controller from runtime inputs.
@ CHANNELS
Remove all channels from controller list.
constexpr int kMaxIterations
TimingDriftState & timingDriftState()
void delay(u32 ms, bool run_async=true) FL_NO_EXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
fl::u32 micros()
Universal microsecond timer - returns microseconds since system startup.
void start(uint32_t delay_ms)
Faithful emulation of the millisDelay library used by the issue sketch: start(t) arms a deadline; jus...
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>