FastLED 3.9.15
Loading...
Searching...
No Matches

◆ triwave8()

LIB8STATIC fl::u8 triwave8 ( fl::u8 in)

Triangle wave generator.

Useful for turning a one-byte ever-increasing value into a one-byte value that oscillates up and down.

input output
0..127 0..254 (positive slope)
128..255 254..0 (negative slope)

On AVR this function takes just three cycles.

Definition at line 678 of file lib8tion.h.

679{
680 if( in & 0x80) {
681 in = 255 - in;
682 }
683 fl::u8 out = in << 1;
684 return out;
685}
unsigned char u8
Definition stdint.h:131

References LIB8STATIC.

Referenced by cubicwave8(), and quadwave8().

+ Here is the caller graph for this function: