New Python library for blink(1) & blink(1) mk2

Salim Fadhley has taken on the job of rewriting the basic Python blink(1) library we provided and making it so much more awesome. You can get it here: https://pypi.python.org/pypi/blink1

As he says: “This is a rewrite of ThingM’s original Python library. It includes the following modifications:

  • 100% test coverage on all library components
  • Python 3.x compatible
  • Automatic installation via Python Package Index.
  • Higher level control over the blink(1).
  • Single implementation with pyusb, intended to be installed with admin access or virtualenv.”

He’s also added features like gamma correction and white-point correction. Salim has been pushing his changes to the official ThingM blink1 github and we’re very proud to have it as part of the official blink(1) software set.

 

4 Comments

Andreas L

I am a newbie to python but struggled for hours to make it run. Any help is appreciated but I only get error messages like

Traceback (most recent call last):
  File "./blink.py", line 7, in 
    blink1 = Blink1.open
AttributeError: class Blink1 has no attribute 'open'

or

Traceback (most recent call last):
  File "./blink1.py", line 23, in 
    from .kelvin import kelvin_to_rgb, COLOR_TEMPERATURES
ValueError: Attempted relative import in non-package

Is there any manual how we can download and start this package so that it is running out of the box? There seems to be so many things missing: Which python version (2.7?, 2.6?, 3?), where to install the test-files, how to run the example etc pp.

todbot

Hi Andreas,

How did you install the library?

Have you seen these docs: https://github.com/todbot/blink1/tree/master/python/pypi ?
There’s also a couple of demo scripts there to look at too.

Note that just the host of that Python library by Salim, not the author. You may want to ask him those questions.

Finally, you may find one of the original (now “alternate”) Python libraries more useful: https://github.com/todbot/blink1/tree/master/python/alternative_libraries

Unfortunately, getting Python to talk to USB hardware is really hit-or-miss, which is why we have so many different approaches.

Andreas L

Thanks for the immediate reply. There seems to be many python-versions and, at least for me, it is not entirely clear what to use. Maybe this has to do with the USB problem. So I understand it correctly that this is a trial-and-error approach?

I gained a little ground by using now the correct version because I get and USB-error message (File “/Library/Python/2.7/site-packages/blink1/blink1.py”, line 90, in find
dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
File “build/bdist.macosx-10.9-intel/egg/usb/core.py”, line 864, in find
ValueError: No backend available). I will look further.

todbot

Yes, it’s been trial-and-error for me. I’m not much of a Python expert though. The default “pypi” library should work for both Python 2.7+ and Python 3.x, but I think it might actually need Python 3.x. (or at least I’ve not been able to get it to work under 2.7+)

That “no backend available” message is because there’s no libusb driver for Python. I’ve had a lot of similar problems on my Mac too. It doesn’t help that the Mac comes with a Python (and needs it for the system), but when you use “pip” that could be using your own install of Python (if using homebrew or macports)

On my to-do list is to level-up in my Python abilities (I wrote the library in “alternative_libraries”) enough to fold some of the ease-of-use ideas I’ve seen in other Python libraries into this library and take over its development from Salim.

Apologies for it being confusing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>