◀ Make the rainbow move

This commit is contained in:
Felix Pankratz 2024-12-17 14:56:57 +01:00
parent da0dd90562
commit f00a164f74

View File

@ -15,6 +15,7 @@ float cell_value(Cell c) {
Cell cells[PANEL_WIDTH * PANEL_HEIGHT]; Cell cells[PANEL_WIDTH * PANEL_HEIGHT];
bool cells_setup = false; bool cells_setup = false;
uint8_t rainbow_offset = 0;
void setup_cells() { void setup_cells() {
for(int i = 0; i < PANEL_WIDTH * PANEL_HEIGHT; i++) { for(int i = 0; i < PANEL_WIDTH * PANEL_HEIGHT; i++) {
@ -37,10 +38,14 @@ void draw_supercomputer(MatrixPanel_I2S_DMA *matrix, Mode mode) {
} else { } else {
// rainbow // 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])); uint8_t hue = ((int)round(progress) + rainbow_offset);
CHSV hsv_color(hue, 255, 255 * cell_value(cells[i]));
CRGB rgb; CRGB rgb;
hsv2rgb_rainbow(hsv_color, rgb); hsv2rgb_rainbow(hsv_color, rgb);
matrix->drawPixel(x, 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));
} }
} }
if (mode == HighVis) {
rainbow_offset++;
}
} }