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

◆ setup()

void setup ( )

Definition at line 104 of file AnimartrixRing.ino.

104 {
105 Serial.begin(115200);
106
107 // Setup LED strip
108 fl::ScreenMap screenMapLocal(screenmap);
109 screenMapLocal.setDiameter(
110 0.15); // 0.15 cm or 1.5mm - appropriate for dense 144 LED rope
111 FastLED.addLeds<WS2812, PIN_DATA>(leds, NUM_LEDS)
112 .setCorrection(TypicalLEDStrip)
113 .setScreenMap(screenMapLocal);
114 FastLED.setBrightness(brightness.value());
115
116 // Add the 2D-to-1D effect to FxEngine
117 fxEngine.addFx(fx2dTo1d);
118
119 // Route audio through FastLED.add() for auto-pump when available.
120 // gAutoPump may only be set true when FastLED.add() actually returned a
121 // live processor -- otherwise loop() would skip the manual pump path and
122 // the orchestrator would never see any samples.
123 auto input = audio.audioInput();
124 if (input) {
125 gAudioProcessor = FastLED.add(input);
126 if (gAudioProcessor) {
127 gAutoPump = true;
128 printf("AnimartrixRing: Audio routed via FastLED.add() (auto-pump)\n");
129 }
130 }
131 if (!gAudioProcessor) {
133 gAutoPump = false;
134 printf("AnimartrixRing: Audio using manual pump (fallback)\n");
135 }
136
137 // Build the 3-state orchestrator. It owns nothing: it just polls the
138 // Processor, asks the Animartrix to switch banks, and pokes the FxEngine
139 // speed on every frame.
142 gOrchestrator->begin();
143
144 // Log state transitions so a developer can see the classifier in action.
145 static animartrix_ring::SoundState sLastState =
147 (void)sLastState;
148
149 Serial.println("AnimartrixRing setup complete (3-state orchestrator)");
150}
fl::UIAudio audio("Audio Input")
fl::FxEngine fxEngine(NUM_LEDS)
#define NUM_LEDS
fl::Animartrix animartrix(xyMap, FIRST_ANIMATION)
#define PIN_DATA
fl::CRGB leds[NUM_LEDS]
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
fl::ScreenMap screenmap
bool gAutoPump
fl::shared_ptr< animartrix_ring::SoundOrchestrator > gOrchestrator
fl::shared_ptr< fl::audio::Processor > gAudioProcessor
auto fx2dTo1d
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:15
void printf(const char *format, const Args &... args) FL_NOEXCEPT
Printf-like formatting function that prints directly to the platform output.
Definition stdio.h:635
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
#define Serial
Definition serial.h:304

References animartrix, audio, brightness, FastLED, fx2dTo1d, fxEngine, gAudioProcessor, gAutoPump, gOrchestrator, leds, fl::make_shared(), NUM_LEDS, PIN_DATA, screenmap, Serial, fl::ScreenMap::setDiameter(), animartrix_ring::Silence, and TypicalLEDStrip.

+ Here is the call graph for this function: