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

609{
610 if( in & 0x80) {
611 in = 255 - in;
612 }
613 uint8_t out = in << 1;
614 return out;
615}

References LIB8STATIC.

Referenced by cubicwave8(), and quadwave8().

+ Here is the caller graph for this function: