modify effects

- snake has a nice tail
- random is not so fast anymore
- merge sparks and sparks-color
- make more params available in json files


Former-commit-id: fc2a4f6f6c
This commit is contained in:
redpanther 2016-01-20 22:36:21 +01:00
parent 7dfe8ae8cf
commit de5b284975
8 changed files with 50 additions and 69 deletions

View File

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

View File

@ -1,24 +1,20 @@
import hyperion
import time
import colorsys
import random
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
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)
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])

View File

@ -1,10 +1,10 @@
{
"name" : "Snake",
"name" : "Snake",
"script" : "snake.py",
"args" :
{
"rotation-time" : 10.0,
"color" : [255, 0, 0],
"percentage" : 25
"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

View File

@ -1,7 +1,14 @@
{
"name" : "Sparks color",
"script" : "sparks-color.py",
"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
}
}

View File

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

View File

@ -3,5 +3,12 @@
"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
}
}

View File

@ -1,33 +1,37 @@
import hyperion
import time
import colorsys
import random
import hyperion, time, colorsys, 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))
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))
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
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)