Re: [WS281x](SK6812 driver for the Omega2? [Solved])
In the last days I played a bit with Python to get the WS281x working wirth Luz' module.
As I want to use HLS color schema (it allows to change the luminosity of the color by only one number), I programmed a function HLS to RGB color string:
By using the following additional function, it allows using a 2 dimensional color matrix which is converted in the corresponding hex color string needed for the module. (It might be useful and easier to use a matrix to handle LED chains instead of a string of hexadigitals)def hls2rgb_hexstring(hls_matrix): dim1 = len(hls_matrix) try: dim2t = len(hls_matrix) except: dim2t = 0 if dim2t == 0: dim2 = dim1 dim1 = 1 else: dim2 = dim2t if dim1 == 1: h = hls_matrix/360.0 l = hls_matrix/100.0 s = hls_matrix/100.0 col_led_string = hls2rgb(h,l,s) return col_led_string else: col_led_string="" for i in range(0,dim1): h = hls_matrix[i]/360.0 l = hls_matrix[i]/100.0 s = hls_matrix[i]/100.0 col_led_string = col_led_string + hls2rgb(h,l,s) return col_led_string
To display a color gradient among several LED's (here 40) one has to run this code, which is using both function above:color_start = 0 color_end = 359 nr_led = 40 lum = 2 sat = 100 colorMatrix =  for i in range(color_start,color_end, abs(color_end-color_start)/nr_led): colorMatrix.append([i,lum,sat]) #print [i,lum, sat] print colorMatrix with open('/dev/ledchain0','w') as export: export.write(hls2rgb_hexstring(colorMatrix))