Merge pull request #520 from redPanther/master

effects rework and new effects

Former-commit-id: f5bd9db54fd5adfe2e9a8c7b65e31ba14c529707
This commit is contained in:
brindosch 2016-03-08 15:49:50 +01:00
commit b41dfff0da
25 changed files with 395 additions and 104 deletions

View 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 ]
}
}

View 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 ]
}
}

27
effects/fade.py Normal file
View File

@ -0,0 +1,27 @@
import hyperion, time
# 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
calcChannel = lambda i: min(max(int(colorStart[i] + color_step[i]*step),0),255)
for step in range(256):
if hyperion.abort():
break
hyperion.setColor( calcChannel(0),calcChannel(1),calcChannel(2) )
time.sleep( fadeTime / 256 )
# maintain color until effect end
hyperion.setColor(colorEnd[0],colorEnd[1],colorEnd[2])
while not hyperion.abort():
time.sleep(1)

View File

@ -1,10 +1,10 @@
{
"name" : "Knight rider",
"script" : "knight-rider.py",
"args" :
{
"speed" : 1.0,
"fadeFactor" : 0.7,
"color" : [255,0,0]
}
}
{
"name" : "Knight rider",
"script" : "knight-rider.py",
"args" :
{
"speed" : 1.0,
"fadeFactor" : 0.7,
"color" : [255,0,0]
}
}

View File

@ -1,12 +1,12 @@
{
"name" : "Blue mood blobs",
"script" : "mood-blobs.py",
"args" :
{
"rotationTime" : 60.0,
"color" : [0,0,255],
"hueChange" : 60.0,
"blobs" : 5,
"reverse" : false
}
}
{
"name" : "Blue mood blobs",
"script" : "mood-blobs.py",
"args" :
{
"rotationTime" : 60.0,
"color" : [0,0,255],
"hueChange" : 60.0,
"blobs" : 5,
"reverse" : false
}
}

View File

@ -1,12 +1,12 @@
{
"name" : "Green mood blobs",
"script" : "mood-blobs.py",
"args" :
{
"rotationTime" : 60.0,
"color" : [0,255,0],
"hueChange" : 60.0,
"blobs" : 5,
"reverse" : false
}
}
{
"name" : "Green mood blobs",
"script" : "mood-blobs.py",
"args" :
{
"rotationTime" : 60.0,
"color" : [0,255,0],
"hueChange" : 60.0,
"blobs" : 5,
"reverse" : false
}
}

View File

@ -1,12 +1,12 @@
{
"name" : "Red mood blobs",
"script" : "mood-blobs.py",
"args" :
{
"rotationTime" : 60.0,
"color" : [255,0,0],
"hueChange" : 60.0,
"blobs" : 5,
"reverse" : false
}
}
{
"name" : "Red mood blobs",
"script" : "mood-blobs.py",
"args" :
{
"rotationTime" : 60.0,
"color" : [255,0,0],
"hueChange" : 60.0,
"blobs" : 5,
"reverse" : false
}
}

View File

@ -1,10 +1,10 @@
{
"name" : "Rainbow mood",
"script" : "rainbow-mood.py",
"args" :
{
"rotation-time" : 60.0,
"brightness" : 1.0,
"reverse" : false
}
}
{
"name" : "Rainbow mood",
"script" : "rainbow-mood.py",
"args" :
{
"rotation-time" : 60.0,
"brightness" : 1.0,
"reverse" : false
}
}

View File

@ -1,10 +1,10 @@
{
"name" : "Rainbow swirl fast",
"script" : "rainbow-swirl.py",
"args" :
{
"rotation-time" : 3.0,
"brightness" : 1.0,
"reverse" : false
}
}
{
"name" : "Rainbow swirl fast",
"script" : "rainbow-swirl.py",
"args" :
{
"rotation-time" : 3.0,
"brightness" : 1.0,
"reverse" : false
}
}

View File

@ -1,10 +1,10 @@
{
"name" : "Rainbow swirl",
"script" : "rainbow-swirl.py",
"args" :
{
"rotation-time" : 20.0,
"brightness" : 1.0,
"reverse" : false
}
}
{
"name" : "Rainbow swirl",
"script" : "rainbow-swirl.py",
"args" :
{
"rotation-time" : 20.0,
"brightness" : 1.0,
"reverse" : false
}
}

9
effects/random.json Normal file
View File

@ -0,0 +1,9 @@
{
"name" : "Random",
"script" : "random.py",
"args" :
{
"speed" : 1.0,
"saturation" : 1.0
}
}

21
effects/random.py Normal file
View File

@ -0,0 +1,21 @@
import hyperion, time, colorsys, random
# get args
sleepTime = float(hyperion.args.get('speed', 1.0))
saturation = float(hyperion.args.get('saturation', 1.0))
ledData = bytearray()
# Initialize the led data
for i in range(hyperion.ledCount):
ledData += bytearray((0,0,0))
# Start the write data loop
while not hyperion.abort():
hyperion.setColor(ledData)
for i in range(hyperion.ledCount):
if random.randrange(10) == 1:
rgb = colorsys.hsv_to_rgb(random.random(), saturation, random.random())
ledData[i*3 ] = int(255*rgb[0])
ledData[i*3+1] = int(255*rgb[1])
ledData[i*3+2] = int(255*rgb[2])
time.sleep(sleepTime)

10
effects/running_dots.json Normal file
View 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
View 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)

11
effects/shutdown.json Normal file
View File

@ -0,0 +1,11 @@
{
"name" : "System Shutdown",
"script" : "shutdown.py",
"args" :
{
"speed" : 1.2,
"alarm-color" : [255,0,0],
"post-color" : [255,174,11],
"shutdown-enabled" : false
}
}

49
effects/shutdown.py Normal file
View File

@ -0,0 +1,49 @@
import hyperion, time, subprocess
def setPixel(x,y,rgb):
global imageData, width
offset = y*width*3 + x*3
if offset+2 < len(imageData):
imageData[offset] = rgb[0]
imageData[offset+1] = rgb[1]
imageData[offset+2] = rgb[2]
# Initialize the led data and args
sleepTime = float(hyperion.args.get('speed', 1.0))*0.5
alarmColor = hyperion.args.get('alarm-color', (255,0,0))
postColor = hyperion.args.get('post-color', (255,174,11))
off = bool(hyperion.args.get('shutdown-enabled', False))
width = 12
height = 10
imageData = bytearray(height * width * (0,0,0))
# Start the write data loop
for i in range(6):
if hyperion.abort():
off = False
break
if i % 2:
hyperion.setColor(alarmColor[0], alarmColor[1], alarmColor[2])
else:
hyperion.setColor(0, 0, 0)
time.sleep(sleepTime)
for y in range(height,0,-1):
if hyperion.abort():
off = False
break
for x in range(width):
setPixel(x, y-1, alarmColor)
hyperion.setImage(width, height, imageData)
time.sleep(sleepTime)
time.sleep(1)
for y in range(height):
for x in range(width):
setPixel(x, y, postColor)
hyperion.setImage(width, height, imageData)
time.sleep(2)
if off and not hyperion.abort():
subprocess.call("halt")

View File

@ -1,10 +1,10 @@
{
"name" : "Snake",
"script" : "snake.py",
"args" :
{
"rotation-time" : 10.0,
"color" : [255, 0, 0],
"percentage" : 25
}
}
{
"name" : "Snake",
"script" : "snake.py",
"args" :
{
"rotation-time" : 12.0,
"color" : [255, 0, 0],
"percentage" : 10
}
}

View File

@ -23,7 +23,7 @@ for i in range(hyperion.ledCount-snakeLeds):
ledData += bytearray((0, 0, 0))
for i in range(1,snakeLeds+1):
rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1], hsv[2]/i)
rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1], hsv[2]*(snakeLeds-i)/snakeLeds)
ledData += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255)))
# Calculate the sleep time and rotation increment

14
effects/sparks-color.json Normal file
View File

@ -0,0 +1,14 @@
{
"name" : "Sparks Color",
"script" : "sparks.py",
"args" :
{
"rotation-time" : 3.0,
"sleep-time" : 0.05,
"brightness" : 1.0,
"saturation" : 1.0,
"reverse" : false,
"color" : [255,255,255],
"random-color" : true
}
}

14
effects/sparks.json Normal file
View File

@ -0,0 +1,14 @@
{
"name" : "Sparks",
"script" : "sparks.py",
"args" :
{
"rotation-time" : 3.0,
"sleep-time" : 0.05,
"brightness" : 1.0,
"saturation" : 1.0,
"reverse" : false,
"color" : [255,255,255],
"random-color" : false
}
}

37
effects/sparks.py Normal file
View File

@ -0,0 +1,37 @@
import hyperion, time, colorsys, random
# Get the parameters
rotationTime = float(hyperion.args.get('rotation-time', 3.0))
sleepTime = float(hyperion.args.get('sleep-time', 0.05))
brightness = float(hyperion.args.get('brightness', 1.0))
saturation = float(hyperion.args.get('saturation', 1.0))
reverse = bool(hyperion.args.get('reverse', False))
color = list(hyperion.args.get('color', (255,255,255)))
randomColor = bool(hyperion.args.get('random-color', False))
# Check parameters
rotationTime = max(0.1, rotationTime)
brightness = max(0.0, min(brightness, 1.0))
saturation = max(0.0, min(saturation, 1.0))
# Initialize the led data
ledData = bytearray()
for i in range(hyperion.ledCount):
ledData += bytearray((0, 0, 0))
# Start the write data loop
while not hyperion.abort():
ledData[:] = bytearray(3*hyperion.ledCount)
for i in range(hyperion.ledCount):
if random.random() < 0.005:
if randomColor:
rgb = colorsys.hsv_to_rgb(random.random(), 1, 1)
for n in range(3):
color[n] = int(rgb[n]*255)
for n in range(3):
ledData[i*3+n] = color[n]
hyperion.setColor(ledData)
time.sleep(sleepTime)

View File

@ -1,6 +1,4 @@
import hyperion
import time
import colorsys
import hyperion, time
# Get the rotation time
color = hyperion.args.get('color', (255,255,255))
@ -12,13 +10,9 @@ frequency = min(100.0, frequency)
# Compute the strobe interval
sleepTime = 1.0 / frequency
# Initialize the led data
blackLedsData = bytearray(hyperion.ledCount * ( 0, 0, 0))
whiteLedsData = bytearray(hyperion.ledCount * color)
# Start the write data loop
while not hyperion.abort():
hyperion.setColor(blackLedsData)
hyperion.setColor(0, 0, 0)
time.sleep(sleepTime)
hyperion.setColor(whiteLedsData)
hyperion.setColor(color[0], color[1], color[2])
time.sleep(sleepTime)

8
effects/traces.json Normal file
View File

@ -0,0 +1,8 @@
{
"name" : "Color traces",
"script" : "traces.py",
"args" :
{
"speed" : 1.0
}
}

34
effects/traces.py Normal file
View File

@ -0,0 +1,34 @@
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 = float(hyperion.args.get('speed', 1.0)) * 0.004
runners = [
{ "i":0, "pos":0, "c":0, "step":9 , "lvl":255},
{ "i":1, "pos":0, "c":0, "step":8 , "lvl":255},
{ "i":2, "pos":0, "c":0, "step":7 , "lvl":255},
{ "i":0, "pos":0, "c":0, "step":6 , "lvl":100},
{ "i":1, "pos":0, "c":0, "step":5 , "lvl":100},
{ "i":2, "pos":0, "c":0, "step":4, "lvl":100},
]
# Start the write data loop
while not hyperion.abort():
for r in runners:
if r["c"] == 0:
#ledData[r["pos"]*3+r["i"]] = 0
r["c"] = r["step"]
r["pos"] = (r["pos"]+1)%hyperion.ledCount
ledData[r["pos"]*3+r["i"]] = int(r["lvl"]*(0.2+0.8*random.random()))
else:
r["c"] -= 1
hyperion.setColor(ledData)
time.sleep(sleepTime)

View File

@ -1,8 +1,8 @@
{
"name" : "X-Mas",
"script" : "x-mas.py",
"args" :
{
"sleepTime" : 0.75
}
}
{
"name" : "X-Mas",
"script" : "x-mas.py",
"args" :
{
"sleepTime" : 0.75
}
}