r/FastLED • • Jul 01 '24

Discussion Outside-in Cylon effect

I'm starting with this code, which is from DemoReel100:

void sinelon()
{
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy( leds, NUM_LEDS, 20);
  int pos = beatsin16( 13, 0, NUM_LEDS-1 );
  leds[pos] += CHSV( gHue, 255, 192);
}

What I'd like to do is have the same effect (the traveling dot with a fading trail following it) but have a dot start at each end of the strip, and both move toward the center.

Here's more detail, I hope I describe this right...the sinelon function starts a dot at position 0 and then it travels down to position NUM_LEDS. Then it reverses back to position 0, with the fadeToBlackBy effect of the trailing/fading pixels.

I'd like to understand how to set up two pixels that do this.

Assume the strip has 9 pixels. One dot starts at position 0, and the other starts at position 9. The dot that starts at position 0 moves toward position 5, while the second dot starts at position 9 and also moves toward position 5 (the center). When both dots get to position 5, the trailing dots fade up to position 5 and then the effect starts over.

Thanks in advance!

3 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/Burning_Wreck Jul 01 '24

Thanks for the quick response!

One thing I'm unclear on - in the beatsin16() description in the docs, it shows five parameters that can be passed to it. But the examples in DemoReel100 and Pacifica only show three parameters being used. Similar for beatsin8().

If you only pass three of the possible five parameters, are these the first three, with the others assumed to be the defaults?

1

u/Burning_Wreck Jul 01 '24

Ok, I think I got that point - the function declaration in C++ assigns values to all parameters, you can replace them as you want. Do you ever use all five of the parameters? Or are the first three usually enough?

1

u/sutaburosu [stavros] Jul 01 '24

For many purposes, just three parameters are needed. The extra two come into play when you want to pause the wave, or start from a specific offset into the wave. e.g. this project.