mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
add fading effect like in a cinema. sped start and end color are selectable in json file
rename loop effects to more meaningfull names Former-commit-id: bed033e19d7cb38b0d5f11313a9f927ac8121194
This commit is contained in:
parent
2555c50710
commit
e7c7e05f88
10
effects/cinema-fade-in.json
Normal file
10
effects/cinema-fade-in.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name" : "Cinema brighten lights",
|
||||||
|
"script" : "fade.py",
|
||||||
|
"args" :
|
||||||
|
{
|
||||||
|
"fade-time" : 5.0,
|
||||||
|
"color-start" : [ 136, 97, 7 ],
|
||||||
|
"color-end" : [ 238, 173, 47 ]
|
||||||
|
}
|
||||||
|
}
|
10
effects/cinema-fade-off.json
Normal file
10
effects/cinema-fade-off.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name" : "Cinema dim lights",
|
||||||
|
"script" : "fade.py",
|
||||||
|
"args" :
|
||||||
|
{
|
||||||
|
"fade-time" : 5.0,
|
||||||
|
"color-start" : [ 238, 173, 47 ],
|
||||||
|
"color-end" : [ 136, 97, 7 ]
|
||||||
|
}
|
||||||
|
}
|
34
effects/fade.py
Normal file
34
effects/fade.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import hyperion, time
|
||||||
|
|
||||||
|
def setColor(rgb):
|
||||||
|
hyperion.setColor( bytearray( hyperion.ledCount * rgb))
|
||||||
|
|
||||||
|
# Get the parameters
|
||||||
|
fadeTime = float(hyperion.args.get('fade-time', 5.0))
|
||||||
|
colorStart = hyperion.args.get('color-start', (255,174,11))
|
||||||
|
colorEnd = hyperion.args.get('color-end', (100,100,100))
|
||||||
|
|
||||||
|
color_step = (
|
||||||
|
(colorEnd[0] - colorStart[0]) / 256.0,
|
||||||
|
(colorEnd[1] - colorStart[1]) / 256.0,
|
||||||
|
(colorEnd[2] - colorStart[2]) / 256.0
|
||||||
|
)
|
||||||
|
|
||||||
|
# fade color
|
||||||
|
for step in range(256):
|
||||||
|
if hyperion.abort():
|
||||||
|
break
|
||||||
|
|
||||||
|
setColor( (
|
||||||
|
int( min(max(0, colorStart[0] + color_step[0]*step), 255) ),
|
||||||
|
int( min(max(0, colorStart[1] + color_step[1]*step), 255) ),
|
||||||
|
int( min(max(0, colorStart[2] + color_step[2]*step), 255) )
|
||||||
|
) )
|
||||||
|
|
||||||
|
time.sleep( fadeTime / 256 )
|
||||||
|
|
||||||
|
# maintain color until effect end
|
||||||
|
setColor(colorEnd)
|
||||||
|
while not hyperion.abort():
|
||||||
|
time.sleep(1)
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"name" : "Loop",
|
|
||||||
"script" : "loop.py",
|
|
||||||
"args" :
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"name" : "Loop2",
|
|
||||||
"script" : "loop2.py",
|
|
||||||
"args" :
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
import hyperion
|
|
||||||
import time
|
|
||||||
import colorsys
|
|
||||||
import random
|
|
||||||
|
|
||||||
# Initialize the led data
|
|
||||||
ledData = bytearray()
|
|
||||||
for i in range(hyperion.ledCount):
|
|
||||||
ledData += bytearray((0,0,0))
|
|
||||||
|
|
||||||
sleepTime = 0.005
|
|
||||||
|
|
||||||
runners = [
|
|
||||||
{ "pos":0, "step":4 , "lvl":255},
|
|
||||||
{ "pos":1, "step":5 , "lvl":255},
|
|
||||||
{ "pos":2, "step":6 , "lvl":255},
|
|
||||||
{ "pos":0, "step":7 , "lvl":255},
|
|
||||||
{ "pos":1, "step":8 , "lvl":255},
|
|
||||||
{ "pos":2, "step":9, "lvl":255},
|
|
||||||
]
|
|
||||||
|
|
||||||
# Start the write data loop
|
|
||||||
count = 0
|
|
||||||
while not hyperion.abort():
|
|
||||||
count += 1
|
|
||||||
for r in runners:
|
|
||||||
if count%r["step"] == 0:
|
|
||||||
ledData[r["pos"]] = 0
|
|
||||||
r["pos"] = (r["pos"]+3)%(hyperion.ledCount*3)
|
|
||||||
ledData[r["pos"]] = r["lvl"]
|
|
||||||
|
|
||||||
hyperion.setColor(ledData)
|
|
||||||
time.sleep(sleepTime)
|
|
10
effects/running_dots.json
Normal file
10
effects/running_dots.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name" : "Running dots",
|
||||||
|
"script" : "running_dots.py",
|
||||||
|
"args" :
|
||||||
|
{
|
||||||
|
"speed" : 1.5,
|
||||||
|
"whiteLevel" : 100,
|
||||||
|
"colorLevel" : 230
|
||||||
|
}
|
||||||
|
}
|
43
effects/running_dots.py
Normal file
43
effects/running_dots.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import hyperion, time, colorsys, random
|
||||||
|
|
||||||
|
# get options from args
|
||||||
|
sleepTime = float(hyperion.args.get('speed', 1.5)) * 0.005
|
||||||
|
whiteLevel = int(hyperion.args.get('whiteLevel', 0))
|
||||||
|
lvl = int(hyperion.args.get('colorLevel', 220))
|
||||||
|
|
||||||
|
# check value
|
||||||
|
whiteLevel = min( whiteLevel, 254 )
|
||||||
|
lvl = min( lvl, 255 )
|
||||||
|
|
||||||
|
if whiteLevel >= lvl:
|
||||||
|
lvl = 255
|
||||||
|
|
||||||
|
# Initialize the led data
|
||||||
|
ledData = bytearray()
|
||||||
|
for i in range(hyperion.ledCount):
|
||||||
|
ledData += bytearray((0,0,0))
|
||||||
|
|
||||||
|
runners = [
|
||||||
|
{ "pos":0, "step": 4, "lvl":lvl},
|
||||||
|
{ "pos":1, "step": 5, "lvl":lvl},
|
||||||
|
{ "pos":2, "step": 6, "lvl":lvl},
|
||||||
|
{ "pos":0, "step": 7, "lvl":lvl},
|
||||||
|
{ "pos":1, "step": 8, "lvl":lvl},
|
||||||
|
{ "pos":2, "step": 9, "lvl":lvl},
|
||||||
|
#{ "pos":0, "step":10, "lvl":lvl},
|
||||||
|
#{ "pos":1, "step":11, "lvl":lvl},
|
||||||
|
#{ "pos":2, "step":12, "lvl":lvl},
|
||||||
|
]
|
||||||
|
|
||||||
|
# Start the write data loop
|
||||||
|
counter = 0
|
||||||
|
while not hyperion.abort():
|
||||||
|
counter += 1
|
||||||
|
for r in runners:
|
||||||
|
if counter % r["step"] == 0:
|
||||||
|
ledData[r["pos"]] = whiteLevel
|
||||||
|
r["pos"] = (r["pos"]+3) % (hyperion.ledCount*3)
|
||||||
|
ledData[r["pos"]] = r["lvl"]
|
||||||
|
|
||||||
|
hyperion.setColor(ledData)
|
||||||
|
time.sleep(sleepTime)
|
8
effects/traces.json
Normal file
8
effects/traces.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name" : "Color traces",
|
||||||
|
"script" : "traces.py",
|
||||||
|
"args" :
|
||||||
|
{
|
||||||
|
"speed" : 1.0
|
||||||
|
}
|
||||||
|
}
|
@ -8,15 +8,15 @@ ledData = bytearray()
|
|||||||
for i in range(hyperion.ledCount):
|
for i in range(hyperion.ledCount):
|
||||||
ledData += bytearray((0,0,0))
|
ledData += bytearray((0,0,0))
|
||||||
|
|
||||||
sleepTime = 0.002
|
sleepTime = float(hyperion.args.get('speed', 1.0)) * 0.004
|
||||||
|
|
||||||
runners = [
|
runners = [
|
||||||
{ "i":0, "pos":0, "c":0, "step":9 , "lvl":255},
|
{ "i":0, "pos":0, "c":0, "step":9 , "lvl":255},
|
||||||
{ "i":1, "pos":0, "c":0, "step":8 , "lvl":255},
|
{ "i":1, "pos":0, "c":0, "step":8 , "lvl":255},
|
||||||
{ "i":2, "pos":0, "c":0, "step":7 , "lvl":255},
|
{ "i":2, "pos":0, "c":0, "step":7 , "lvl":255},
|
||||||
{ "i":0, "pos":0, "c":0, "step":6 , "lvl":0},
|
{ "i":0, "pos":0, "c":0, "step":6 , "lvl":100},
|
||||||
{ "i":1, "pos":0, "c":0, "step":5 , "lvl":0},
|
{ "i":1, "pos":0, "c":0, "step":5 , "lvl":100},
|
||||||
{ "i":2, "pos":0, "c":0, "step":4, "lvl":0},
|
{ "i":2, "pos":0, "c":0, "step":4, "lvl":100},
|
||||||
]
|
]
|
||||||
|
|
||||||
# Start the write data loop
|
# Start the write data loop
|
Loading…
Reference in New Issue
Block a user