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 fl::CRGBPalette16 myPal = getPalette();
181
182 // Get the current time in milliseconds
183 uint32_t now = fl::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 fl::CRGB c = ColorFromPalette(myPal, palette_index, BRIGHTNESS);
202
203 // Convert our 2D coordinates to the 1D fl::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 fl::array
209 leds[index] = c;
210 }
211 }
212
213 // Send the color data to the actual LEDs
214 FastLED.show();
215}
fl::XYMap xyMap
fl::CRGB leds[NUM_LEDS]
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
#define BRIGHTNESS
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
uint8_t getPaletteIndex(uint32_t millis32, int width, int max_width, int height, int max_height, uint32_t y_speed)
fl::TimeWarp timeScale(0, 1.0f)
fl::CRGBPalette16 getPalette()
fl::UISlider speedY("SpeedY", 1.3, 1, 6,.1)
int y_speed
#define WIDTH
#define HEIGHT
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
fl::u32 uint32_t
Definition s16x16x4.h:219
u8 u8 height
Definition blur.h:186
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
u8 width
Definition blur.h:186
unsigned char uint8_t
Definition s16x16x4.h:209
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38

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

+ Here is the call graph for this function: