|
FastLED 3.9.15
|
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.
Because of the AVR (Arduino) and ARM assembly language implementations provided, using these functions often results in smaller and faster code than the equivalent program using plain "C" arithmetic and logic.
Included are:
Scaling (down) of unsigned 8- and 16- bit values. Scaledown value is specified in 1/256ths.
Example: scaling a 0-255 value down into a range from 0-99:
A special version of scale8 is provided for scaling LED brightness values, to make sure that they don't accidentally scale down to total black at low dimming levels, since that would look wrong:
Example: reducing an LED brightness by a dimming factor:
Fast 16-bit approximations of sin and cos. Input angle is a uint16_t from 0-65535. Output is a signed int16_t from -32767 to 32767.
Accurate to more than 99% in all cases.
Fast 8-bit approximations of sin and cos. Input angle is a uint8_t from 0-255. Output is an UNsigned uint8_t from 0 to 255.
Accurate to within about 2%.
Dimming and brightening functions for 8-bit light values.
The dimming functions in particular are suitable for making LED light output appear more 'linear'.
Beat generators which return sine or sawtooth waves in a specified number of Beats Per Minute. Sine wave beat generators can specify a low and high range for the output. Sawtooth wave beat generators always range 0-255 or 0-65535.
BPM is beats per minute in either simple form e.g. 120, or Q8.8 fixed-point form. BPM88 is beats per minute in ONLY Q8.8 fixed-point form.
Lib8tion is pronounced like 'libation': lie-BAY-shun
Collaboration diagram for Fast Math Functions:Topics | |
| Easing Functions | |
| Specify the rate of change of a parameter over time. | |
| Fast Random Number Generators | |
| Fast 8-bit and 16-bit unsigned random number generators. | |
| Fixed-Point Fractional Types. | |
| Types for storing fractional data. | |
| Float-to-Fixed and Fixed-to-Float Conversions | |
| Functions to convert between floating point and fixed point types. | |
| Integer Mapping Functions | |
| Maps a scalar from one integer size to another. | |
| Linear Interpolation | |
| Fast linear interpolation functions, such as could be used for Perlin noise, etc. | |
| Waveform Generators | |
| General purpose wave generator functions. | |
Classes | |
| class | CEveryNMillisDynamic |
| Create the CEveryNMillisDynamic class for dynamic millisecond intervals. More... | |
| class | CEveryNMillisRandom |
| class | CEveryNTime |
| Time interval checking class. More... | |
Macros | |
| #define | INSTANTIATE_EVERY_N_TIME_PERIODS(NAME, TIMETYPE, TIMEGETTER) |
Preprocessor-based class "template" for CEveryNTime, used with EVERY_N_TIME timekeepers. | |
| #define | LIB8STATIC __attribute__ ((unused)) static inline |
| Define a LIB8TION member function as static inline with an "unused" attribute. | |
| #define | LIB8STATIC_ALWAYS_INLINE FL_ALWAYS_INLINE |
| Define a LIB8TION member function as always static inline This macro is deprecated and should be replaced with FL_ALWAYS_INLINE. | |
CEveryNTime Base Classes | |
These macros define the time interval checking classes used in the | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNMillis, fl::u32, GET_MILLIS) | |
| Create the CEveryNMillis class for millisecond intervals. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNSeconds, fl::u16, seconds16) | |
| Create the CEveryNSeconds class for second intervals. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNBSeconds, fl::u16, bseconds16) | |
| Create the CEveryNBSeconds class for bsecond intervals. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNMinutes, fl::u16, minutes16) | |
| Create the CEveryNMinutes class for minutes intervals. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNHours, fl::u8, hours8) | |
| Create the CEveryNHours class for hours intervals. | |
| #define | CEveryNMilliseconds CEveryNMillis |
| Alias for CEveryNMillis. | |
"EVERY_N_TIME" Macros | |
Check whether to excecute a block of code every N amount of time. These are useful for limiting how often code runs. For example, you can use fill_rainbow() to fill a strip of LEDs with color, combined with an EVERY_N_MILLIS block to limit how fast the colors change: void fill_rainbow(CRGB *targetArray, int numToFill, u8 initialhue, u8 deltahue) Fill a range of LEDs with a rainbow of colors. Definition fill.cpp.hpp:29 #define EVERY_N_MILLIS(N) Checks whether to execute a block of code every N milliseconds. Definition lib8tion.h:1001 Note that in order for these to be accurate, the EVERY_N block must be evaluated at a regular basis. | |
| #define | EVERY_N_MILLIS(N) |
| Checks whether to execute a block of code every N milliseconds. | |
| #define | EVERY_N_MILLIS_I(NAME, N) |
| Checks whether to execute a block of code every N milliseconds, using a custom instance name. | |
| #define | EVERY_N_SECONDS(N) |
| Checks whether to execute a block of code every N seconds. | |
| #define | EVERY_N_SECONDS_I(NAME, N) |
| Checks whether to execute a block of code every N seconds, using a custom instance name. | |
| #define | EVERY_N_BSECONDS(N) |
| Checks whether to execute a block of code every N bseconds. | |
| #define | EVERY_N_BSECONDS_I(NAME, N) |
| Checks whether to execute a block of code every N bseconds, using a custom instance name. | |
| #define | EVERY_N_MINUTES(N) |
| Checks whether to execute a block of code every N minutes. | |
| #define | EVERY_N_MINUTES_I(NAME, N) |
| Checks whether to execute a block of code every N minutes, using a custom instance name. | |
| #define | EVERY_N_HOURS(N) |
| Checks whether to execute a block of code every N hours. | |
| #define | EVERY_N_HOURS_I(NAME, N) |
| Checks whether to execute a block of code every N hours, using a custom instance name. | |
| #define | EVERY_N_MILLISECONDS(N) |
| Alias for EVERY_N_MILLIS. | |
| #define | EVERY_N_MILLISECONDS_I(NAME, N) |
| Alias for EVERY_N_MILLIS_I. | |
| #define | EVERY_N_MILLISECONDS_DYNAMIC(PERIOD_FUNC) |
| Checks whether to execute a block of code every N milliseconds, where N is determined dynamically. | |
| #define | EVERY_N_MILLISECONDS_DYNAMIC_I(NAME, PERIOD_FUNC) |
| Checks whether to execute a block of code every N milliseconds, where N is determined dynamically, using a custom instance name. | |
| #define | EVERY_N_MILLISECONDS_RANDOM(MIN, MAX) |
| #define | EVERY_N_MILLISECONDS_RANDOM_I(NAME, MIN, MAX) |