|
FastLED 3.9.15
|
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.
Definition in file lib8tion.h.
#include "fl/math/types.h"#include "fl/stl/compiler_control.h"#include "led_sysdefs.h"#include "platforms/is_platform.h"#include "fl/stl/stdint.h"#include "fl/math/lib8static.h"#include "fl/math/math8.h"#include "fl/math/qfx.h"#include "fl/math/memmove.h"#include "platforms/math8_config.h"#include "fl/math/ease.h"#include "fl/math/squarewave.h"#include "fl/math/beat.h"#include "fl/math/time_functions.h"#include "fl/stl/chrono.h"#include "fl/math/scale8.h"#include "fl/math/random8.h"#include "fl/math/trig8.h"
Include dependency graph for lib8tion.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| class | CEveryNMillisDynamic |
| Create the CEveryNMillisDynamic class for dynamic millisecond intervals. More... | |
| class | CEveryNMillisRandom |
| class | CEveryNTime |
| Time interval checking class. More... | |
Macros | |
| #define | __INC_LIB8TION_H |
| #define | GET_MILLIS fl::millis |
| The a number of functions need access to a millisecond counter in order to keep time. | |
| #define | INSTANTIATE_EVERY_N_TIME_PERIODS(NAME, TIMETYPE, TIMEGETTER) |
Preprocessor-based class "template" for CEveryNTime, used with EVERY_N_TIME timekeepers. | |
| #define | USE_GET_MILLISECOND_TIMER |
| Set this flag to use the get_millisecond_timer() function in place of the default millis() function. | |
"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: static uint8_t hue = 0;
void fill_rainbow(CRGB *targetArray, int numToFill, fl::u8 initialhue, fl::u8 deltahue=5) FL_NOEXCEPT 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_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_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_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_MILLISECONDS(N) |
| Alias for EVERY_N_MILLIS. | |
| #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_I(NAME, N) |
| Alias for EVERY_N_MILLIS_I. | |
| #define | EVERY_N_MILLISECONDS_RANDOM(MIN, MAX) |
| #define | EVERY_N_MILLISECONDS_RANDOM_I(NAME, MIN, MAX) |
| #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_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. | |
Typedefs | |
| typedef fl::i64 | i64 |
| typedef signed char | i8 |
| typedef qfx< u16, 12, 4 > | q124 |
| A 12.4 integer (12 bits integer, 4 bits fraction) | |
| typedef qfx< u8, 4, 4 > | q44 |
| A 4.4 integer (4 bits integer, 4 bits fraction) | |
| typedef qfx< u8, 6, 2 > | q62 |
| A 6.2 integer (6 bits integer, 2 bits fraction) | |
| typedef qfx< u16, 8, 8 > | q88 |
| A 8.8 integer (8 bits integer, 8 bits fraction) | |
| typedef fl::u64 | u64 |
| typedef unsigned char | u8 |
Functions | |
| LIB8STATIC u16 | beat16 (accum88 beats_per_minute, u32 timebase=0) FL_NOEXCEPT |
| Generates a 16-bit "sawtooth" wave at a given BPM. | |
| LIB8STATIC u8 | beat8 (accum88 beats_per_minute, u32 timebase=0) FL_NOEXCEPT |
| Generates an 8-bit "sawtooth" wave at a given BPM. | |
| LIB8STATIC u16 | beat88 (accum88 beats_per_minute_88, u32 timebase=0) FL_NOEXCEPT |
| Generates a 16-bit "sawtooth" wave at a given BPM, with BPM specified in Q8.8 fixed-point format. | |
| LIB8STATIC u16 | beatsin16 (accum88 beats_per_minute, u16 lowest=0, u16 highest=65535, u32 timebase=0, u16 phase_offset=0) FL_NOEXCEPT |
| Generates a 16-bit sine wave at a given BPM that oscillates within a given range. | |
| LIB8STATIC u8 | beatsin8 (accum88 beats_per_minute, u8 lowest=0, u8 highest=255, u32 timebase=0, u8 phase_offset=0) FL_NOEXCEPT |
| Generates an 8-bit sine wave at a given BPM that oscillates within a given range. | |
| LIB8STATIC u16 | beatsin88 (accum88 beats_per_minute_88, u16 lowest=0, u16 highest=65535, u32 timebase=0, u16 phase_offset=0) FL_NOEXCEPT |
| Generates a 16-bit sine wave at a given BPM that oscillates within a given range. | |
| LIB8STATIC u16 | bseconds16 () FL_NOEXCEPT |
| Returns the current time-since-boot in "binary seconds", which are actually 1024/1000 of a second long. | |
| LIB8STATIC fl::u8 | cubicwave8 (fl::u8 in) |
| Cubic waveform generator. | |
| LIB8STATIC u16 | div1024_32_16 (u32 in32) FL_NOEXCEPT |
| Helper routine to divide a 32-bit value by 1024, returning only the low 16 bits. | |
| LIB8STATIC fl::u16 | ease16InOutCubic (fl::u16 i) |
| LIB8STATIC fl::u16 | ease16InOutQuad (fl::u16 i) |
| LIB8STATIC fract8 | ease8InOutApprox (fract8 i) |
| Fast, rough 8-bit ease-in/ease-out function. | |
| LIB8STATIC fract8 | ease8InOutCubic (fract8 i) |
| 8-bit cubic ease-in / ease-out function. | |
| LIB8STATIC fl::u8 | ease8InOutQuad (fl::u8 i) |
| 8-bit quadratic ease-in / ease-out function. | |
| LIB8STATIC sfract15 | floatToSfract15 (float f) |
| Conversion from IEEE754 float in the range (-1,1) to 16-bit fixed point (sfract15). | |
| LIB8STATIC u8 | hours8 () FL_NOEXCEPT |
| Return the current hours since boot in an 8-bit value. | |
| LIB8STATIC fl::i16 | lerp15by16 (fl::i16 a, fl::i16 b, fract16 frac) |
| Linear interpolation between two signed 15-bit values, with 8-bit fraction. | |
| LIB8STATIC fl::i16 | lerp15by8 (fl::i16 a, fl::i16 b, fract8 frac) |
| Linear interpolation between two signed 15-bit values, with 8-bit fraction. | |
| LIB8STATIC fl::u16 | lerp16by16 (fl::u16 a, fl::u16 b, fract16 frac) |
| Linear interpolation between two unsigned 16-bit values, with 16-bit fraction. | |
| LIB8STATIC fl::u16 | lerp16by8 (fl::u16 a, fl::u16 b, fract8 frac) |
| Linear interpolation between two unsigned 16-bit values, with 8-bit fraction. | |
| LIB8STATIC fl::u8 | lerp8by8 (fl::u8 a, fl::u8 b, fract8 frac) |
| Linear interpolation between two unsigned 8-bit values, with 8-bit fraction. | |
| LIB8STATIC fl::u8 | map8 (fl::u8 in, fl::u8 rangeStart, fl::u8 rangeEnd) |
| Map from one full-range 8-bit value into a narrower range of 8-bit values, possibly a range of hues. | |
| LIB8STATIC u16 | minutes16 () FL_NOEXCEPT |
| Return the current minutes since boot in a 16-bit value. | |
| LIB8STATIC fl::u8 | quadwave8 (fl::u8 in) |
| Quadratic waveform generator. | |
| LIB8STATIC u16 | seconds16 () FL_NOEXCEPT |
| Return the current seconds since boot in a 16-bit value. | |
| LIB8STATIC float | sfract15ToFloat (sfract15 y) |
| Conversion from 16-bit fixed point (sfract15) to IEEE754 32-bit float. | |
| LIB8STATIC u8 | squarewave8 (u8 in, u8 pulsewidth=128) FL_NOEXCEPT |
| Square wave generator. | |
| LIB8STATIC fl::u8 | triwave8 (fl::u8 in) |
| Triangle wave generator. | |
CEveryNTime Base Classes | |
These macros define the time interval checking classes used in the | |
| #define | CEveryNMilliseconds CEveryNMillis |
| Alias for CEveryNMillis. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNBSeconds, fl::u16, bseconds16) | |
| Create the CEveryNBSeconds class for bsecond intervals. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNHours, fl::u8, hours8) | |
| Create the CEveryNHours class for hours intervals. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNMillis, fl::u32, GET_MILLIS) | |
| Create the CEveryNMillis class for millisecond intervals. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNMinutes, fl::u16, minutes16) | |
| Create the CEveryNMinutes class for minutes intervals. | |
| INSTANTIATE_EVERY_N_TIME_PERIODS (CEveryNSeconds, fl::u16, seconds16) | |
| Create the CEveryNSeconds class for second intervals. | |