@mvaladas This is where i am so far,
i have used your french flag as a test along with some parts from the Knightrider effect, The whole matrix lights up all at once and then fades out and stays off, i cant seem to get the pixels scrolling across the matrix,
Could you point out where i am going wrong and maybe point me in the right direction?
Code
import hyperion
import time
import colorsys
# Get the parameters
speed = float(hyperion.args.get('speed', 1.0))
fadeFactor = float(hyperion.args.get('fadeFactor', 0.7))
# Check parameters
speed = max(0.0001, speed)
fadeFactor = max(0.0, min(fadeFactor, 1.0))
# Initialize the led data
width = 10
imageData = bytearray()
# french flag, width = 10
# blue
imageData += bytearray((int(0), int(85), int(164)))
imageData += bytearray((int(0), int(85), int(164)))
imageData += bytearray((int(0), int(85), int(164)))
# white
imageData += bytearray((int(255), int(255), int(255)))
imageData += bytearray((int(255), int(255), int(255)))
imageData += bytearray((int(255), int(255), int(255)))
imageData += bytearray((int(255), int(255), int(255)))
# red
imageData += bytearray((int(239), int(65), int(53)))
imageData += bytearray((int(239), int(65), int(53)))
imageData += bytearray((int(239), int(65), int(53)))
# Calculate the sleep time and rotation increment
increment = 1
sleepTime = 1.0 / (speed * width)
while sleepTime < 0.05:
increment *= 2
sleepTime *= 2
# Start the write data loop
position = 0
direction = 1
while not hyperion.abort():
hyperion.setImage(width, 1, imageData)
# Move data into next state
for i in range(increment):
position += direction
if position == -1:
position = 1
direction = 1
elif position == width:
position = width-2
direction = -1
# Fade the old data
for j in range(width):
imageData[3*j] = int(fadeFactor * imageData[3*j])
imageData[3*j+1] = int(fadeFactor * imageData[3*j+1])
imageData[3*j+2] = int(fadeFactor * imageData[3*j+2])
# Insert new data
imageData[3*position]
imageData[3*position+1]
imageData[3*position+2]
# Sleep for a while
time.sleep(sleepTime)
Alles anzeigen