👈 visibility modes for supercomputer

This commit is contained in:
Felix Pankratz 2024-12-17 12:35:53 +01:00
parent 224f2beb23
commit da0dd90562
3 changed files with 17 additions and 10 deletions

View File

@ -83,7 +83,7 @@ void loop() {
draw_congress(matrix, mode); draw_congress(matrix, mode);
break; break;
case Supercomputer: case Supercomputer:
draw_supercomputer(matrix); draw_supercomputer(matrix, mode);
break; break;
} }
} }

View File

@ -1,6 +1,7 @@
#include <Arduino.h> #include <Arduino.h>
#include <FastLED.h> #include <FastLED.h>
#include "constants.h" #include "constants.h"
#include "enums.h"
#include "supercomputer.h" #include "supercomputer.h"
struct Cell { struct Cell {
@ -22,19 +23,24 @@ void setup_cells() {
} }
} }
void draw_supercomputer(MatrixPanel_I2S_DMA *matrix) { void draw_supercomputer(MatrixPanel_I2S_DMA *matrix, Mode mode) {
if (!cells_setup) { if (!cells_setup) {
setup_cells(); setup_cells();
cells_setup = true; cells_setup = true;
} }
for(int i = 0; i < PANEL_WIDTH * PANEL_HEIGHT; i++) { 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; int x = i % PANEL_WIDTH;
cells[i].state += 0.3;
if (mode == Stealth) {
// red only
matrix->drawPixel(x, i / PANEL_WIDTH, matrix->color565((int)round(255.0 * cell_value(cells[i])), 0, 0));
} else {
// rainbow
float progress = (255.0 / PANEL_WIDTH) * x; float progress = (255.0 / PANEL_WIDTH) * x;
CHSV hsv_color((int)round(progress), 255, 255 * cell_value(cells[i])); CHSV hsv_color((int)round(progress), 255, 255 * cell_value(cells[i]));
CRGB rgb; CRGB rgb;
hsv2rgb_rainbow(hsv_color, rgb); hsv2rgb_rainbow(hsv_color, rgb);
matrix->drawPixel(i % PANEL_WIDTH, i / PANEL_WIDTH, matrix->color565(rgb.r, rgb.g, rgb.b)); matrix->drawPixel(x, i / PANEL_WIDTH, matrix->color565(rgb.r, rgb.g, rgb.b));
}
} }
} }

View File

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