FastLED 3.10.6
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 677 of file lib8tion.h.

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

References LIB8STATIC.

Referenced by cubicwave8(), and quadwave8().

+ Here is the caller graph for this function: