FastLED 3.9.15
Loading...
Searching...
No Matches

◆ setup()

void setup ( )

Definition at line 302 of file curr.h.

302 {
303 // Use constexpr dimensions (computed at compile time)
304 constexpr int width = CORKSCREW_WIDTH; // = 16
305 constexpr int height = CORKSCREW_HEIGHT; // = 18
306
307
308 // Noise controls are now automatically grouped by the UIGroup constructor
309 // The noiseGroup variadic constructor automatically called setGroup() on all controls
310
311
312 // Or use runtime corkscrew for dynamic sizing
313 // int width = corkscrew.cylinder_width();
314 // int height = corkscrew.cylinder_height();
315
316 XYMap xyMap = XYMap::constructRectangularGrid(width, height, 0);
317
318 // Use the corkscrew's internal buffer for the LED strip
320 &FastLED.addLeds<APA102HD, PIN_DATA, PIN_CLOCK, BGR>(corkscrew.rawData(), NUM_LEDS);
321
322 // CLEDController *controller =
323 // &FastLED.addLeds<WS2812, 3, BGR>(stripLeds, NUM_LEDS);
324
325 // NEW: Create ScreenMap directly from Corkscrew using toScreenMap()
326 // This maps each LED index to its exact position on the corkscrew spiral
327 // instead of using a rectangular grid mapping
328 ScreenMap corkscrewScreenMap = corkscrew.toScreenMap(0.2f);
329
330 // OLD WAY (rectangular grid - not accurate for corkscrew visualization):
331 // ScreenMap screenMap = xyMap.toScreenMap();
332 // screenMap.setDiameter(.2f);
333
334 // Set the corkscrew screen map for the controller
335 // This allows the web interface to display the actual corkscrew spiral shape
336 controller->setScreenMap(corkscrewScreenMap);
337
338 // Initialize wave effects for cylindrical surface
339 XYMap xyRect(width, height, false); // Rectangular grid for wave simulation
340 WaveFx::Args waveArgs;
341 waveArgs.factor = SuperSample::SUPER_SAMPLE_2X; // 2x supersampling for smoother waves
342 waveArgs.half_duplex = true; // Only positive waves
343 waveArgs.auto_updates = true; // Auto-update simulation
344 waveArgs.speed = 0.16f; // Wave propagation speed
345 waveArgs.dampening = 6.0f; // Wave energy loss
346 waveArgs.x_cyclical = true; // Enable cylindrical wrapping!
347 waveArgs.crgbMap = fl::make_shared<WaveCrgbGradientMap>(waveBluepal); // Default color palette
348
349 // Create wave effect with cylindrical mapping
350 waveFx = fl::make_shared<WaveFx>(xyRect, waveArgs);
351
352 // Create blender for wave effects (allows multiple wave layers in future)
354 waveBlend->add(waveFx);
355
356 // Initialize Animartrix effect
357 XYMap animartrixXyMap = XYMap::constructRectangularGrid(width, height, 0);
358 animartrix.reset(new Animartrix(animartrixXyMap, POLAR_WAVES));
359 fxEngine.reset(new FxEngine(width * height));
360 fxEngine->addFx(*animartrix);
361
362 // Demonstrate UIGroup functionality for noise controls
363 FL_WARN("Noise UI Group initialized: " << noiseGroup.name());
364 FL_WARN(" This group contains noise pattern controls:");
365 FL_WARN(" - Use Noise Pattern toggle");
366 FL_WARN(" - Noise Scale and Speed sliders");
367 FL_WARN(" - Color Palette selection for noise");
368 FL_WARN(" UIGroup automatically applied group membership via variadic constructor");
369
370 // Set initial dropdown selections
371 paletteDropdown.setSelectedIndex(0); // Party
372 renderModeDropdown.setSelectedIndex(0); // Fire (new default)
373
374 // Add onChange callbacks for dropdowns
375 paletteDropdown.onChanged([](UIDropdown &dropdown) {
376 string selectedPalette = dropdown.value();
377 FL_WARN("Noise palette changed to: " << selectedPalette);
378 if (selectedPalette == "Party") {
380 } else if (selectedPalette == "Heat") {
382 } else if (selectedPalette == "Ocean") {
384 } else if (selectedPalette == "Forest") {
386 } else if (selectedPalette == "Rainbow") {
388 }
389 });
390
391 renderModeDropdown.onChanged([](UIDropdown &dropdown) {
392 string mode = dropdown.value();
393 // Simple example of using getOption()
394 for(size_t i = 0; i < dropdown.getOptionCount(); i++) {
395 if(dropdown.getOption(i) == mode) {
396 FL_WARN("Render mode changed to: " << mode);
397 }
398 }
399 });
400
401 // Add onChange callback for animartrix color order
402 animartrixColorOrder.onChanged([](int value) {
403 EOrder order = RGB;
404 switch(value) {
405 case 0: order = RGB; break;
406 case 1: order = RBG; break;
407 case 2: order = GRB; break;
408 case 3: order = GBR; break;
409 case 4: order = BRG; break;
410 case 5: order = BGR; break;
411 }
412 if (animartrix.get()) {
413 animartrix->setColorOrder(order);
414 }
415 });
416
417
418 waveFx->setCrgbMap(crgMap);
419
420 frameBufferPtr = corkscrew.getOrCreateInputSurface();
421}
#define NUM_LEDS
#define PIN_DATA
Definition simple.h:52
fl::XYMap xyMap
Definition ColorBoost.h:61
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:74
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:126
CLEDController * controller
Base definition for an LED controller.
Manages and renders multiple visual effects (Fx) for LED strips.
Definition fx_engine.h:33
fl::size getOptionCount() const
Definition ui.h:456
fl::string getOption(fl::size index) const
Definition ui.h:457
fl::string value() const
Definition ui.h:448
WaveFxArgs Args
Definition wave.h:83
static XYMap constructRectangularGrid(u16 width, u16 height, u16 offset=0)
Definition xymap.cpp:34
UIDropdown paletteDropdown("Color Palette", paletteOptions)
fl::unique_ptr< Animartrix > animartrix
Definition curr.h:298
UIGroup noiseGroup("Noise Controls", noiseScale, noiseSpeed, paletteDropdown)
#define PIN_CLOCK
Definition curr.h:52
Blend2dPtr waveBlend
Definition curr.h:295
UIDropdown renderModeDropdown("Render Mode", renderModeOptions)
constexpr uint16_t CORKSCREW_HEIGHT
Definition curr.h:274
UINumberField animartrixColorOrder("Animartrix Color Order", 0, 0, 5)
WaveFxPtr waveFx
Definition curr.h:294
fl::unique_ptr< FxEngine > fxEngine
Definition curr.h:299
constexpr uint16_t CORKSCREW_WIDTH
Definition curr.h:272
fl::shared_ptr< Grid< CRGB > > frameBufferPtr
Definition curr.h:291
WaveCrgbGradientMapPtr crgMap
Definition curr.h:300
CRGBPalette16 noisePalette
Definition curr.h:255
Corkscrew corkscrew(CORKSCREW_TURNS, NUM_LEDS)
const TProgmemRGBPalette16 OceanColors_p
Ocean colors, blues and whites.
const TProgmemRGBPalette16 HeatColors_p
Approximate "black body radiation" palette, akin to the FastLED HeatColor() function.
const TProgmemRGBPalette16 ForestColors_p
Forest colors, greens.
const TProgmemRGBPalette16 PartyColors_p
HSV color ramp: blue, purple, pink, red, orange, yellow (and back).
const TProgmemRGBPalette16 RainbowColors_p
HSV Rainbow.
@ POLAR_WAVES
shared_ptr< T > make_shared(Args &&... args)
Definition shared_ptr.h:348
EOrder
RGB color channel orderings, used when instantiating controllers to determine what order the controll...
Definition eorder.h:13
@ RBG
Red, Blue, Green (0021)
Definition eorder.h:15
@ BGR
Blue, Green, Red (0210)
Definition eorder.h:19
@ GBR
Green, Blue, Red (0120)
Definition eorder.h:17
@ GRB
Green, Red, Blue (0102)
Definition eorder.h:16
@ BRG
Blue, Red, Green (0201)
Definition eorder.h:18
@ RGB
Red, Green, Blue (0012)
Definition eorder.h:14
float speed
Definition wave.h:74
bool x_cyclical
Definition wave.h:76
WaveCrgbMapPtr crgbMap
Definition wave.h:77
bool auto_updates
Definition wave.h:73
SuperSample factor
Definition wave.h:71
float dampening
Definition wave.h:75
bool half_duplex
Definition wave.h:72
#define FL_WARN
Definition warn.h:12

References animartrix, animartrixColorOrder(), APA102HD, fl::WaveFxArgs::auto_updates, fl::BGR, fl::BRG, fl::XYMap::constructRectangularGrid(), controller, corkscrew(), CORKSCREW_HEIGHT, CORKSCREW_WIDTH, fl::WaveFxArgs::crgbMap, crgMap, fl::WaveFxArgs::dampening, fl::WaveFxArgs::factor, FastLED, FL_WARN, ForestColors_p, frameBufferPtr, fxEngine, fl::GBR, fl::UIDropdown::getOption(), fl::UIDropdown::getOptionCount(), fl::GRB, fl::WaveFxArgs::half_duplex, HeatColors_p, fl::make_shared(), noiseGroup(), noisePalette, NUM_LEDS, OceanColors_p, paletteDropdown(), PartyColors_p, PIN_CLOCK, PIN_DATA, fl::POLAR_WAVES, RainbowColors_p, fl::RBG, renderModeDropdown(), fl::RGB, fl::WaveFxArgs::speed, fl::SUPER_SAMPLE_2X, fl::UIDropdown::value(), waveBlend, waveFx, fl::WaveFxArgs::x_cyclical, and xyMap.

+ Here is the call graph for this function: