Fixed div by 0 when using palette on single LED segment

This commit is contained in:
cschwinne 2021-06-15 20:12:20 +02:00
parent 7610ab7a8d
commit 7d2f5f0799

View File

@ -964,7 +964,7 @@ uint32_t WS2812FX::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8
} }
uint8_t paletteIndex = i; uint8_t paletteIndex = i;
if (mapping) paletteIndex = (i*255)/(SEGLEN -1); if (mapping && SEGLEN > 1) paletteIndex = (i*255)/(SEGLEN -1);
if (!wrap) paletteIndex = scale8(paletteIndex, 240); //cut off blend at palette "end" if (!wrap) paletteIndex = scale8(paletteIndex, 240); //cut off blend at palette "end"
CRGB fastled_col; CRGB fastled_col;
fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND); fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND);