I'm developping my own libraries for controlling a led strand (12mm Diffused Thin Digital RGB LED Pixels (Strand of 25) - WS2801) with a python script using module pyserial. I'm using Adalight and the strand works like a charm with lightpack or processing, but I experience problems when I try to send my own serial data to it.
Here is a piece of code I use to test it :
Code: Select all
from serial import Serial
from time import sleep
# magic word + led number + checksum which are recognized as valid by my adalight
buffer = ['A','d','a','\x32','\x35','\x52']
# filling my buffer variable with 0 (6 bytes for header and 75 bytes for rgb leds data)
for i in range(75):
buffer.append('0')
# opening my serial port, works well
arduino = Serial('COM3',115200)
# then I send a dim white (10,10,10) to my 25 leds
while 1:
for i in range(6,81):
buffer[i] = chr(10)
arduino.write(buffer)
sleep(.01)
I figure out that if I send
- header then 25 rgb data for red then, without sending the header again, 25 rgb data for green, I get my 25 Led with proper color.
but if I send color data without resending header, my strand goes stuck after a few iteration, so I guess I've to send the header every time.
I spend hours testing things, I can't figure out what's wrong.