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

◆ beatsin8()

LIB8STATIC u8 fl::beatsin8 ( accum88 beats_per_minute,
u8 lowest = 0,
u8 highest = 255,
u32 timebase = 0,
u8 phase_offset = 0 )

Generates an 8-bit sine wave at a given BPM that oscillates within a given range.

Parameters
beats_per_minutethe frequency of the wave, in decimal
lowestthe lowest output value of the sine wave
highestthe highest output value of the sine wave
timebasethe time offset of the wave from the millis() timer
phase_offsetphase offset of the wave from the current position
Examples
DemoReel100.ino, Pacifica.ino, and ParallelSPI.ino.

Definition at line 105 of file beat.h.

107 {
108 u8 beat = beat8(beats_per_minute, timebase);
109 u8 beatsin = sin8(beat + phase_offset);
110 u8 rangewidth = highest - lowest;
111 u8 scaledbeat = scale8(beatsin, rangewidth);
112 u8 result = lowest + scaledbeat;
113 if (result > highest) {
114 result = highest;
115 }
116 return result;
117}
unsigned char u8
Definition stdint.h:131
LIB8STATIC u8 beat8(accum88 beats_per_minute, u32 timebase=0) FL_NOEXCEPT
Generates an 8-bit "sawtooth" wave at a given BPM.
Definition beat.h:51
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

Referenced by bpm(), loop(), pacifica_add_whitecaps(), pacifica_loop(), and updateLEDs().

+ Here is the caller graph for this function: