🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

FancyLed palette_lookup not really working
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

FancyLed palette_lookup not really working

by braddo on Wed Nov 20, 2019 4:36 pm

Hey folks, I'm using a Feather M0 to control an APA102 LED ring. Trying to use a pot to adjust the color using the palette_lookup function of fancyled but it doesn't appear to be interpolating correctly, Not *certain* what to expect but it doesn't look right.

I've set a simple loop to send values between 0 and 1 (divided into 24 parts) as the lookup into the palatte. What I'm getting back is not a smooth gradient between/among the palette colors but instead changes in brightness of the simple colors in the palatte then an abrupt switch to the next color. So, if going from typical red to yellow to green, it will be full red, dimmer red dimmer red then just a single yellow, then dim blue then slightly brighter blue full blue etc. It's not actually blending the colors at all, and the non primary colors aren't even dimmed they just make a very quick appearance then move to dim primary colors. The same thing happens when I expose the full resolution of the pot, it basically doesn't blend colors and non primary colors can only be shown with extremely fine adjustment of the pot. Here's an excerpt from the code:

Code: Select all | TOGGLE FULL SIZE
# Declare RGB rainbow and monochrome palettes
rainbow = [fancy.CRGB(1.0, 0.0, 0.0), # Red
           fancy.CRGB(0.5, 0.5, 0.0), # Yellow
           fancy.CRGB(0.0, 1.0, 0.0), # Green
           fancy.CRGB(0.0, 0.5, 0.5), # Cyan
           fancy.CRGB(0.0, 0.0, 1.0), # Blue
           fancy.CRGB(0.5, 0.0, 0.5)] # Magenta

...

for j in range(0,24):
                bright = PotLeft.value / 65520 * max_bright
                print(("j/24=",j/24))
                color = fancy.palette_lookup(rainbow, j/24)
                color = fancy.gamma_adjust(color, brightness=bright)
                for i in range(num_leds):
                    pixels[i] = color.pack()
                pixels.show()
                time.sleep(0.5)


Any obvious missing stuff in how I'm using this library? Thanks!

The ring is a Sparkfun Lumini (would have used any Adafruit ring but none were available with high density also in the size that would fit around my pot.

braddo
 
Posts: 12
Joined: Wed Mar 19, 2014 1:44 pm

Re: FancyLed palette_lookup not really working

by pburgess on Thu Nov 21, 2019 9:56 pm

Gamma correction can cause pretty severe quantization at the low end of things, especially at lower brightness settings.

Try keeping brightness above a certain level (e.g. maybe it ranges from 0.4 to 1.0 instead of 0.0 to 1.0), and/or try a lower gamma value (1.0 = no gamma correction, 2.5 = default), e.g.:
Code: Select all | TOGGLE FULL SIZE
        color = fancy.gamma_adjust(color, brightness=bright, gamma_value=1.5)

pburgess
 
Posts: 4046
Joined: Sun Oct 26, 2008 2:29 am

Re: FancyLed palette_lookup not really working

by braddo on Sun Nov 24, 2019 12:27 pm

I'll give that a try. I thought the default i.e. no setting for gamma might be 1 but if the default is 2.5 that could help. Perhaps what's happening is that the non-primary leds in a given color blend are below the threshold of seeing at a certain brightness and that's why the expected blended colors are only dim and dimmer versions of the primary colors? Will check it out. Thanks

braddo
 
Posts: 12
Joined: Wed Mar 19, 2014 1:44 pm

Re: FancyLed palette_lookup not really working

by braddo on Wed Nov 27, 2019 6:25 pm

In the end I think I was just setting the brightness too low such that some blended colors were not appearing because the contribution from one of the RGB was too low to show up. I rescaled the way I read the pot to make it impossible to set the brightness that low. Thanks

braddo
 
Posts: 12
Joined: Wed Mar 19, 2014 1:44 pm

Please be positive and constructive with your questions and comments.