I am wondering if it’s possible to use beatsin8 (or some related beat generating function) to produce floating point and/or negative values? I would like to smoothly change the speed of a pattern back and forth by changing how quickly some index value changes. Typically, good ranges are between (-2,2), otherwise the pattern moves too quickly. But beatsin8 only generates int values, making it jerky. Is there another similar function I can use?
My attempted solution was to add a beatsin_float function in the FastLED library, in the lib8tion.h file. However, the function doesn’t seem to be saved after defining it in the file, saving, restarting arduino, reloading the library, etc. How can I add another definition here? Thank you!
@Mark_Kriegsman I don’t need much precision, maybe to two decimal places, but the important part is to allow decimal values for smooth transitions between -2,2. Sin16 is still an int value, correct? I figured the easiest thing would be to make a new sin_float definition in the library, but it doesn’t seem to save.
In general, we don’t use float in library because of how slow it is on AVR ATmega chips. We tend to prefer fixed-point math with is fast on all platforms. Hence lots of integers, which you can then scale as needed.
@Mark_Kriegsman I see, makes sense. I actually tried some of the 16-bit beat functions, dividing by 32767 to scale them, but they always rounded to the nearest integer. I assumed sin16 would behave similarly, but perhaps not. I liked the simple elegance of the beatsin function and ability to simply choose a BPM that will match other functions, but I’ll give this a shot when I get a chance after work. Thank you!
@marmil@Mark_Kriegsman Ah! That’s what it is! Works perfectly now. Most of my programming experience is in matlab, where I don’t need to worry about different data types. Thank you both for helping me catch the stupid mistake!