mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
add color parameter to the knight rider effect
Former-commit-id: 9d4cd0e18b7871acd76a9cafb04efc39ce6fac74
This commit is contained in:
parent
d102ffd043
commit
6d6f4bf629
@ -4,6 +4,7 @@
|
||||
"args" :
|
||||
{
|
||||
"speed" : 1.0,
|
||||
"fadeFactor" : 0.7
|
||||
"fadeFactor" : 0.7,
|
||||
"color" : [255,0,0]
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ import hyperion
|
||||
import time
|
||||
import colorsys
|
||||
|
||||
# Get the rotation time
|
||||
# Get the parameters
|
||||
speed = float(hyperion.args.get('speed', 1.0))
|
||||
fadeFactor = float(hyperion.args.get('fadeFactor', 0.7))
|
||||
color = hyperion.args.get('color', (255,0,0))
|
||||
|
||||
# Check parameters
|
||||
speed = max(0.0001, speed)
|
||||
@ -13,7 +14,9 @@ fadeFactor = max(0.0, min(fadeFactor, 1.0))
|
||||
# Initialize the led data
|
||||
width = 25
|
||||
imageData = bytearray(width * (0,0,0))
|
||||
imageData[0] = 255
|
||||
imageData[0] = color[0]
|
||||
imageData[1] = color[1]
|
||||
imageData[2] = color[2]
|
||||
|
||||
# Calculate the sleep time and rotation increment
|
||||
increment = 1
|
||||
@ -41,9 +44,13 @@ while not hyperion.abort():
|
||||
# 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] = 255
|
||||
imageData[3*position] = color[0]
|
||||
imageData[3*position+1] = color[1]
|
||||
imageData[3*position+2] = color[2]
|
||||
|
||||
# Sleep for a while
|
||||
time.sleep(sleepTime)
|
||||
|
Loading…
Reference in New Issue
Block a user