Update fading strip

master
Raphaël Vinot 2015-05-10 17:31:30 +02:00
parent e2df6a69ef
commit c425f132bd
2 changed files with 12 additions and 11 deletions

View File

@ -4,9 +4,9 @@ from prepare import prepare
import random
# Config, will be checked upstream
height = 15
width = 25
framerate = 30
height = 25
width = 15
framerate = 10
brightness = 1
#####################################
#receiver_IP = "10.2.113.151"
@ -15,7 +15,7 @@ receiver_IP = "dummy"
receiver_port = 9999
# Do we have one single long line?
long_line = False
long_line = True
# Type of installation (see details in data_generator)
type = 2
@ -55,7 +55,7 @@ def draw():
else:
col = pixels[px]
if i == cur_len:
col = color(red(col) * 0.9, green(col) * 0.9, blue(col) * 0.9)
col = color(red(col) * 0.7, green(col) * 0.7, blue(col) * 0.7)
pixels[px] = col
px -=1
updatePixels()

View File

@ -56,8 +56,8 @@ Possibilities:
def make_line(type, nb, long_line):
'''
If moving up or down: 0 <= nb <= height
If moving right or left: 0 <= nb <= width
If moving up or down: 0 <= nb < height
If moving right or left: 0 <= nb < width
'''
indexes = []
if type == 0:
@ -68,7 +68,7 @@ def make_line(type, nb, long_line):
elif type == 1:
# top left -> right / OK
pxstart = nb * width
for w in range((width)):
for w in range(width):
indexes.append(pxstart + w)
elif type == 2:
# bottom left -> up / OK
@ -78,7 +78,7 @@ def make_line(type, nb, long_line):
elif type == 3:
# bottom left -> right / OK
pxstart = width * (height - 1) - nb * width
for w in range((width)):
for w in range(width):
indexes.append(pxstart + w)
elif type == 4:
# top right -> down / OK
@ -88,7 +88,7 @@ def make_line(type, nb, long_line):
elif type == 5:
# top right -> left / OK
pxstart = width - 1 + nb * width
for w in range((width)):
for w in range(width):
indexes.append(pxstart - w)
elif type == 6:
# bottom right -> up / OK
@ -98,10 +98,11 @@ def make_line(type, nb, long_line):
elif type == 7:
# bottom right -> left / OK
pxstart = width * height - 1 - nb * width
for w in range((width)):
for w in range(width):
indexes.append(pxstart - w)
else:
raise Exception("Invalid Type")
if long_line and nb % 2 == 1:
return reversed([pixels[px] for px in indexes])
return [pixels[px] for px in indexes]