🌈 rainbow supercomputaa

This commit is contained in:
Felix Pankratz 2024-12-17 12:29:01 +01:00
parent 7b5701f2e9
commit 224f2beb23
4 changed files with 51 additions and 1 deletions

View File

@ -8,6 +8,7 @@ enum Mode {
enum DisplayStyle { enum DisplayStyle {
Rain, Rain,
Congress Congress,
Supercomputer
}; };
#endif #endif

View File

@ -6,6 +6,7 @@
#include "constants.h" #include "constants.h"
#include "congress.h" #include "congress.h"
#include "rain.h" #include "rain.h"
#include "supercomputer.h"
#include "pillowlava8pt7b.h" #include "pillowlava8pt7b.h"
@ -65,6 +66,9 @@ void loop() {
style = Congress; style = Congress;
break; break;
case Congress: case Congress:
style = Supercomputer;
break;
case Supercomputer:
style = Rain; style = Rain;
break; break;
} }
@ -78,6 +82,9 @@ void loop() {
case Congress: case Congress:
draw_congress(matrix, mode); draw_congress(matrix, mode);
break; break;
case Supercomputer:
draw_supercomputer(matrix);
break;
} }
} }

View File

@ -0,0 +1,40 @@
#include <Arduino.h>
#include <FastLED.h>
#include "constants.h"
#include "supercomputer.h"
struct Cell {
float state;
float factor;
};
float cell_value(Cell c) {
return (1.0 + sin(c.state * c.factor)) * 0.5;
}
Cell cells[PANEL_WIDTH * PANEL_HEIGHT];
bool cells_setup = false;
void setup_cells() {
for(int i = 0; i < PANEL_WIDTH * PANEL_HEIGHT; i++) {
cells[i].state = random(100, 1000) / 100.0;
cells[i].factor = random(90, 110) / 100.0;
}
}
void draw_supercomputer(MatrixPanel_I2S_DMA *matrix) {
if (!cells_setup) {
setup_cells();
cells_setup = true;
}
for(int i = 0; i < PANEL_WIDTH * PANEL_HEIGHT; i++) {
cells[i].state += 0.3;
//matrix->drawPixel(i % PANEL_WIDTH, i / PANEL_WIDTH, matrix->color565((int)round(255.0 * cell_value(cells[i])), 0, 0));
int x = i % PANEL_WIDTH;
float progress = (255.0 / PANEL_WIDTH) * x;
CHSV hsv_color((int)round(progress), 255, 255 * cell_value(cells[i]));
CRGB rgb;
hsv2rgb_rainbow(hsv_color, rgb);
matrix->drawPixel(i % PANEL_WIDTH, i / PANEL_WIDTH, matrix->color565(rgb.r, rgb.g, rgb.b));
}
}

View File

@ -0,0 +1,2 @@
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
void draw_supercomputer(MatrixPanel_I2S_DMA *matrix);