New 8-bit wave functions Just committed to github on the FastLED v2.1 branch:

New 8-bit wave functions
Just committed to github on the FastLED v2.1 branch: new 8-bit wave functions: sine and cosine (sin8/cos8), as well as 8-bit cubic, quadratic, and triangle wave functions.
Notes are here:

Performance-minded developers take note: sin8/cos8 are almost twice as fast as sin16/cos16 – which were already much faster than the built-in Arduino floating point versions. Plus, the 8-bit versions seem like they’re going to be easier to use, which means that they actually help you code faster.

Furthermore, “quadwave8()” is remarkably close to “sin8()” in output values, but it executes even faster than sin8. As always, your mileage may vary, but it looks like we have some very fast new choices available now.

Play around, and see which waves you like best for your projects!

It’s interesting to note that most animation code you find “in the wild” out there uses ‘sine’ and ‘cosine’ not because those exact trig functions are needed to make the animation work correctly, but rather because (1) they look nice and smooth, and (2) they’re almost universally available in different languages and platforms.

Now that FastLED is giving you some more choices for wave functions, you can choose a wave shape that gives you the best-looking and best-performing results for your particular project.

I’m noticing that the cubic wave (cubicwave8) is a little more ‘contrasty’ than sine – it spends more time at the top and bottom of the scale, and less time in the middle. This, in particular, might be good for some situations where ‘sine’ is too slow to transition from one end of the scale to the other.

Having choices here is new! We’ll all have to play around and see what looks good!

Thank you, Mark! This is even more than I was hoping for :smiley:

Great stuff Mark - thanks!! :slight_smile:

Can’t wait to try this out. I noticed that on the wiki, I couldn’t find the page in the menu, you linked to above.

The wiki definitely needs some love. We’ve been, in this order: adding code, uploading examples, writing docs, and finally making the wiki links all work. Sorry it’s a bit of a mess now.

You can see a list of all the pages by going to the Pages link:
The wave functions page is listed there; it’s just not linked in anywhere else yet.

Looks promising! For me as a artist / web guy it would be awesome to see some small code examples to get started. Maybe nice to add some lines to the great wiki?

To get a better understanding / feeling of the new functions, I visualized them:

I really need to pay more attention to this page! Very excited here. I have been using lookup tables!