In [1]:
import time
import numpy as np

import webcolors
from blink1 import blink1


"""
On Windows need to install: http://sourceforge.net/p/libusb-win32/wiki/Home/
"""

In [2]:
# Setup.
t_lo = 0.2
t_hi = 1.0

t_elapse = 60.0*30

In [3]:
b = blink1.Blink1()

t_0 = time.time()

RGB = [0, 0, 0]
while time.time() - t_0 < t_elapse:
    ix = np.random.random_integers(0, 2)
    
    RGB[ix] = np.random.random_integers(0, 255)
    
    dt = np.random.uniform(t_lo, t_hi)
    dt_ms = dt * 1000.
    b.fade_to_rgb(dt_ms, RGB[0], RGB[1], RGB[2])
    time.sleep(dt*1.5)
    
b.off()


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-9af195a70023> in <module>()
----> 1 b = blink1.Blink1()
      2 
      3 t_0 = time.time()
      4 
      5 RGB = [0, 0, 0]

c:\Users\pvvilleneuve\Projects\working_python\venv\lib\site-packages\blink1\blink1.py in __init__(self, gamma, white_point)
     79         )
     80 
---> 81         self.dev = self.find()
     82         if not self.dev:
     83             raise BlinkConnectionFailed("Could not find an attached Blink(1)")

c:\Users\pvvilleneuve\Projects\working_python\venv\lib\site-packages\blink1\blink1.py in find()
     88     @staticmethod
     89     def find():
---> 90         dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
     91         if dev == None:
     92             return None

c:\Users\pvvilleneuve\Projects\working_python\venv\lib\site-packages\usb\core.py in find(find_all, backend, custom_match, **args)
   1197                 break
   1198         else:
-> 1199             raise ValueError('No backend available')
   1200 
   1201     k, v = args.keys(), args.values()

ValueError: No backend available

In [41]:
np.random.random_integers?

In [50]:
b.off()

In [33]:
b.fade_to_rgb(500, 200,0, 0)

In [3]:
blink1.VENDOR_ID


Out[3]:
10168

In [ ]: