FastLED 3.9.7
Loading...
Searching...
No Matches
Waveform Generators

Detailed Description

General purpose wave generator functions.

Functions

LIB8STATIC uint8_t triwave8 (uint8_t in)
 Triangle wave generator.
 
LIB8STATIC uint8_t quadwave8 (uint8_t in)
 Quadratic waveform generator.
 
LIB8STATIC uint8_t cubicwave8 (uint8_t in)
 Cubic waveform generator.
 
LIB8STATIC uint8_t squarewave8 (uint8_t in, uint8_t pulsewidth=128)
 Square wave generator.
 

Function Documentation

◆ cubicwave8()

LIB8STATIC uint8_t cubicwave8 ( uint8_t in)

Cubic waveform generator.

Spends visibly more time at the limits than "sine" does. Spends just a little more time at the limits than "sine" does.

S-shaped wave generator (like "sine"). Useful for turning a one-byte "counter" value into a one-byte oscillating value that moves smoothly up and down, with an "acceleration" and "deceleration" curve.

This is even faster than "sin8()", and has a slightly different curve shape.

Definition at line 773 of file lib8tion.h.

◆ quadwave8()

LIB8STATIC uint8_t quadwave8 ( uint8_t in)

Quadratic waveform generator.

Spends just a little more time at the limits than "sine" does.

S-shaped wave generator (like "sine"). Useful for turning a one-byte "counter" value into a one-byte oscillating value that moves smoothly up and down, with an "acceleration" and "deceleration" curve.

This is even faster than "sin8()", and has a slightly different curve shape.

Definition at line 765 of file lib8tion.h.

◆ squarewave8()

LIB8STATIC uint8_t squarewave8 ( uint8_t in,
uint8_t pulsewidth = 128 )

Square wave generator.

Useful for turning a one-byte ever-increasing value into a one-byte value that is either 0 or 255. The width of the output "pulse" is determined by the pulsewidth argument:

if pulsewidth is 255, output is always 255.
if pulsewidth < 255, then
if input < pulsewidth then output is 255
if input >= pulsewidth then output is 0

The output looking like:

255 +--pulsewidth--+
. | |
0 0 +--------(256-pulsewidth)--------
Parameters
ininput value
pulsewidthwidth of the output pulse
Returns
square wave output

Definition at line 802 of file lib8tion.h.

◆ 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.