From 8d51a0a036fbc158c4822f0ad5c576d5b1685f83 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Fri, 13 Dec 2024 18:26:57 +0100 Subject: [PATCH] fix up some things, it flickers sometimes now?? --- nametag/src/rain.cpp | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/nametag/src/rain.cpp b/nametag/src/rain.cpp index b8a63ef..39ce268 100644 --- a/nametag/src/rain.cpp +++ b/nametag/src/rain.cpp @@ -24,7 +24,7 @@ bool rain_initialized = false; uint16_t color_highlight; uint16_t color_default; -void setup_rain() { +void setup_rain(MatrixPanel_I2S_DMA *matrix) { color_highlight = matrix->color565( COLOR_HIGHLIGHT_R, COLOR_HIGHLIGHT_G, @@ -46,7 +46,7 @@ void setup_rain() { void draw_rain(MatrixPanel_I2S_DMA *matrix, Mode mode) { //matrix ->drawBitmap(0, 0, overlay, 64, 32, matrix->color565(64, 0, 0)); if (!rain_initialized) { - setup_rain(); + setup_rain(matrix); rain_initialized = true; } unsigned long timestamp = millis(); @@ -66,7 +66,7 @@ void draw_rain(MatrixPanel_I2S_DMA *matrix, Mode mode) { // draw our trail for (int trail_offset = 1; trail_offset < raindrops[x].length; trail_offset++) { int trail_y = raindrops[x].y - trail_offset; - float brightness = (raindrops[x].length - trail_offset); + float brightness = ((raindrops[x].length - trail_offset) / (float)raindrops[x].length); uint16_t fade_color = matrix->color565( COLOR_DEFAULT_R * brightness, COLOR_DEFAULT_G * brightness, @@ -75,10 +75,10 @@ void draw_rain(MatrixPanel_I2S_DMA *matrix, Mode mode) { if (trail_y < 0) { if (not raindrops[x].reached_bottom) { - continue; + break; } // we need to count from the bottom up - trail_y = PANEL_WIDTH + trail_y; + trail_y = PANEL_HEIGHT + trail_y; } int pixel_num = (trail_y * PANEL_WIDTH) + x; @@ -95,27 +95,6 @@ void draw_rain(MatrixPanel_I2S_DMA *matrix, Mode mode) { } else { matrix->drawPixel(x, trail_y, fade_color); } - - //} else if (raindrops[x].reached_bottom) { - // int pixel_num = ((PANEL_HEIGHT + trail_y) * PANEL_WIDTH) + x; - // if (raindrops[x].y >= 0) { - // if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) ) and mode != Stealth) { - // if (mode == HighVis) { - // matrix->drawPixel(x, PANEL_HEIGHT + trail_y, color_highlight); - // } else { - // matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565( - // COLOR_HIGHLIGHT_R * brightness, - // COLOR_HIGHLIGHT_G * brightness, - // COLOR_HIGHLIGHT_B * brightness - // )); - // } - // } else { - // matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(0, fade_color, 0)); - // } - // } else { - // break; - // } - //} } } }