Error when using set_led_data(0, data) in Python


#1

This is the example code im trying to use:

from blinkstick import blinkstick
from time import sleep, time
from colorsys import hsv_to_rgb

speed = 1
fps = 50.0
cut = 2
brightness = 1.0

stk = blinkstick.find_first()
cnt = 2

while True:
    data = []
    for i in range(1,cnt+1):
        (r, g, b) = hsv_to_rgb(i/float(cnt*(1.0/cut))+time()*speed, 1, brightness)
        data = data + [int(g*255), int(r*255), int(b*255)]
        #print(int(r*255), int(g*255), int(b*255), i/32.0,)
    stk.set_led_data(0, data)
    sleep(1/fps)

This is the error im getting:

Traceback (most recent call last):
  File "C:/Users/Daniel/PycharmProjects/Blinkstick/toys-master/rotatingrainbow.py", line 26, in <module>
    stk.set_led_data(0, data)

  File "C:\Users\Daniel\PycharmProjects\Blinkstick\venv\lib\site-packages\blinkstick\blinkstick.py", line 458, 
    in set_led_data
   self._usb_ctrl_transfer(0x20, 0x9, report_id, 0, bytes(bytearray(report)))

 File "C:\Users\Daniel\PycharmProjects\Blinkstick\venv\lib\site-packages\blinkstick\blinkstick.py", line 226, in 
  _usb_ctrl_transfer
    data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c)) for c in data_or_wLength])

  File "C:\Users\Daniel\PycharmProjects\Blinkstick\venv\lib\site-packages\blinkstick\blinkstick.py", line 226, 
in <listcomp>
    data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c)) for c in data_or_wLength])

TypeError: ord() expected string of length 1, but int found

Im using a BlinkstickFlex Chip with 2 Leds attached to it. I used this code with the same board before once and it worked perfectly. I dont know why it doesnt now…

Im also using Pyhton 3.5

I searched around the Forums but couldn’t find any help to my problem.


#2

Please take a look at the issues regarding this at github:


#3

Thank you. It’s working again :slight_smile:

(Also thanks for the fast reply)