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

◆ drawMatrixRain()

void drawMatrixRain ( float peak)

Definition at line 382 of file advanced.h.

382 {
383 // Shift everything down
384 for (int x = 0; x < WIDTH; x++) {
385 for (int y = HEIGHT - 1; y > 0; y--) {
386 int currentIndex = xyMap(x, y);
387 int aboveIndex = xyMap(x, y - 1);
388 if (currentIndex >= 0 && currentIndex < NUM_LEDS &&
389 aboveIndex >= 0 && aboveIndex < NUM_LEDS) {
390 leds[currentIndex] = leds[aboveIndex];
391 leds[currentIndex].fadeToBlackBy(40);
392 }
393 }
394 }
395
396 // Add new drops based on audio
397 int numDrops = peak * WIDTH * audioGain.value() * autoGainValue;
398 for (int i = 0; i < numDrops; i++) {
399 int x = random(WIDTH);
400 int ledIndex = xyMap(x, 0);
401 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
402 leds[ledIndex] = CHSV(96, 255, 255); // Green
403 }
404 }
405}
fl::XYMap xyMap
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
int y
Definition simple.h:93
int x
Definition simple.h:92
#define WIDTH
float autoGainValue
Definition advanced.h:90
fl::UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f)
#define HEIGHT
fl::hsv8 CHSV
Definition chsv.h:11

References audioGain(), autoGainValue, HEIGHT, leds, NUM_LEDS, WIDTH, x, xyMap, and y.

Referenced by loop().

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