From 7275a34e1fd335c9ebcb23990b861081a0326a9a Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sat, 9 Dec 2023 22:39:26 +0100 Subject: [PATCH] Partial fix for #3578 --- wled00/FX_fcn.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 2bc247bc5..30218a4f0 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1022,15 +1022,16 @@ void Segment::blur(uint8_t blur_amount) { */ uint32_t Segment::color_wheel(uint8_t pos) { if (palette) return color_from_palette(pos, false, true, 0); + uint8_t w = W(currentColor(0)); pos = 255 - pos; if (pos < 85) { - return ((uint32_t)(255 - pos * 3) << 16) | ((uint32_t)(0) << 8) | (pos * 3); + return RGBW32((255 - pos * 3), 0, (pos * 3), w); } else if(pos < 170) { pos -= 85; - return ((uint32_t)(0) << 16) | ((uint32_t)(pos * 3) << 8) | (255 - pos * 3); + return RGBW32(0, (pos * 3), (255 - pos * 3), w); } else { pos -= 170; - return ((uint32_t)(pos * 3) << 16) | ((uint32_t)(255 - pos * 3) << 8) | (0); + return RGBW32((pos * 3), (255 - pos * 3), 0, w); } } @@ -1044,13 +1045,10 @@ uint32_t Segment::color_wheel(uint8_t pos) { * @returns Single color from palette */ uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri) { + uint32_t color = gamma32(currentColor(mcol)); + // default palette or no RGB support on segment - if ((palette == 0 && mcol < NUM_COLORS) || !_isRGB) { - uint32_t color = currentColor(mcol); - color = gamma32(color); - if (pbri == 255) return color; - return color_fade(color, pbri, true); - } + if ((palette == 0 && mcol < NUM_COLORS) || !_isRGB) return (pbri == 255) ? color : color_fade(color, pbri, true); uint8_t paletteIndex = i; if (mapping && virtualLength() > 1) paletteIndex = (i*255)/(virtualLength() -1); @@ -1059,7 +1057,7 @@ uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_ curPal = currentPalette(curPal, palette); CRGB fastled_col = ColorFromPalette(curPal, paletteIndex, pbri, (strip.paletteBlend == 3)? NOBLEND:LINEARBLEND); // NOTE: paletteBlend should be global - return RGBW32(fastled_col.r, fastled_col.g, fastled_col.b, 0); + return RGBW32(fastled_col.r, fastled_col.g, fastled_col.b, W(color)); }