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

◆ loop()

void loop ( )

Definition at line 52 of file Particles1d.h.

52 {
53 uint32_t now = fl::millis();
54
55 // Update effect parameters from UI
56 FastLED.setBrightness(uiBrightness.as<int>());
57 particles.setSpeed(uiSpeed.as<float>());
58 particles.setFadeRate(uiFadeAmount.as<int>());
59 particles.setLifetime(uiLifetime.as<float>() * 1000);
60 particles.setOverdrawCount(uiOverdrawCount.as<int>());
61 particles.setCyclical(uiCyclical.value());
62
63 // Manual spawn
64 if (uiSpawnButton.clicked()) {
65 particles.spawnRandomParticle();
66 }
67
68 // Auto spawn (external control)
69 if (uiAutoSpawn.value() && now - lastSpawnTime >= uiSpawnInterval.as<float>() * 1000) {
70 particles.spawnRandomParticle();
71 lastSpawnTime = now;
72 }
73
74 // Draw particles
76
77 FastLED.show();
78 delay(20);
79}
fl::CRGB leds[NUM_LEDS]
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
uint32_t lastSpawnTime
Definition Particles1d.h:44
fl::UISlider uiBrightness("Brightness", 64, 0, 255, 1)
fl::UIButton uiSpawnButton("Spawn Particle")
fl::Particles1d particles(NUM_LEDS, PARTICLE_MAX, PARTICLE_GROUPS)
fl::UICheckbox uiAutoSpawn("Auto Spawn", true)
fl::UISlider uiFadeAmount("Trail Length", 2, 0, 10, 1)
fl::UISlider uiOverdrawCount("Overdraw Count", 20, 1, 50, 1)
fl::UISlider uiLifetime("Avg Lifetime (sec)", 4.0, 0.5, 8.0, 0.5)
fl::UISlider uiSpeed("Avg Speed", 1.0, 0.1, 3.0, 0.1)
fl::UISlider uiSpawnInterval("Spawn Interval (sec)", 2.0, 0.1, 10.0, 0.1)
fl::UICheckbox uiCyclical("Cyclical", true)
::fl::DrawContext DrawContext
Definition fx.h:21
fl::u32 uint32_t
Definition s16x16x4.h:219
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
void delay(u32 ms, bool run_async=true) FL_NOEXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
Definition delay.h:98

References FastLED, lastSpawnTime, leds, fl::millis(), particles(), uiAutoSpawn(), uiBrightness(), uiCyclical(), uiFadeAmount(), uiLifetime(), uiOverdrawCount(), uiSpawnButton(), uiSpawnInterval(), and uiSpeed().

+ Here is the call graph for this function: