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 746 of file lib8tion.h.

747{
748 if( in & 0x80) {
749 in = 255 - in;
750 }
751 uint8_t out = in << 1;
752 return out;
753}

References LIB8STATIC.

Referenced by cubicwave8(), and quadwave8().

+ Here is the caller graph for this function: