Skip to content

Commit

Permalink
Partial fix for #3578
Browse files Browse the repository at this point in the history
  • Loading branch information
blazoncek committed Dec 9, 2023
1 parent 391876e commit 7275a34
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
Expand All @@ -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));

This comment has been minimized.

Copy link
@softhack007

softhack007 Dec 10, 2023

Collaborator

This always returns the white from gamma32(currentColor(mcol)), right?
In particular the "white" has nothing to do with ColorFromPalette(curPal,...)?

Maybe it would be better to return luminance or avg lightness in this case: fastled_col.getLuma() or fastled_col.getAverageLight().

This comment has been minimized.

Copy link
@blazoncek

blazoncek Dec 11, 2023

Author Collaborator

Exactly this is the point of getting W() from original color.

None of the FastLED palettes contain white channel information and if a user selects Brighter or Accurate auto white calculation then white channel is re-calculated from RGB information (in bus setPixelColor()). If, on the other hand, user selected None or Dual as auto white calculation then original white channel should be used.

}


Expand Down

0 comments on commit 7275a34

Please sign in to comment.