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

◆ triwave8()

LIB8STATIC uint8_t triwave8 ( uint8_t 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 728 of file lib8tion.h.

729{
730 if( in & 0x80) {
731 in = 255 - in;
732 }
733 uint8_t out = in << 1;
734 return out;
735}

References LIB8STATIC.

Referenced by cubicwave8(), and quadwave8().

+ Here is the caller graph for this function: