Skip to content

Commit

Permalink
use constrain to keep in segment limits
Browse files Browse the repository at this point in the history
  • Loading branch information
fishbone-git committed Apr 5, 2021
1 parent ecdc0a3 commit f18dced
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3108,7 +3108,7 @@ uint16_t WS2812FX::mode_drip(void)
drops[j].vel += gravity;

for (uint16_t i=1;i<7-drops[j].colIndex;i++) { // some minor math so we don't expand bouncing droplets
uint16_t pos = uint16_t(drops[j].pos) +i; //this is BAD, returns a pos >= SEGLEN occasionally
uint16_t pos = constrain(uint16_t(drops[j].pos) +i, 0, SEGLEN-1); //this is BAD, returns a pos >= SEGLEN occasionally
setPixelColor(pos,color_blend(BLACK,SEGCOLOR(0),drops[j].col/i)); //spread pixel with fade while falling
}

Expand Down

0 comments on commit f18dced

Please sign in to comment.