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 import random
# Config, will be checked upstream # Config, will be checked upstream
height = 15 height = 25
width = 25 width = 15
framerate = 30 framerate = 10
brightness = 1 brightness = 1
##################################### #####################################
#receiver_IP = "10.2.113.151" #receiver_IP = "10.2.113.151"
@ -15,7 +15,7 @@ receiver_IP = "dummy"
receiver_port = 9999 receiver_port = 9999
# Do we have one single long line? # Do we have one single long line?
long_line = False long_line = True
# Type of installation (see details in data_generator) # Type of installation (see details in data_generator)
type = 2 type = 2
@ -55,7 +55,7 @@ def draw():
else: else:
col = pixels[px] col = pixels[px]
if i == cur_len: 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 pixels[px] = col
px -=1 px -=1
updatePixels() updatePixels()

View File

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