From da0dd90562acf7e17afbee56bac9791b039b2465 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Tue, 17 Dec 2024 12:35:53 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=88=20visibility=20modes=20for=20super?= =?UTF-8?q?computer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nametag/src/main.cpp | 2 +- nametag/src/supercomputer.cpp | 22 ++++++++++++++-------- nametag/src/supercomputer.h | 3 ++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/nametag/src/main.cpp b/nametag/src/main.cpp index 332a2a3..85ee993 100644 --- a/nametag/src/main.cpp +++ b/nametag/src/main.cpp @@ -83,7 +83,7 @@ void loop() { draw_congress(matrix, mode); break; case Supercomputer: - draw_supercomputer(matrix); + draw_supercomputer(matrix, mode); break; } } diff --git a/nametag/src/supercomputer.cpp b/nametag/src/supercomputer.cpp index 18e5fb8..a17fead 100644 --- a/nametag/src/supercomputer.cpp +++ b/nametag/src/supercomputer.cpp @@ -1,6 +1,7 @@ #include #include #include "constants.h" +#include "enums.h" #include "supercomputer.h" 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) { 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)); + 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; + CHSV hsv_color((int)round(progress), 255, 255 * cell_value(cells[i])); + CRGB rgb; + hsv2rgb_rainbow(hsv_color, rgb); + matrix->drawPixel(x, i / PANEL_WIDTH, matrix->color565(rgb.r, rgb.g, rgb.b)); + } } } diff --git a/nametag/src/supercomputer.h b/nametag/src/supercomputer.h index 9297e2d..f257094 100644 --- a/nametag/src/supercomputer.h +++ b/nametag/src/supercomputer.h @@ -1,2 +1,3 @@ #include -void draw_supercomputer(MatrixPanel_I2S_DMA *matrix); +#include "enums.h" +void draw_supercomputer(MatrixPanel_I2S_DMA *matrix, Mode mode);