diff --git a/nametag/src/enums.h b/nametag/src/enums.h index 34928b6..9bf3533 100644 --- a/nametag/src/enums.h +++ b/nametag/src/enums.h @@ -8,6 +8,7 @@ enum Mode { enum DisplayStyle { Rain, - Congress + Congress, + Supercomputer }; #endif diff --git a/nametag/src/main.cpp b/nametag/src/main.cpp index aab3099..332a2a3 100644 --- a/nametag/src/main.cpp +++ b/nametag/src/main.cpp @@ -6,6 +6,7 @@ #include "constants.h" #include "congress.h" #include "rain.h" +#include "supercomputer.h" #include "pillowlava8pt7b.h" @@ -65,6 +66,9 @@ void loop() { style = Congress; break; case Congress: + style = Supercomputer; + break; + case Supercomputer: style = Rain; break; } @@ -78,6 +82,9 @@ void loop() { case Congress: draw_congress(matrix, mode); break; + case Supercomputer: + draw_supercomputer(matrix); + break; } } diff --git a/nametag/src/supercomputer.cpp b/nametag/src/supercomputer.cpp new file mode 100644 index 0000000..18e5fb8 --- /dev/null +++ b/nametag/src/supercomputer.cpp @@ -0,0 +1,40 @@ +#include +#include +#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)); + } +} diff --git a/nametag/src/supercomputer.h b/nametag/src/supercomputer.h new file mode 100644 index 0000000..9297e2d --- /dev/null +++ b/nametag/src/supercomputer.h @@ -0,0 +1,2 @@ +#include +void draw_supercomputer(MatrixPanel_I2S_DMA *matrix);