Due to high demand expect some shipping delays at this time, orders may not ship for 3-4 business days. On MLK Day no orders will be shipped.
0

FancyLed and RGBW - Compatible?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

FancyLed and RGBW - Compatible?

by hopworks on Wed Dec 08, 2021 7:16 am

Good Morning!

Is the FancyLED library compatible with RGBW LED's? If not, could someone recommend a similar library or a fork of FancyLED that can handle the 4th color (white) data?

Thank you for your time!

hopworks
 
Posts: 21
Joined: Fri Jul 06, 2012 5:50 pm

Re: FancyLed and RGBW - Compatible?

by mikeysklar on Wed Dec 08, 2021 8:38 pm

@hopworks,

You can use FancyLED with NeoPixel or DotStart strips. It is fine if they are RGBW based. FancyLED is higher level layer that lets the appropriate neopixel or dotstar library do the lower level communication.

mikeysklar
 
Posts: 6498
Joined: Mon Aug 01, 2016 8:10 pm

Re: FancyLed and RGBW - Compatible?

by hopworks on Thu Dec 09, 2021 9:10 am

Thank you for the reply!
I would have responded sooner but it was obvious I needed to read up on the library. I am in a hurry and did not want to invest the time (yet) unless using the library with RGBW led's was viable, and your post suggested that. Thanks!!

I am sure there is a more elegant way to do this. I just converted the packed color integers back into separate integers, and then added a white integer value. This is the only thing that would work for me. If you know of a function or easier way to do this, please let me know. Thanks!

Here is my modified example that I found on https://learn.adafruit.com/fancyled-lib ... led-colors
I am using 4 NeoPixel Jewels in series. The masking and shifting of the packed integers is towards the bottom of the code.

Code: Select all | TOGGLE FULL SIZE
import time
import board
import neopixel
import adafruit_fancyled.adafruit_fancyled as fancy

# On CircuitPlayground Express, and boards with built in status NeoPixel -> board.NEOPIXEL
# Otherwise choose an open pin connected to the Data In of the NeoPixel strip, i.e. board.D1
# pixel_pin = board.NEOPIXEL

# On a Raspberry pi, use this instead, not all pins are supported
pixel_pin = board.GP28

# The number of NeoPixels
num_pixels = 28

# The order of the pixel colors - RGB or GRB. Some NeoPixels have red and green reversed!
# For RGBW NeoPixels, simply change the ORDER to RGBW or GRBW.
ORDER = neopixel.GRBW

pixels = neopixel.NeoPixel(
    pixel_pin, num_pixels, brightness=.2, auto_write=False, pixel_order=ORDER
)

palette = [fancy.CRGB(255, 0, 0),  # red
           fancy.CRGB(0, 255, 0),      # blue
           fancy.CRGB(0, 0, 255),    # green
           fancy.CRGB(0, 0, 0)]        # Black

offset = 0  # Position offset into palette to make it "spin"

while True:
    for i in range(28):
        color = fancy.palette_lookup(palette, offset + i / 27)
        color_packed=color.pack()
        # debug - print((color_packed & 0xff0000) >> 16, (color_packed & 0xff00) >> 8, (color_packed & 0xff))
        pixels[i] = ((color_packed & 0xff0000) >> 16, (color_packed &
            0xff00) >> 8, color_packed & 0xff, 0) # Mask and shift individual integers  out of packed integer value.
        pixels.show()
    offset += 0.02 # Bigger number = faster spin

hopworks
 
Posts: 21
Joined: Fri Jul 06, 2012 5:50 pm

Re: FancyLed and RGBW - Compatible?

by mikeysklar on Thu Dec 09, 2021 3:55 pm

Your solution looks like the best option based on what the FancyLED API currently offers. Breakup the packed values back into individual RGB values and add your white.

mikeysklar
 
Posts: 6498
Joined: Mon Aug 01, 2016 8:10 pm

Re: FancyLed and RGBW - Compatible?

by hopworks on Thu Dec 09, 2021 8:37 pm

Thank you, although I am thinking about writing a simple class to do this for me. Thing is, I figured there would be one already written but I have not stumbled upon it as of yet. I'll worry about that after Christmas! =)

This is for a replacement project of a legacy light element for a small fiber-optic Christmas tree we set up. The original OEM fixture uses a VERY HEAVY 120vac to 12vac wall wart, an AC stepper motor for the light-altering spinning wheel, and a halogen bulb. The thing probably uses about $5 in power each day! My update uses 4 RGBW Jewels, a PI PICO, and a 5vdc 3amp switching power supply adapter. I am considering replacing the jewels with cut up 144ct per meter density RGBW strips in 4 rows, right next to each other. But time is of the essence.

Anyway, your simple reply that the library was viable saved me a ton of research time sir, and I appreciate it! Things like this with something new takes me down deep dark rabbit holes with no solution at the end. I learned to ask if it is doable first. THANKS! Merry Christmas!

hopworks
 
Posts: 21
Joined: Fri Jul 06, 2012 5:50 pm

Re: FancyLed and RGBW - Compatible?

by mikeysklar on Sat Dec 11, 2021 12:11 pm

I'm sure any code contributions you wish to make to FancyLED easier RGBW usage would be welcome.

You could even open an issue with your current solution just to help others find their way.

https://github.com/adafruit/Adafruit_Ci ... LED/issues

We would love to see a pic of your new xmas tree setup. Post it here when it gets up and running.

mikeysklar
 
Posts: 6498
Joined: Mon Aug 01, 2016 8:10 pm

Re: FancyLed and RGBW - Compatible?

by hopworks on Tue Dec 14, 2021 4:19 pm

Thank you mikeysklar, I certainly will do that! It's been a few years since I posted anything about mods, but this is a fun project and maybe it will help others out there with the same predicament.

On a side note, as I posted that issue on github, I thought that it would be easier just to shift the packed integers to the left 8 bits and OR the white 8 bit value into it. I am almost certain I tried that with unexpected results, but I really cannot find a reason why that would not work. I will try again... maybe I forgot to shift left 8 bits first. I will test and post back what I find.

Thanks!

hopworks
 
Posts: 21
Joined: Fri Jul 06, 2012 5:50 pm

Re: FancyLed and RGBW - Compatible?

by mikeysklar on Tue Dec 14, 2021 5:48 pm

Nice solution doing a left shift + logical OR for White bits. Elegant and should work.

mikeysklar
 
Posts: 6498
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.