grantHarris / raspberrypi-e131-led

Accepts multiple E1.31 universes for mapping on to a single LED string connected to a raspberry pi
MIT License
2 stars 2 forks source link

WS281x Support #4

Open SpikedCola opened 4 years ago

SpikedCola commented 4 years ago

Hi there,

This project exactly what I've been looking for. Got it to build on my Raspberry Pi Model A (running raspbian buster), but I'm not getting any output. This is my config.yaml file:

---
gpionum: 18
led_count: 170
brightness: 255
strip_type: WS2811_STRIP_GRB
mapping:
  1:
  - input:
      start_address: 1
      total_rgb_channels: 170
    output:
      start_address: 0

Here is the log of e131bridge starting and running (note I changed multicast ip setup from wlan0 to eth0):

pi@raspberrypi:~/raspberrypi-e131-led/Release $ sudo ./e131bridge --verbosity=debug --stats=true
[2019-12-24 16:36:40.034660] [0xb6f172a0] [info]    Using config file ./config.yaml
[2019-12-24 16:36:40.042369] [0xb6f172a0] [info]    E1.31 socket created.
[2019-12-24 16:36:40.045076] [0xb6f172a0] [info]    E1.31 client bound to port: 5568
[2019-12-24 16:36:40.047502] [0xb6f172a0] [info]    Joining universe: 1
[2019-12-24 16:36:40.049970] [0xb6f172a0] [debug]   Executing shell command: sudo ip maddr add 239.255.0.1 dev eth0
[2019-12-24 16:36:40.415111] [0xb6f172a0] [info]    Stats enabled
[2019-12-24 16:36:40.418009] [0xb6f172a0] [info]    Using WS2811 strip
[2019-12-24 16:36:40.420835] [0xb2950450] [info]    E.131 receive data starting
[2019-12-24 16:36:40.424157] [0xb214f450] [info]    Universe: 1, Good: 0FPS, Dropped: 0FPS

When I start Jinx, I do see packets being received, but there is no activity on the strip:

[2019-12-24 16:37:28.196366] [0xb2950450] [debug]   Packet for universe: 1
[2019-12-24 16:37:28.236336] [0xb2950450] [debug]   Packet for universe: 1
[2019-12-24 16:37:28.276365] [0xb2950450] [debug]   Packet for universe: 1
[2019-12-24 16:37:28.316349] [0xb2950450] [debug]   Packet for universe: 1
[2019-12-24 16:37:28.356353] [0xb2950450] [debug]   Packet for universe: 1
[2019-12-24 16:37:28.396367] [0xb2950450] [debug]   Packet for universe: 1
[2019-12-24 16:37:28.436423] [0xb2950450] [debug]   Packet for universe: 1
[2019-12-24 16:37:28.456264] [0xb214f450] [info]    Universe: 1, Good: 10FPS, Dropped: 0FPS

If I run 'strandtest.py' from rpi-ws281x/python/examples, with the following config, the strip works as expected:

# LED strip configuration:
LED_COUNT      = 170 # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255     # Set to 0 for darkest and 255 for brightest
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53

I've also noticed that CTRL+C has no effect on e131bridge - I have to kill -9 it to make it stop.

When I started looking for why the pixels may not be lighting up, I noticed that all of WS2811Strip.cpp and WS2811Strip.h are commented out. Only APA102 looks normal.

Perhaps you can offer some insight here. Really looking forward to getting e1.31->ws281x working!


Note: I needed to do the following in order to build:

grantHarris commented 4 years ago

I believe that code was commented out when I was using it in a project for APA102 and had some issue with building the lib code on my pi. It was easier to just comment out than fix the compile. This was just a dump of the source code at that point in time and could probably use some love to get it into a more documented and friendly state.

I can confirm the code for WS2811 absolutely worked so you should be able to get it working again fairly easily.

I'm not actively developing on this at the moment, but I'm still here to answer any questions. If you get it working again I'd welcome a PR :)

SpikedCola commented 4 years ago

Hey Grant,

Thanks for taking the time to reply.

Unfortunately I didn't understand what I was getting myself into with this codebase. I've spent a few hours trying to learn what is going on, and get it to compile, but I'm stuck at a linker error (I'm by no means a C++ programmer). It seems some part of the compiling/linking process can't find the ws2811 library:

/usr/bin/ld: CMakeFiles/e131bridge.dir/src/WS2811Strip.cpp.o: in function WS2811Strip::WS2811Strip(YAML::Node&)': /home/jordan/raspberrypi-e131-led/src/WS2811Strip.cpp:7: undefined reference tows2811_init' /usr/bin/ld: /home/jordan/raspberrypi-e131-led/src/WS2811Strip.cpp:8: undefined reference to `ws2811_get_return_t_str'

At this point I think I'm just going to give up... There are yaml config options in the source that don't exist in the config file (eg. strip_channel, invert). Perhaps it works with APA102, but WS2811 needs more love than I am capable of giving.

EDIT Finally found a reference to the ws2811 lib, commented out in CMakeLists.txt. Glad I'm not going crazy!

SpikedCola commented 4 years ago

Spent a bit more time on this after figuring out the library issue, and I seem to have run into an issue you've also run into: the call to ws2811_render() seems to hang. As you say, _init returns successfully, but _render hangs its respective thread. I noticed you closed the issue on rpi_ws281x - did you ever figure out what was causing this? Or is this what drove you to APA102?

grantHarris commented 4 years ago

If I remember correctly it was a stupid error and I wasn't initializing the struct properly I think. I forgot about that until you mentioned it.

I had this as private, but I just opened it. Feel free to look at this repo. https://github.com/grantHarris/NZR-e131. The ws2811 issue was fixed. This repo was a fork with some recording and playback functionality implemented. I just merged the branch it was on into master.

The reason I was using APA102 was because it was a project which required really small LED's: DotStar Micro LEDs (APA102–2020)

SpikedCola commented 4 years ago

Thanks, that's excellent! I ended up getting WS2811 working, so it will be interesting to compare with what you did in NZR-e131. Will send over a PR soon-ish.