Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 515208c

Browse files
committed
Merge pull request #88 from spudwebb/master
add color parameter to the knight rider effect
2 parents ad35436 + 9d4cd0e commit 515208c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

effects/knight-rider.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"args" :
55
{
66
"speed" : 1.0,
7-
"fadeFactor" : 0.7
7+
"fadeFactor" : 0.7,
8+
"color" : [255,0,0]
89
}
910
}

effects/knight-rider.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import time
33
import colorsys
44

5-
# Get the rotation time
5+
# Get the parameters
66
speed = float(hyperion.args.get('speed', 1.0))
77
fadeFactor = float(hyperion.args.get('fadeFactor', 0.7))
8+
color = hyperion.args.get('color', (255,0,0))
89

910
# Check parameters
1011
speed = max(0.0001, speed)
@@ -13,7 +14,9 @@
1314
# Initialize the led data
1415
width = 25
1516
imageData = bytearray(width * (0,0,0))
16-
imageData[0] = 255
17+
imageData[0] = color[0]
18+
imageData[1] = color[1]
19+
imageData[2] = color[2]
1720

1821
# Calculate the sleep time and rotation increment
1922
increment = 1
@@ -41,9 +44,13 @@
4144
# Fade the old data
4245
for j in range(width):
4346
imageData[3*j] = int(fadeFactor * imageData[3*j])
47+
imageData[3*j+1] = int(fadeFactor * imageData[3*j+1])
48+
imageData[3*j+2] = int(fadeFactor * imageData[3*j+2])
4449

4550
# Insert new data
46-
imageData[3*position] = 255
51+
imageData[3*position] = color[0]
52+
imageData[3*position+1] = color[1]
53+
imageData[3*position+2] = color[2]
4754

4855
# Sleep for a while
4956
time.sleep(sleepTime)

0 commit comments

Comments
 (0)