Profile cover photo
Profile photo
Andrew Tuline
102 followers -
IT/tech involved with the community.
IT/tech involved with the community.

102 followers
About
Communities and Collections
Posts

beatsin8() and beatsin16() are very cool functions.

I'm wondering if anyone has managed to change parameters on the fly without completely resetting the beat? I'd really like for the beat to continue at the current location, but with modified parameters, such as reversing the phase or changing the speed.

Here's the parameters:

uint16_t beatsin16( accum88 beats_per_minute, uint16_t lowest = 0, uint16_t highest = 65535, uint32_t timebase = 0, uint16_t phase_offset = 0)

For instance, I modified the 16 bit phase_offset value (to change direction), but it appeared to set the absolute phase instead of the relative phase.

I've been thinking about animation speeds lately; that is to provide a fixed animation speed for a routine even if other overhead has been added to the overall code. The 3 things that come to mind are:


// insert a delay to keep the framerate modest, as used in demoreel100
FastLED.delay(1000/FRAMES_PER_SECOND);

I'm not really sure that this would help us out, but then I'm not sure how FastLED.delay() works.

The other options that I think are more viable to keep a fixed animation speed are to use:

EVERY_N_MILLISECONDS(20) { routine(); }

Note: There is a method to make the above '20' a variable, so this could be used by routines with different animation speeds.

Another method would be to use mills() instead of an incremental counter between frames in a routine. As the overhead increases, the frame rate decreases. By using millis(), the animation appears the same, but the pixels may move imperceptibly more or less between animations.

Any thoughts on this?

Post has attachment
Add a comment...

Post has attachment
Add a comment...

Post has attachment
One of the top exhibits at Burning Man (which I did not attend) was the Tree of Ténéré (which I was not involved with). Here's a couple of videos I found of it in action:

https://www.youtube.com/watch?v=czGBkVrNQKs

https://www.youtube.com/watch?v=O-kWR9LNkq0

PSA: Writing to leds[NUM_LEDS] can be bad for your health.

Scenario 1: You write a standalone animation and it works like a charm.

Scenario 2: Someone else integrates your animation and it crashes due to that animation writing to leds[NUM_LEDS].

A prime example is:

int posn = beatsin16(13, 0, NUM_LEDS);
leds[posn] = CRGB::white;

At some point the value of posn will be NUM_LEDS and it will write to one LED beyond the end. It may break your code and it may not. It will probably break the code of the programmer who re-uses it in another fashion.

Post has attachment
Add a comment...

Post has attachment
Here's another really short routine that uses noise() instead of sine waves to move pixels up and down a strand. Code is shown in the Youtube link.

Post has attachment
Add a comment...

Post has attachment
Add a comment...
Wait while more posts are being loaded