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

◆ loop()

void loop ( )

Definition at line 173 of file FireCylinder.h.

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

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: