5 more effects

Former-commit-id: e6a826299a
This commit is contained in:
jm-github 2014-10-30 16:02:30 +00:00
parent d1f043f233
commit fb8c10876b
10 changed files with 195 additions and 0 deletions

7
effects/loop.json Normal file
View File

@ -0,0 +1,7 @@
{
"name" : "Loop",
"script" : "loop.py",
"args" :
{
}
}

34
effects/loop.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 = 0.002
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":0},
{ "i":1, "pos":0, "c":0, "step":5 , "lvl":0},
{ "i":2, "pos":0, "c":0, "step":4, "lvl":0},
]
# 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)

7
effects/loop2.json Normal file
View File

@ -0,0 +1,7 @@
{
"name" : "Loop2",
"script" : "loop2.py",
"args" :
{
}
}

33
effects/loop2.py Normal file
View File

@ -0,0 +1,33 @@
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)

7
effects/random.json Normal file
View File

@ -0,0 +1,7 @@
{
"name" : "Random",
"script" : "random.py",
"args" :
{
}
}

25
effects/random.py Normal file
View File

@ -0,0 +1,25 @@
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.001
# Start the write data loop
while not hyperion.abort():
hyperion.setColor(ledData)
for i in range(hyperion.ledCount):
if random.randrange(10) == 1:
hue = random.random()
sat = 1.0
val = random.random()
rgb = colorsys.hsv_to_rgb(hue, sat, val)
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)

View File

@ -0,0 +1,7 @@
{
"name" : "Sparks color",
"script" : "sparks-color.py",
"args" :
{
}
}

35
effects/sparks-color.py Normal file
View File

@ -0,0 +1,35 @@
import hyperion
import time
import colorsys
import random
# Get the parameters
rotationTime = float(hyperion.args.get('rotation-time', 3.0))
brightness = float(hyperion.args.get('brightness', 1.0))
saturation = float(hyperion.args.get('saturation', 1.0))
reverse = bool(hyperion.args.get('reverse', 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()
sleepTime = 0.05
# 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:
hue = random.random()
sat = 1
val = 1
rgb = colorsys.hsv_to_rgb(hue, sat, val)
ledData[i*3] = int(255*rgb[0])
ledData[i*3+1] = int(255*rgb[1])
ledData[i*3+2] = int(255*rgb[2])
hyperion.setColor(ledData)
time.sleep(sleepTime)

7
effects/sparks.json Normal file
View File

@ -0,0 +1,7 @@
{
"name" : "Sparks",
"script" : "sparks.py",
"args" :
{
}
}

33
effects/sparks.py Normal file
View File

@ -0,0 +1,33 @@
import hyperion
import time
import colorsys
import random
# Get the parameters
rotationTime = float(hyperion.args.get('rotation-time', 3.0))
brightness = float(hyperion.args.get('brightness', 1.0))
saturation = float(hyperion.args.get('saturation', 1.0))
reverse = bool(hyperion.args.get('reverse', 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))
sleepTime = 0.05
# 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:
ledData[i*3] = 255
ledData[i*3+1] = 255
ledData[i*3+2] = 255
hyperion.setColor(ledData)
time.sleep(sleepTime)