ESP32-HUB75-MatrixPanel-DMA/examples/AuroraDemo/PatternTheMatrix.hpp
mrcodetastic f77a5cac9c Make AuroraDemo great again.
And test out ChatGPT's attempt to create some effects as well.
2024-07-29 17:23:53 +01:00

54 lines
1.1 KiB
C++

// Codetastic 2024
// ChatGPT was used to create this.
#ifndef PatternTheMatrix_H
#define PatternTheMatrix_H
// Function to generate a random greenish color for the digital rain
CRGB generateRainColor() {
return CHSV(96 + random(64), 255, 255); // Greenish colors
}
class PatternTheMatrix : public Drawable {
public:
PatternTheMatrix() {
name = (char *)"The Matrix";
}
// Function to draw the digital rain effect
void drawDigitalRain() {
// Shift all the LEDs down by one row
for (int x = 0; x < VPANEL_W ; x++) {
for (int y = VPANEL_H - 1; y > 0; y--) {
effects.leds[XY(x, y)] = effects.leds[XY(x, y - 1)];
}
// Add a new drop at the top of the column randomly
if (random(10) > 7) { // Adjust the probability to control density of rain
effects.leds[XY(x, 0)] = generateRainColor();
} else {
effects.leds[XY(x, 0)] = CRGB::Black;
}
}
}
void start()
{
};
unsigned int drawFrame() {
effects.DimAll(250);
drawDigitalRain();
effects.ShowFrame();
return 0;
}
};
#endif