Visualization: Plasma Wave
| 430 | |
| 431 | // Visualization: Plasma Wave |
| 432 | void drawPlasmaWave(float peak) { |
| 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 | } |
| 456 | |
| 457 | void setup() { |
| 458 | Serial.begin(115200); |
no test coverage detected