Commit 600e5593 authored by Fjen Undso's avatar Fjen Undso
Browse files

lights.py: cleanup

parent 578e4f3d
......@@ -39,44 +39,17 @@ def make_stripe_data(pixellist):
assert(len(pixellist) % 4 == 0)
if len(pixellist) > LED_NUM * 4:
pixellist = pixellist[:LED_NUM * 4]
if len(pixellist) / 4 < LED_NUM * 4:
if len(pixellist) < LED_NUM * 4:
print("!!! Filling missing pixels")
missing_pixels = (LED_NUM - int(len(pixellist) / 4)) * 4
pixellist += missing_pixels * [0]
stripe_data = bytes(0)
for i in range(LED_NUM):
stripe_data += rgbw2bytes(pixellist[i * 4:i * 4 + 4])
return stripe_data
return rgbw2bytes(pixellist)
def pixelsteps(index):
bytes = b'\x00'
for i in range(LED_NUM):
if i == index:
bytes += rgb2bytes(255, 0, 0, 0)
else:
bytes += rgb2bytes(0, 0, 0, 0)
return bytes
def fill(red, green, blue, white=0):
data = b'\x00'
for i in range(LED_NUM):
data += rgb2bytes(red, green, blue, white)
return data
def fill_rainbow(brightness=1):
while True:
for i in range(255):
send(fill(round((255 - i) * brightness), round(i * brightness), 0))
for i in range(255):
send(fill(0, round((255 - i) * brightness), round(i * brightness)))
for i in range(255):
send(fill(round(i * brightness), 0, round((255 - i) * brightness)))
print(make_stripe_data([1, 2, 3, 4]))
colors = make_stripe_data([0, 255, 255, 0] * 24)
SEQUENCE=0
send(colors)
SEQUENCE=128
send(colors)
# while True:
# for i in range(LED_NUM):
# send(pixelsteps(i))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment