From 7d2f5f07996eb88ce0e5d3b9e5812293a6946825 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 15 Jun 2021 20:12:20 +0200 Subject: [PATCH] Fixed div by 0 when using palette on single LED segment --- wled00/FX_fcn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 4d08bc144..075988cd5 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -964,7 +964,7 @@ uint32_t WS2812FX::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8 } 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" CRGB fastled_col; fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND);