From bcebde545d45c08b518f79bfa393353d67d71391 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Sat, 7 Dec 2024 20:40:06 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8C=20don't=20draw=20trails=20on=20fir?= =?UTF-8?q?st=20drop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nametag/src/main.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nametag/src/main.cpp b/nametag/src/main.cpp index ed3c95c..00480b8 100644 --- a/nametag/src/main.cpp +++ b/nametag/src/main.cpp @@ -42,6 +42,7 @@ int line_speed[PANEL_WIDTH]; // how fast each line moves unsigned long line_last_moved[PANEL_WIDTH]; typedef struct { + bool reached_bottom = false; int y; int length; int speed; @@ -59,12 +60,7 @@ void setup(){ raindrops[i].length = random(20, 28); raindrops[i].speed = random(25, 100); raindrops[i].last_moved = millis(); - //raindrops[i] = rd; - - //line_pos[i] = 0 - random(24); - //line_length[i] = random(20, 28); - //line_speed[i] = random(25, 100); - //line_last_moved[i] = millis(); + //raindrops[i].reached_bottom = false; } // redefine pins if required HUB75_I2S_CFG::i2s_pins _pins={R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK}; @@ -100,6 +96,7 @@ void loop() { } if (raindrops[x].y > PANEL_HEIGHT) { raindrops[x].y = 0; + raindrops[x].reached_bottom = true; } if (raindrops[x].y >= 0) { //draw our pixel @@ -114,7 +111,7 @@ void loop() { } else { matrix->drawPixel(x, trail_y, matrix->color565(0, (255 / raindrops[x].length) * (raindrops[x].length - trail_offset), 0)); } - } else { + } else if (raindrops[x].reached_bottom) { int pixel_num = ((PANEL_HEIGHT + trail_y) * PANEL_WIDTH) + x; if (line_pos[x] >= 0) { if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) )) {