Merge pull request #1862 from fishbone-git/drip

Drip: use constrain to keep in segment limits
This commit is contained in:
Aircoookie 2021-04-07 00:59:38 +02:00 committed by GitHub
commit daa77d40a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3108,7 +3108,7 @@ uint16_t WS2812FX::mode_drip(void)
drops[j].vel += gravity; 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 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 setPixelColor(pos,color_blend(BLACK,SEGCOLOR(0),drops[j].col/i)); //spread pixel with fade while falling
} }