MCPcopy Create free account
hub / github.com/FastLED/FastLED / clear

Method clear

src/FastLED.cpp.hpp:161–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161void CFastLED::clear(ClearFlags flags) {
162 // Lambda to check if flag is set, clear it, and return true if it was set
163 auto clearFlag = [&flags](ClearFlags flag) -> bool {
164 if ((flags & flag) != ClearFlags::NONE) {
165 flags = static_cast<ClearFlags>(static_cast<fl::u32>(flags) & ~static_cast<fl::u32>(flag));
166 return true;
167 }
168 return false;
169 };
170
171
172 // Reset POWER_SETTINGS - reset power management to defaults
173 if (clearFlag(ClearFlags::POWER_SETTINGS)) {
174 FastLED.mPPowerFunc = nullptr; // No power limiting function
175 FastLED.mNPowerData = 0xFFFFFFFF; // No power limit (max value)
176 }
177
178 // Reset BRIGHTNESS - reset global brightness to 255 (full brightness)
179 if (clearFlag(ClearFlags::BRIGHTNESS)) {
180 FastLED.mScale = 255;
181 }
182
183 // Reset REFRESH_RATE - reset refresh rate limiting to unlimited
184 if (clearFlag(ClearFlags::REFRESH_RATE)) {
185 FastLED.mNMinMicros = 0; // No minimum delay between frames
186 }
187
188 // Reset FPS_COUNTER - reset FPS tracking counter to 0
189 if (clearFlag(ClearFlags::FPS_COUNTER)) {
190 FastLED.mNFPS = 0;
191 }
192
193 // Reset CHANNELS - remove all channels from controller list
194 if (clearFlag(ClearFlags::CHANNELS)) {
195 // Wait for engines to complete, with 2s timeout to prevent infinite hang
196 // if an engine is permanently stalled (e.g. PARLIO on ESP32-C6 hw bug)
197 FastLED.wait(2000);
198
199 // Remove all channels by iterating through a copy of the vector
200 // (we make a copy because remove() modifies channels())
201 fl::vector<fl::ChannelPtr> channelsCopy = channels();
202 for (auto& channel : channelsCopy) {
203 remove(channel);
204 }
205
206 // Reset bus manager state (clear enqueued and transmitting channels)
207 fl::ChannelManager& manager = fl::channelManager();
208 manager.reset();
209
210 // Clear the internal storage (should already be empty, but ensure it)
211 channels().clear();
212 }
213
214 // Reset CHANNEL_ENGINES - clear all registered channel drivers
215 if (clearFlag(ClearFlags::CHANNEL_ENGINES)) {
216 // Always wait for all channel bus transmissions to complete first
217 FastLED.wait();
218 fl::ChannelManager& manager = fl::channelManager();

Callers 15

loopFunction · 0.45
setupFunction · 0.45
print_summaryFunction · 0.45
setupFunction · 0.45
RawBeginDrawMethod · 0.45
validateParlioStreamingFunction · 0.45
dumpRawEdgeTimingFunction · 0.45
runMultiTestFunction · 0.45
runSimdTestsFunction · 0.45
measureTightTimingFunction · 0.45

Calls 6

showColorFunction · 0.85
clearAllDriversMethod · 0.80
removeFunction · 0.50
CRGBClass · 0.50
waitMethod · 0.45
resetMethod · 0.45

Tested by 5

print_summaryFunction · 0.36
dumpRawEdgeTimingFunction · 0.36
runMultiTestFunction · 0.36