20 if (context.leds.empty() ||
mNumLeds == 0)
return;
22 u32 now = context.now;
32 for (
size_t i = 0; i <
mParticles.size(); i++) {
44 for (
size_t i = 0; i <
mParticles.size(); i++) {
54 for (
size_t i = 1; i <
mParticles.size(); i++) {
127 while (
pos >= numLeds)
pos -= numLeds;
128 while (
pos < 0)
pos += numLeds;
131 if (
pos >= numLeds ||
pos < 0) {
140 if (power <= 0.0f)
return;
149 float frac =
pos - i;
150 if (i >= 0 && i < (
int)numLeds)
151 leds[i] +=
color.nscale8(255 * (1.0f - frac));
152 if (i + 1 >= 0 && i + 1 < (
int)numLeds && frac > 0)
153 leds[i + 1] +=
color.nscale8(255 * frac);
Fx1d(u16 numLeds) FL_NO_EXCEPT
Particles1d(u16 num_leds, u8 max_particles=10, u8 fade_rate=2) FL_NO_EXCEPT
void setSpeed(float speed) FL_NO_EXCEPT
Set speed multiplier (1.0 = normal, >1.0 = faster, <1.0 = slower)
fl::vector< Particle > mParticles
Particle pool (oldest particle reused when full)
u8 mFadeRate
Fade amount per frame (0-255, higher = shorter trails)
fl::string fxName() const FL_NO_EXCEPT override
~Particles1d() FL_NO_EXCEPT
void setLifetime(u16 lifetime_ms) FL_NO_EXCEPT
Set average particle lifetime in milliseconds.
void spawnRandomParticle() FL_NO_EXCEPT
Spawn a particle with random position, velocity, color, and lifetime.
void setCyclical(bool cyclical) FL_NO_EXCEPT
Set cyclical mode (true = wrap around, false = stop at edges)
u8 mOverdrawCount
Number of update/draw cycles per frame (higher = smoother trails, more CPU)
u16 mLifetimeMs
Average particle lifetime in milliseconds.
float mSpeedMultiplier
Global speed multiplier (1.0 = normal, >1.0 = faster, <1.0 = slower)
bool mCyclical
Wrap mode: true = wrap around, false = stop at edges.
void draw(DrawContext context) FL_NO_EXCEPT override
Update and render all particles with overdraw technique.
void setFadeRate(u8 fade_rate) FL_NO_EXCEPT
Set fade rate for trails (0-255, higher = shorter trails)
void setOverdrawCount(u8 count) FL_NO_EXCEPT
Set overdraw count (higher = smoother trails, more CPU)
Internal FastLED header for implementation files.
LIB8STATIC fl::u16 random16() FL_NO_EXCEPT
Generate a 16-bit random number.
LIB8STATIC fl::u8 random8() FL_NO_EXCEPT
Generate an 8-bit random number.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NO_EXCEPT
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
void blur1d(fl::span< CRGB > leds, fract8 blur_amount) FL_NO_EXCEPT
Base definition for an LED controller.
Representation of an 8-bit RGB pixel (Red, Green, Blue)
CHSV baseColor
Base color (HSV) - saturation increases with age.
bool active
Active flag (false = available for reuse)
float pos
Position (floating point for sub-pixel rendering)
float baseVel
Base velocity (actual velocity = baseVel × power)
void draw(fl::span< CRGB > leds, u32 now, u16 numLeds) FL_NO_EXCEPT
Render particle with sub-pixel accuracy and power-modulated color.
void update(u32 now, u16 numLeds, float speedMultiplier, bool cyclical) FL_NO_EXCEPT
Update position based on velocity × power.
u32 lifetime
Lifespan in milliseconds.
u32 birthTime
Spawn timestamp (ms)
void spawn(u16 numLeds) FL_NO_EXCEPT
Spawn with random position, velocity, color, and lifetime.
float getPower(u32 now) const FL_NO_EXCEPT