FastLED 3.9.15
Loading...
Searching...
No Matches
Particles1d.h
Go to the documentation of this file.
1
12
13#include <FastLED.h>
14
15#include "fl/fx/1d/particles.h"
16#include "fl/math/screenmap.h"
17#include "fl/ui/ui.h"
18
19
20#define NUM_LEDS 210
21#define PARTICLE_MAX 10
22#define PARTICLE_GROUPS 2
23
24
25#define DATA_PIN 3
26
28
29// UI Controls
30fl::UISlider uiSpeed("Avg Speed", 1.0, 0.1, 3.0, 0.1);
31fl::UISlider uiFadeAmount("Trail Length", 2, 0, 10, 1);
32fl::UISlider uiBrightness("Brightness", 64, 0, 255, 1);
33fl::UISlider uiLifetime("Avg Lifetime (sec)", 4.0, 0.5, 8.0, 0.5);
34fl::UISlider uiSpawnInterval("Spawn Interval (sec)", 2.0, 0.1, 10.0, 0.1);
35fl::UISlider uiOverdrawCount("Overdraw Count", 20, 1, 50, 1);
36fl::UICheckbox uiCyclical("Cyclical", true);
37fl::UICheckbox uiAutoSpawn("Auto Spawn", true);
38fl::UIButton uiSpawnButton("Spawn Particle");
39
40// Create particles effect with adjusted parameters for memory-constrained platforms
42
43// External spawn management
44uint32_t lastSpawnTime = 0;
45
46void setup() {
48 FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS).setScreenMap(screenMap);
49 FastLED.setBrightness(64);
50}
51
52void loop() {
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}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
#define DATA_PIN
Definition ClientReal.h:82
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
uint32_t lastSpawnTime
Definition Particles1d.h:44
#define PARTICLE_MAX
Definition Particles1d.h:21
fl::UISlider uiBrightness("Brightness", 64, 0, 255, 1)
#define PARTICLE_GROUPS
Definition Particles1d.h:22
fl::UIButton uiSpawnButton("Spawn Particle")
fl::Particles1d particles(NUM_LEDS, PARTICLE_MAX, PARTICLE_GROUPS)
fl::UICheckbox uiAutoSpawn("Auto Spawn", true)
void setup()
Definition Particles1d.h:46
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)
void loop()
Definition Particles1d.h:52
::fl::DrawContext DrawContext
Definition fx.h:21
Power-based particle system for 1D LED strips creating organic light effects.
Definition particles.h:52
static ScreenMap Circle(int numLeds, float cm_between_leds=1.5f, float cm_led_diameter=0.5f, float completion=1.0f) FL_NOEXCEPT
constexpr EOrder GRB
Definition eorder.h:19
fl::ScreenMap screenMap
Definition Corkscrew.h:101
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
Aggregator header for the fl/ui/ family of per-element UI types.