Search This Blog

Sunday, February 23, 2014

XBMC, Windows, Boblight, and the Woodenshark USB Lightpack

For along time I've seen groovy videos of ambilight systems making people's TV's dance with colour.  You can see a video of the results of all that follows here: http://lightpack.tv/


(and maybe buy your own lightpack!).

The idea is that it's
  • Cool
  • Gives an illusion of your TV being bigger
  • Increases the apparent contrast of the actual screen
  • Reduces eye fatigue as a whole
Well, that's the theory but it's that first point that's the main thing!

Never seen it - there are plenty of youtube videos etc (search for ambilight which is the original Phillips branded system).

Most open source implementations of this futz around with arduinos or Raspberry Pis to control the lights,  and you can buy LED strinps and wire them up to pins etc.  Sounds like a lot of hassle to me, and a waste of machine - why bother with a Pi/arduino as a controller, it's just another device needing power etc, and it should be trivially easy to get a PC to control one of these things.

Then, Woodenshark did a successful Kickstarter project to bring an easy solution to this problem and the result is here: http://lightpack.tv/ - a USB based LED light strip system.  So, I ordered one (about AU $100).  One lightpack works well for TVs up to 50" but you can get more than one and run them together.

Now, the general idea is to drive this thing with some software called Prismatik - latest releases here: https://github.com/Atarity/Lightpack/releases

But - this software does not work so well, and especially with XBMC.  It's got a lot of bugs - you need to disable Aero to get even vaguely decent performance (which you should probably have turned off anyway - who needs aero on an XBMC box?) - but it also doesn't detect what aspect ratio XBMC is playing in etc.  Basically I tried this out and even after a fair amount of config. work it was still slow and not doing what I wanted.

Now, the standard way of controlling these lightpacks in xbmc environments is via the boblight addon.  This little python addon takes care of all the XBMC stuff - detects what you are playing (movie, tvshow, music video etc) - works out the aspect ratio, and then grabs the right colour numbers from the screen to send them out to the lightpack (via a program called boblightd) which in turn triggers the LEDs to light up all at 60 frames a second.

So the XBMC addon talks to a little controller program - boblightd, a daemon (server) that listens to a port, and accepts control signals to send on to the lightpack LEDs.  Like most of these things, it's developed under Linux/unix.  It's not so easy/obvious how to get it going with Windows, but it is possible.  So normally you would still have boblightd running on some sort of micro-controller I guess, but again I wanted to avoid the extra machine.

So - I knew lightpack support had been added to boblightd, but I could not find a working Windows version.  The main xbmc/windows/boblight thread (here) - has a note from uncleted that said:
I switched the Lightpack driver to WinUSB using Zadig and commented out the libusb_detach_kernel_driver call from lightpack device code. It works for me now without crashing. Not sure if WinUSB is really required so I'll have a bit more of a play to find out.

So this is what we're going to do to get it working.

Here's what uncleted worked out and I did in case anyone wants to repeat:
  1. Install cygwin including development, opengl, usb
  2. SVN the boblightd source from:

    svn checkout http://boblight.googlecode.com/svn/trunk/ boblight-read-only
  3. Comment out the offending code block which makes it crash (it's not needed on Windows/Darwin): - lines 100 to 103 of devicelightpack.cpp:

            if ((error=libusb_detach_kernel_driver(devhandle, LIGHTPACK_INTERFACE)) != LIBUSB_SUCCESS) {
              LogError("%s: error detaching interface %i, error:%i %s", m_name.c_str(), LIGHTPACK_INTERFACE, error, UsbErrorName(error));
              return false;
            }

  4. Configure it:

    ./configure --without-portaudio --without-opengl --without-x11
  5. And then make; make install
     
  6. Grab the resulting binary boblightd.exe from \cygwin\usr\local\bin
 But, I have done this for you.  You also need a conf file for your lightpack. I've included a basic one for a sinlge lightpack mounted to a TV using the Andromeda pattern.

All of this you can grab here. - has the boblightd.exe, the conf file, and a few required cygwin dlls.

Unzip all of these into a folder on your htpc called:

c:\boblightd\

Now, one more necessary step - you must change the lightpack's USB driver to a more unix style friendly.  This will mean it no longer works with prismatik (presumably you can restore the older driver if you need this, but don't worry - if you're just using this thing with XBMC, change the driver and away you go).

To do this just download Zadig.  Run this (say yes when it wants to elevate to admin) - and tell it to show you all devices (in the menus) - then choose lightpack and tell it to replace the driver with the latest (included) WinUSB.  Done - not even a reboot (you should hear the device beeps as this happens, and you should now have a device in Device Manager -> Universal Serial Bus *Devices* -> Lightpack.

You'll want to run boblightd at startup before XBMC starts:

c:\boblightd\boblightd.exe -c c:\boblightd\boblight.conf -f

Finally, install and configure the xbmc boblight service addon - you don't need to change any ports/addresses since you're running it locally on the standard port. I set it all to 'fast' mode initially so it reacts quickly.

IMPORTANT NOTE : THIS BOBLIGHTD DOES NOT SEEM TO WORK CONSISTENTLY IF YOU PLUG THE LIGHTPACK INTO SOME USB3 PORTS (well, for me anyway) - use USB 2!!

If you're having issues, run boblightd as above from the command line (without the -f) ... and see what it says.

I have created an issue for boblightd here and presumably they will fix this up:
http://code.google.com/p/boblight/issues/detail?id=79

So to sum up, to get it going (one lightpack) - you need to:
  1. Grab the pre-compiled files
  2. Unzip all to c:\boblightd
  3.  Replace the lightpack USB driver using Zadig to WinUSB
  4. Run boblightd at startup as above
  5. Plug your lightpack into a USB2 port
  6. Install and configure the XBMC boblight service addon
...that's it!

21 comments:

  1. Thanks for giving me a mention :) Caught your post on Reddit.

    Sorry about not getting it sussed for you guys on XBMC - been busy, glad you figured it out :)

    I'm going to try to get rid of the WinUSB stuff if I can get the time - best thing for us Windows users would be to have our own USB wrapper layer going so we don't need to mess around installing other drivers. Using that it may even be possible to avoid all the Cygwin stuff too and build it under MinGW or maybe even VC++ at a stretch.

    Not sure why it's trying to detach the USB since as far as I know that function isn't supported for Windows port of libusb - it should do nothing under Windows.

    Since apparently it worked without WinUSB, I'm wondering whether we can get rid of it somehow without doing too many major things. Hopefully have a bit more time soon.

    ReplyDelete
  2. Hey you did the hard work...I just typed it up

    I really don't know much about it all, have never done any dev on windows at all really. But I am sure if you can do it with the standard drivers and without all the cygwin malarkey, people would be grateful!

    But this at least works, and very well - thanks again!

    ReplyDelete
  3. Thanks for the tips.

    Are you having issues with your configuration running mkv or mp4 files? I've followed your instructions and everything is going well but just when I run avi files my lightpack stop responding.

    thanks in advance :)

    ReplyDelete
  4. Problem solved!
    I hadn't the latest ati drivers installed. Thanks!! :)
    Continue the good work :)

    Continue the good work :)

    ReplyDelete
  5. Thank you for this. I was pulling my hair out trying to get the Boblight Daemon working in windows.

    ReplyDelete
  6. Hey there - thanks for putting this up! My Lightpack had been collecting dust until I came across this guide today. I've got everything followed to the T, but on the last step, when I try to launch the Boblight service addon in XBMC, it says it can't connect to the boblightd. I've got your files extracted into C:\boblightd and the exe is in startup. You mention it needs to be configured - I'm guessing that's where I'm missing something. I opened the config file from the boblightd folder and changed the device name to "lightpack" as it shows in my device manager, but still no joy. Any guidance? I was going to give up and try out Amibox since I read on r/lightpack that it's working well with XBMC now, but since I replaced the USB driver, the Ambibox app won't connect to my lightpack any more. Any guidance would be much appreciated. TIA

    ReplyDelete
  7. You need to kick off the full boblight task at startup and maybe confirmt hat is running in task manager, then start the xbmc bit.

    I think I use a scheduled task at the user login for:
    c:\boblightd\boblightd.exe -c c:\boblightd\boblight.conf -f

    But I can't check it from here. If you confirm it is running the xbmc bit is easy, my guess it it's not running at all because you aven't got your startup bit right.

    ReplyDelete
    Replies
    1. Thanks! I believe you were correct - I assumed I could just put a shortcut to the exe into my startup folder and call it a day, but I added a .bat file to the startup folder instead, and now XBMC tells me the boblight addon is successfully enabled. Bad new: lights still don't work. When I last used Prismatik, I had the lights turned off (sleep mode, or whatever - the moon icon) - could that be the issue? Is there nothing telling them to turn back on?

      Delete
  8. Hey Dustin - not sure on that side of it, maybe wake it up in Prismatik and confirm it works in general, then repeat this process?

    ReplyDelete
    Replies
    1. Any tips on getting it to work in Prismatik now that the USB driver has been swapped?

      Delete
    2. Use zadig to swap the usb drivers back I guess?

      Delete
  9. I had it working perfectly with windows 7, but now that I switched to windows 8.1, it doesn't work. Everything goes ok, and xbmc says boblight connected, but nothing lights. Any help, please?

    ReplyDelete
  10. No idea, no windows 8 here I am afraid. Sorry!

    ReplyDelete
    Replies
    1. Mmm... Is there any log that can show what's happening? because, as xbmc boblight says connected, I can't figure out what is the problem.

      Delete
  11. there any way to make it work with android lightpack in xbmc?

    you mention is I could make it work in the addon in xbmc boblighthd of android 4.2.2?

    ReplyDelete
  12. Hi, I have the same problem as Manuel V with windows 8, if I run boblightd it says "libusbx warning could not retrieve port number for device"

    ReplyDelete
  13. Thank you for getting this out there, it is comprehensive and aided me to get my device working.

    ReplyDelete
  14. Thank you for this guide, helped me a lot setting up Lightpack and Boblight on Windows 10.

    If anyone's interested, I've built an updated version using Speedy1985's optimized version (https://github.com/Speedy1985/boblightd-for-raspberry) and a pull request with S/N fix from the same repo (https://github.com/Speedy1985/boblightd-for-raspberry/pull/1).

    - Optimized binary is only 354KB (about 10 times smaller than original build).
    - All names in config files should be 3 characters long (T01, B01, L05, etc).
    - I've also modified code a little to use config file located in the same folder as the executable (no need to use -f option) and to write proper log in the same folder. You can launch it from anywhere, not only c:\boblightd.

    Compiled binary (x64) and the source can be downloaded here: https://www.dropbox.com/s/mtiwdb0iv2614uv/boblightd.zip

    I've also included config file for 2 Lightpacks installed in an Andromeda formation. There's a very strange bug with Lighpack channels from the first 5 strips all messed up on both units at the same time, this was present in all versions of the code. I was too lazy to debug it properly, so I just changed channels according to their position, not their connection.

    ReplyDelete
  15. Thank you for this guide, helped me a lot setting up Lightpack and Boblight on Windows 10.

    If anyone's interested, I've built an updated version using Speedy1985's optimized version (https://github.com/Speedy1985/boblightd-for-raspberry) and a pull request with S/N fix from the same repo (https://github.com/Speedy1985/boblightd-for-raspberry/pull/1).

    - Optimized binary is only 354KB (about 10 times smaller than original build).
    - All names in config files should be 3 characters long (T01, B01, L05, etc).
    - I've also modified code a little to use config file located in the same folder as the executable (no need to use -f option) and to write proper log in the same folder. You can launch it from anywhere, not only c:\boblightd.

    Compiled binary (x64) and the source can be downloaded here: https://www.dropbox.com/s/mtiwdb0iv2614uv/boblightd.zip

    I've also included config file for 2 Lightpacks installed in an Andromeda formation. There's a very strange bug with Lighpack channels from the first 5 strips all messed up on both units at the same time, this was present in all versions of the code. I was too lazy to debug it properly, so I just changed channels according to their position, not their connection.

    ReplyDelete
  16. Thank you for this guide, helped me a lot setting up Lightpack and Boblight on Windows 10.

    If anyone's interested, I've built an updated version using Speedy1985's optimized version (https://github.com/Speedy1985/boblightd-for-raspberry) and a pull request with S/N fix from the same repo (https://github.com/Speedy1985/boblightd-for-raspberry/pull/1).

    - Optimized binary is only 354KB (about 10 times smaller than original build).
    - All names in config files should be 3 characters long (T01, B01, L05, etc).
    - I've also modified code a little to use config file located in the same folder as the executable (no need to use -f option) and to write proper log in the same folder. You can launch it from anywhere, not only c:\boblightd.

    Compiled binary (x64) and the source can be downloaded here: https://www.dropbox.com/s/mtiwdb0iv2614uv/boblightd.zip

    I've also included config file for 2 Lightpacks installed in an Andromeda formation. There's a very strange bug with Lighpack channels from the first 5 strips all messed up on both units at the same time, this was present in all versions of the code. I was too lazy to debug it properly, so I just changed channels according to their position, not their connection.

    ReplyDelete

Note: Only a member of this blog may post a comment.