julianschill / klipper-led_effect

LED effects plugin for klipper
GNU General Public License v3.0
645 stars 117 forks source link

144 GRBW light string causing problems #168

Closed oldschool1964 closed 6 months ago

oldschool1964 commented 6 months ago

I have a raspberry pi 4b running klipper. I am trying to get a LED strip sold from Amazon (https://www.amazon.com/gp/product/B01MYV6VGD/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&th=1) hooked up and using the Klipper-led_effect library running with this LED strip. I have an rpi pico connected to the rpi4 using USB, and it is now configured in Klipper and running correctly. I need to know how to configure this setup using an include statement in the printer.cfg file pointing to another file named leds.cfg that includes the configuration for the LEDs. The LED strip I purchased has 144 of the RGBW lights.

My leds.cfg file looks like the following:

[mcu pico_leds] serial: /dev/serial/by-id/usb-Klipper_rp2040_E6609CB2D31F5528-if00

[neopixel overhead] pin: pico_leds:gpio1 chain_count: 144 color_order: GRBW

initial_RED: 0.0 initial_GREEN: 1.0 initial_BLUE: 0.0 initial_WHITE: 0.0

When I save and reboot, Klipper responds with the following error:

Klipper reports: ERROR

neopixel chain too long

Once the underlying issue is corrected, use the "RESTART" command to reload the config and restart the host software. Printer is halted

If I remove the W, I can light up all 144 lights correctly, and I can use GRB as 1.0 for all three colors and come up with the "offwhite" color, but when I try to add in the W into the color_order, that's where this plugin doesn't work. If I add the W and limit the chain count to 72, I can use 0,0,0,1 for white, but the second half of the LEDs show all white, but the first half of the LEDs show Blue for 1/3 of the 72 lights, Green for 1/3, and Red for 1/3.

Any ideas why things aren't working correctly?

julianschill commented 6 months ago

This is a restriction of klipper. I limits the maximum bytes to 500. Every color on each LED is a byte. So the maximum for RGBW is 500/4=125 LEDs. If you are feeling adventurous you can increase the limit here (your repo will become "dirty"): https://github.com/Klipper3d/klipper/blob/4b77f29c1b20d5fdac577c557699e0b20f78d799/klippy/extras/neopixel.py#L13

You can also split up the chain into to and assign it to two pins.

I will close this ticket because it is not an issue of LED effects but of Klipper.

oldschool1964 commented 6 months ago

Can you assist with the issue with GRBW not showing the right colors? Even when I change it to 125 LEDs, and I just try to set one color to 1.0, I usually will get a repeating pattern of 3 colors and then black. Maybe the format I'm using to assign GRBW is incorrect? I didn't see anything in the documentation that explained GRBW vs GRB. I assumed once I used GRBW, the initial_WHITE was correct? GRBW isn't working for me at all, so if I can only use 125 LEDs, I would probably still be OK with it, as long as I can assign colors to all 125 including white.

julianschill commented 6 months ago

There are two kind of strips: one with three colors per LED (RGB) and those with 4 colors per LED (RGBW). The color order is the order in which the colors are sent out and is usually GRB or GRBW respectively. RGB needs 3 bytes per LED and RGBW needs 4 bytes per LED. The limit is 500 bytes, so you can have 500/3=166 RGB LEDs or 500/4=125 RGBW LEDs.

If you configure a GRBW strip like you have, with the color order GRB, it still works but shows the wrong colors. The protocol just sends out the colors and every LED takes 4 values and passes the rest to the next LED. So you get the following mapping:

GRBW GRBW GRBW GRBW...
GRBG RBGR BGRB GRBG...
julianschill commented 6 months ago

To set the white value just use 4 colors in the color definitions: (0,0,0,1). The fourth value is the value for white.

Verify your LED settings with SET_LED before you try anything with LED effects.

oldschool1964 commented 6 months ago

If I configure it as GRB, I can get it to show the colors correctly with all 144 lights, but the white is the “off white” as a mix of all three colors.

If I configure the chain_count: 72, color_order: GRBW, and I try to set it to (0,0,0,0), all the lights on half of the 144 are dark, and half of them are white?! If I try to set it to (R1,0,0,0), (0,G1,0,0), or (0,0,B1,0), or (0,0,0,W1), I get a pattern of 4 LEDs repeating, one Green, one Red, one Blue, and one LED turned off, and that pattern repeating over and over down the strip. Depending on which color is the 1 value, the LEDs will move that pattern up or down the strip, but it will always be that GRB blank pattern.

It seems to me that even if I set the color_order as GRBW, it is misnumbering the 1.0 value for the LEDs.

Any ideas there?

PS – thank you for all your time and help!! Hopefully others like me who want to use the GRBW lights can benefit if/when I can figure this thing out.

From: Julian Schill @.> Sent: Wednesday, December 6, 2023 4:34 PM To: julianschill/klipper-led_effect @.> Cc: oldschool1964 @.>; Author @.> Subject: Re: [julianschill/klipper-led_effect] 144 GRBW light string causing problems (Issue #168)

There are two kind of strips: one with three colors per LED (RGB) and those with 4 colors per LED (RGBW). The color order is the order in which the colors are sent out and is usually GRB or GRBW respectively. RGB needs 3 bytes per LED and RGBW needs 4 bytes per LED. The limit is 500 bytes, so you can have 500/3=166 RGB LEDs or 500/4=125 RGBW LEDs.

If you configure a GRBW strip like you have, with the color order GRB, it still works but shows the wrong colors. The protocol just sends out the colors and every LED takes 4 values and passes the rest to the next LED. So you get the following mapping:

GRBW GRBW GRBW GRBW...

GRBG RBGR BGRB GRBG...

— Reply to this email directly, view it on GitHubhttps://github.com/julianschill/klipper-led_effect/issues/168#issuecomment-1843795724, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEVVQWLY444EFCHBB67Y4BTYIDXERAVCNFSM6AAAAABAJ7LYAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBTG44TKNZSGQ. You are receiving this because you authored the thread.Message ID: @.**@.>>

julianschill commented 6 months ago

Ok, if the colors are correct with GRB, you have an RGB strip without white LEDs. For white you have to use (1,1,1).The white is a mix of all colors and might be a bit off. That's normal. You can try changing the values a bit to get a nicer color.

As you have a GRB strip, you can't configure it as GRBW. So use GRB with chain_count 144 and it should work.