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

◆ drawPlasmaWave()

void drawPlasmaWave ( float peak)

Definition at line 432 of file advanced.h.

432 {
433 static float time = 0; // okay static in header
434 time += 0.05f + (peak * 0.2f);
435
436 fl::CRGBPalette16 palette = getCurrentPalette();
437
438 for (int x = 0; x < WIDTH; x++) {
439 for (int y = 0; y < HEIGHT; y++) {
440 float value = fl::sinf(x * 0.1f + time) +
441 fl::sinf(y * 0.1f - time) +
442 fl::sinf((x + y) * 0.1f + time) +
443 fl::sinf(fl::sqrtf(x * x + y * y) * 0.1f - time);
444
445 value = (value + 4) / 8; // Normalize to 0-1
446 value *= audioGain.value() * autoGainValue;
447
448 uint8_t colorIndex = value * 255;
449 int ledIndex = xyMap(x, y);
450 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
451 leds[ledIndex] = ColorFromPalette(palette, colorIndex + hue);
452 }
453 }
454 }
455}
fl::XYMap xyMap
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
int y
Definition simple.h:93
int x
Definition simple.h:92
UINumberField palette("Palette", 0, 0, 2)
#define WIDTH
fl::CRGBPalette16 getCurrentPalette()
Definition advanced.h:109
float autoGainValue
Definition advanced.h:90
fl::UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f)
uint8_t hue
Definition advanced.h:94
#define HEIGHT
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
float sqrtf(float value) FL_NOEXCEPT
Definition math.h:453
fl::u64 time() FL_NOEXCEPT
Alias for millis64() - returns 64-bit millisecond time.
Definition chrono.h:346
float sinf(float value) FL_NOEXCEPT
Definition math.h:352
unsigned char uint8_t
Definition s16x16x4.h:209

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

Referenced by loop().

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