New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GradientPalette behaving unexpected #515

Open
maxxh11 opened this Issue Oct 30, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@maxxh11

maxxh11 commented Oct 30, 2017

I tried using a Gradient Palette and get strange results. I'm not sure if im using it incorrectly or if there's a bug inside the Library. (I'm using a NodeMCU v1/ ESP8266)

Following this wiki page I'm doing the following steps:

  1. DEFINE_GRADIENT_PALETTE ( heatmap_gp );
  2. Create a CRGBPalette16 gPal
  3. Point the gPal to heatmap_gp
  4. Use leds[0] = ColorFromPalette( gPal, 255); to assign a color from the gradient.
  5. FastLED.show();

In my understanding the led should turn on and be pure white with a Brightness of 255. But in reality I get a dim greenish color.

The issue goes away if I use CRGBPalette256 in step 2 instead of CRGBPalette16.

Am I doing something wrong or is this a bug ?

@marmilicious

This comment has been minimized.

Show comment
Hide comment
@marmilicious

marmilicious Oct 31, 2017

In order to support smooth blending for "circular" palettes, each color blends with "the next", and in the case of the last color, "the next" is the first color since it wraps around, so the last 15 numbers are blending back toward index 0. Sometime circular blending is very useful, other times it might not be what you want. You can use index 240 as your last value to avoid blending.

If you would still like to code using a 0-255 range but have the output maximum be 240 and avoid wrapping you can use the scale8 function:
ColorFromPalette( gPal, scale8( i , 240 ) );

marmilicious commented Oct 31, 2017

In order to support smooth blending for "circular" palettes, each color blends with "the next", and in the case of the last color, "the next" is the first color since it wraps around, so the last 15 numbers are blending back toward index 0. Sometime circular blending is very useful, other times it might not be what you want. You can use index 240 as your last value to avoid blending.

If you would still like to code using a 0-255 range but have the output maximum be 240 and avoid wrapping you can use the scale8 function:
ColorFromPalette( gPal, scale8( i , 240 ) );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment