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

Function setup

examples/FestivalStick/curr.h:290–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288fl::WaveCrgbGradientMapPtr crgMap = fl::make_shared<fl::WaveCrgbGradientMap>();
289
290void setup() {
291 // Use constexpr dimensions (computed at compile time)
292 constexpr int width = CORKSCREW_WIDTH; // = 16
293 constexpr int height = CORKSCREW_HEIGHT; // = 18
294
295
296 // Noise controls are now automatically grouped by the fl::UIGroup constructor
297 // The noiseGroup variadic constructor automatically called setGroup() on all controls
298
299
300 // Or use runtime corkscrew for dynamic sizing
301 // int width = corkscrew.cylinder_width();
302 // int height = corkscrew.cylinder_height();
303
304 fl::XYMap xyMap = fl::XYMap::constructRectangularGrid(width, height, 0);
305
306 // Use the corkscrew's internal buffer for the LED strip
307 CLEDController *controller =
308 &FastLED.addLeds<APA102HD, PIN_DATA, PIN_CLOCK, BGR>(corkscrew.rawData(), NUM_LEDS);
309
310 // CLEDController *controller =
311 // &FastLED.addLeds<WS2812, 3, BGR>(stripLeds, NUM_LEDS);
312
313 // NEW: Create fl::ScreenMap directly from fl::Corkscrew using toScreenMap()
314 // This maps each LED index to its exact position on the corkscrew spiral
315 // instead of using a rectangular grid mapping
316 fl::ScreenMap corkscrewScreenMap = corkscrew.toScreenMap(0.2f);
317
318 // OLD WAY (rectangular grid - not accurate for corkscrew visualization):
319 // fl::ScreenMap screenMap = xyMap.toScreenMap();
320 // screenMap.setDiameter(.2f);
321
322 // Set the corkscrew screen map for the controller
323 // This allows the web interface to display the actual corkscrew spiral shape
324 controller->setScreenMap(corkscrewScreenMap);
325
326 // Initialize wave effects for cylindrical surface
327 fl::XYMap xyRect(width, height, false); // Rectangular grid for wave simulation
328 fl::WaveFx::Args waveArgs;
329 waveArgs.factor = fl::SuperSample::SUPER_SAMPLE_2X; // 2x supersampling for smoother waves
330 waveArgs.half_duplex = true; // Only positive waves
331 waveArgs.auto_updates = true; // Auto-update simulation
332 waveArgs.speed = 0.16f; // Wave propagation speed
333 waveArgs.dampening = 6.0f; // Wave energy loss
334 waveArgs.x_cyclical = true; // Enable cylindrical wrapping!
335 waveArgs.crgbMap = fl::make_shared<fl::WaveCrgbGradientMap>(waveBluepal); // Default color palette
336
337 // Create wave effect with cylindrical mapping
338 waveFx = fl::make_shared<fl::WaveFx>(xyRect, waveArgs);
339
340 // Create blender for wave effects (allows multiple wave layers in future)
341 waveBlend = fl::make_shared<fl::Blend2d>(xyRect);
342 waveBlend->add(waveFx);
343
344 // Initialize fl::Animartrix effect
345 fl::XYMap animartrixXyMap = fl::XYMap::constructRectangularGrid(width, height, 0);
346 animartrix.reset(new fl::Animartrix(animartrixXyMap, fl::AnimartrixAnim::POLAR_WAVES)); // ok bare allocation
347 fxEngine.reset(new fl::FxEngine(width * height)); // ok bare allocation

Callers

nothing calls this directly

Calls 15

rawDataMethod · 0.80
setColorOrderMethod · 0.80
setCrgbMapMethod · 0.80
toScreenMapMethod · 0.45
setScreenMapMethod · 0.45
addMethod · 0.45
resetMethod · 0.45
addFxMethod · 0.45
nameMethod · 0.45
setSelectedIndexMethod · 0.45
onChangedMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected