gkaindl / ambi-tv

a flexible ambilight clone for embedded linux
296 stars 85 forks source link

WS2801 support #4

Open iLLiac4 opened 10 years ago

iLLiac4 commented 10 years ago

Hi! Can you please help me to give some guidance to add support for WS2801 leds. I think a lot of people will love to see that.

gkaindl commented 10 years ago

afaik the WS2801 requires a far more precise timing than the LPD8806, so I'm not sure if you can drive it directly from the Raspberry Pi's spidev. However, I haven't tried this myself either, so I'm just guessing here. I've also seen this adapter board for the WS2801, which looks as if it works around the timing issue: http://www.hackerspaceshop.com/raspberrypi-ws2801.html

Apart from the hardware issue, adding support shouldn't be too hard: you need to implement another "sink" component pretty much identical to the current lpd8806 sink (the only sink right now), which implements the WS2801's "protocol". then register your new component in registrations.c like all the other components, and finally add the new sink to your ambi-tv configuration file.

You can write your own components for different LED effects ("processors") in this manner, too.

iLLiac4 commented 10 years ago

As far as i know the ws2801 is almost the same as lpd8806. The precise timing is required by ws2811 chip and not by ws2801.

gkaindl commented 10 years ago

All the better, if it's similar to the lpd8806, then it should be all the easier to add support for it. I'd really suggest to have a look at lpd8806-sink-component and hack the support for ws2801 into there (please send a pull request if you do, since you weren't the first to ask for the ws2801, but unfortunately, I don't have such a strip to test with).

Mrjohns42 commented 10 years ago

The only difference, software-wise, for the ws2801 is that the SPI protocol might be different. I would recommend looking at the manual for the chipset. It shouldn't be difficult to modify the existing driver to work with these. You might even be able to snag a driver from one of adafruits tutorials.

If you haven't bought the ws2801 already, keep in mind you're paying quite a bit more for significantly less LEDs per meter.

gfix commented 10 years ago

Hi guys,

I have ws2801 leds, and it seems modifying the lpd8806 sink isn't too difficult. I haven't received the stuff I ordered from Hong Kong yet, so I have only tested my ws2801 sink using the mood light program. As far as I can tell, the only differences are:

I might have forgotten something, and I have only tested this with the mood light, so I haven't looked at gamma correction. There might be some problems I haven't encountered yet as well. The ws2801 doesn't need a latch bit, but needs the clock signal to be kept low for at least 500 microseconds to latch the data. I don't have any knowledge about SPI so I don't really know if this is going to be a problem. I can put my modified sink up here when I have tested it some more.

gfix commented 10 years ago

BTW, great work gkaindl!

gkaindl commented 10 years ago

@gfix thanks!

from your description, it sounds as if the best way to implement this would be to actually rename the lpd8806 sink to something else (like spidev-led-sink or something) and add a component parameter to switch between lpd8806 and ws2801 behavior, since it's so similar.

To keep the clock signal low for 500 microseconds, I think that should be doable by sending the last byte via spidev's ioctl() interface, using the delay parameter (and possibly a lower clock speed).

I can go ahead and implement this, but it'll take me a while, since I'm currently a bit busy. Alternatively, if you do it and send me a pull request, I'll incorporate it.

Regarding the gamma correction: That shouldn't be much of a problem. The gamma is configurable separately for all 3 channels, and it mostly boils down to preference: The settings I'm using in the default conf are basically just what works well for me – I tried the gamma that PAL uses earlier, but that was way too dark for my taste. What I did was mirroring my display on the TV and fill it with a couple of solid color pictures to see if it looks ok, then settled on the gamma that I liked most.

sn00zerman commented 10 years ago

I received my WS2801 LED-strips yesterday (bought via Ebay China). Today I did some testing.

I'm willing to write the WS2801 component, but I'm leaving on holidays tomorrow night ... When I return by the end of september, and nobody has written the WS2801 support, I will write it :-) (I'm planning on a second ambi-tv for our bedroom, and I will use the WS2801 for it)

YoBnEb commented 10 years ago

Hi,

first I'd like to say thank you gkaindl for that great project.

I've completed my setup two hours ago, but the problem is, that I have flickering with my WS2801 leds. Colors, and configuration of my leds is great.

Can someone explain me where to set that delay? I'd like to try it with 900 uS to see if it's the problem with flickering.

I've searched for that delay, but cannot find anything.

Thanks for your help.

rcph commented 10 years ago

sn00zerman: ...that would be cool, I also have LED strip WS2801 + boblight, but I would like to use ambi-tv: o)

blais0u commented 10 years ago

@sn00zerman I'll wait for your tutorial beacause i want too try it too with my WS28001 Led that i already have on my tv with my arduino

Dec64 commented 10 years ago

Is there any news on this? Is anyone working on ws2801 support as i am not technical enough to make the changes myself

rcph commented 10 years ago

@sn00zerman ...do you have any solutions?

gfix commented 10 years ago

I have ws2801 and have made it work. However I haven't had the time to implement it such that you just can set the type of led strip (or chip rather) in the conf-file, as @gkaindl suggested. I can upload the files I have altered (which really isn't much). I didn't have to do anything with the delay. I'm not sure that it is even necessary if you have the 30fps as in the sample conf, since the data will have the time to latch between two frames (I guess the clock signal is set to low after the data is transferred?) I don't experience any flickering.

Dec64 commented 10 years ago

If you could upload them files so i could have a play around and see if i can get it working too, that would be great!

gfix commented 10 years ago

I just forked the repo and added my changes in order to make the ws2801 work. I also added my conf file. I did this because I remembered that I experienced some flickering on the left side of the screen, but this was only due to the crappy capture card, so I only needed to add a few more pixels of cropping. If your colours don't match at all, you have to change the order the data is sent to the leds (I'm not talking about gamma correction here): Change the lines 196-198 in the "ws2801-spidev-sink.c" file to the order you need. Then run "make clean" and "make" again. This should also be one of the parameters you should be able to alter in the config file once we fix this for real. Wish you luck!

gfix commented 10 years ago

@YoBnEb, did you figure out the flickering? Have you made sure that you have grounded the led-strip to the same ground as the external power supply?

Dec64 commented 10 years ago

@gfix Thank you very much, I will take a look. Cheers for all the work and sharing it.

YoBnEb commented 10 years ago

@gfix no, I didn't had time to figure out what the problem is. But I also changed the crop values, and so the flickering is minimal.

I use only one power supply for everything, so I think that couldn't be the problem, but thanks for that idea.

Esylias commented 10 years ago

@YoBnEb can you upload your config? i have too that flickering and no config values can minize this

My LEDs also working fine with boblight, so hardware setup is working fine

mnorthfield commented 10 years ago

crop-left 1 crop-top 1 crop-right X < Can't get this to stop flickering crop-bottom 1

Flicker only accrue when there is a black screensaver.

Esylias commented 10 years ago

@mnorthfield

these are my working crop-values

v4l2-grab-source { name v4l2-video video-device /dev/video0 buffers 8 crop-left 60 crop-top 40 crop-right 60 crop-bottom 40 autocrop-luminance-threshold -20 }

The flickering will be produced, if the grabber get an black pixel

mnorthfield commented 10 years ago

@Esylias

Tried your settings and my frame went wakoo when I run a pitch black screen. Lights everywhere.

This is the problem I'm stuck with, but I think it has to do with a crappy video-grabber. Pretty annoying when watching Boardwalk Empire. Managed to fix it on the left side by setting it to 1.

The input is black, it's just my 5min burn in on the plasma:

https://dl.dropboxusercontent.com/u/22263213/AmbiTV/2013-10-28%2021.53.54.jpg https://dl.dropboxusercontent.com/u/22263213/AmbiTV/2013-10-28%2021.55.28.jpg

-- Max

mnorthfield commented 10 years ago

Changed the video-grabber and the problem is gone.