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

◆ drawPlasmaWave()

void drawPlasmaWave ( float peak)

Definition at line 420 of file advanced.h.

420 {
421 static float time = 0;
422 time += 0.05f + (peak * 0.2f);
423
424 CRGBPalette16 palette = getCurrentPalette();
425
426 for (int x = 0; x < WIDTH; x++) {
427 for (int y = 0; y < HEIGHT; y++) {
428 float value = sinf(x * 0.1f + time) +
429 sinf(y * 0.1f - time) +
430 sinf((x + y) * 0.1f + time) +
431 sinf(sqrtf(x * x + y * y) * 0.1f - time);
432
433 value = (value + 4) / 8; // Normalize to 0-1
434 value *= audioGain.value() * autoGainValue;
435
436 uint8_t colorIndex = value * 255;
437 int ledIndex = xyMap(x, y);
438 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
439 leds[ledIndex] = ColorFromPalette(palette, colorIndex + hue);
440 }
441 }
442 }
443}
CRGB leds[NUM_LEDS]
#define NUM_LEDS
uint8_t hue
int y
Definition simple.h:93
int x
Definition simple.h:92
fl::XYMap xyMap
Definition ColorBoost.h:57
UINumberField palette("Palette", 0, 0, 2)
#define WIDTH
Definition advanced.h:34
float autoGainValue
Definition advanced.h:89
UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f)
CRGBPalette16 getCurrentPalette()
Definition advanced.h:101
#define HEIGHT
Definition advanced.h:35
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
fl::u32 time()
Universal millisecond timer - returns milliseconds since system startup.
Definition time.cpp:136

References audioGain(), autoGainValue, ColorFromPalette(), getCurrentPalette(), HEIGHT, hue, leds, NUM_LEDS, palette(), fl::time(), WIDTH, x, xyMap, and y.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: