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

◆ loop()

void loop ( )

Definition at line 172 of file FireCylinder.h.

172 {
173 // The main program loop that runs continuously
174
175 // Set the overall brightness from the UI slider
176 FastLED.setBrightness(brightness);
177
178 // Get the selected color palette
179 CRGBPalette16 myPal = getPalette();
180
181 // Get the current time in milliseconds
182 uint32_t now = millis();
183
184 // Update the animation speed from the UI slider
185 timeScale.setSpeed(speedY);
186
187 // Calculate the current y-offset for animation (makes the fire move)
188 uint32_t y_speed = timeScale.update(now);
189
190 // Loop through every LED in our cylindrical matrix
191 for (int width = 0; width < WIDTH; width++) {
192 for (int height = 0; height < HEIGHT; height++) {
193 // Calculate which color to use from our palette for this LED
194 // This function handles the cylindrical mapping using sine/cosine
195 uint8_t palette_index =
196 getPaletteIndex(now, width, WIDTH, height, HEIGHT, y_speed);
197
198 // Get the actual RGB color from the palette
199 // BRIGHTNESS ensures we use the full brightness range
200 CRGB c = ColorFromPalette(myPal, palette_index, BRIGHTNESS);
201
202 // Convert our 2D coordinates to the 1D array index
203 // We use (WIDTH-1)-width and (HEIGHT-1)-height to flip the coordinates
204 // This makes the fire appear to rise from the bottom
205 int index = xyMap((WIDTH - 1) - width, (HEIGHT - 1) - height);
206
207 // Set the LED color in our array
208 leds[index] = c;
209 }
210 }
211
212 // Send the color data to the actual LEDs
213 FastLED.show();
214}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define WIDTH
Definition Blur2d.ino:9
#define HEIGHT
Definition Blur2d.ino:10
#define BRIGHTNESS
Definition Blur.ino:8
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:62
CRGBPalette16 getPalette()
TimeWarp timeScale(0, 1.0f)
uint8_t getPaletteIndex(uint32_t millis32, int width, int max_width, int height, int max_height, uint32_t y_speed)
UISlider speedY("SpeedY", 1.3, 1, 6,.1)
UISlider brightness("Brightness", 1, 0, 1)
int y_speed
XYMap xyMap
Definition gfx.cpp:8
CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index, uint8_t brightness, TBlendType blendType)
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55

References BRIGHTNESS, brightness, fl::ColorFromPalette(), FastLED, getPalette(), getPaletteIndex(), HEIGHT, leds, speedY(), timeScale(), WIDTH, xyMap, and y_speed.

+ Here is the call graph for this function: