From 56e1d577fdd1abc5f73a6fa1ef9158cf52f18510 Mon Sep 17 00:00:00 2001 From: TripleWhy Date: Fri, 27 Dec 2024 11:19:24 +0100 Subject: [PATCH] palette effect overflow fix --- wled00/FX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 5e43430aef..7bf054581d 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2032,7 +2032,7 @@ uint16_t mode_palette() { const mathType sourceX = xtSinTheta + ytCosTheta + centerX; // The computation was scaled just right so that the result should always be in range [0, maxXOut], but enforce this anyway // to account for imprecision. Then scale it so that the range is [0, 255], which we can use with the palette. - int colorIndex = (std::min(std::max(sourceX, mathType(0)), maxXOut * sInt16Scale) * 255) / (sInt16Scale * maxXOut); + int colorIndex = (std::min(std::max(sourceX, mathType(0)), maxXOut * sInt16Scale) * wideMathType(255)) / (sInt16Scale * maxXOut); // inputSize determines by how much we want to scale the palette: // values < 128 display a fraction of a palette, // values > 128 display multiple palettes.