mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
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: fc2a4f6f6ce2b44a35a75a9c0dbe36504b790be9
This commit is contained in:
parent
7dfe8ae8cf
commit
de5b284975
@ -3,5 +3,7 @@
|
|||||||
"script" : "random.py",
|
"script" : "random.py",
|
||||||
"args" :
|
"args" :
|
||||||
{
|
{
|
||||||
|
"speed" : 1.0,
|
||||||
|
"saturation" : 1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,20 @@
|
|||||||
import hyperion
|
import hyperion, time, colorsys, random
|
||||||
import time
|
|
||||||
import colorsys
|
# get args
|
||||||
import random
|
sleepTime = float(hyperion.args.get('speed', 1.0))
|
||||||
|
saturation = float(hyperion.args.get('saturation', 1.0))
|
||||||
|
ledData = bytearray()
|
||||||
|
|
||||||
# Initialize the led data
|
# Initialize the led data
|
||||||
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.001
|
|
||||||
|
|
||||||
# Start the write data loop
|
# Start the write data loop
|
||||||
while not hyperion.abort():
|
while not hyperion.abort():
|
||||||
hyperion.setColor(ledData)
|
hyperion.setColor(ledData)
|
||||||
for i in range(hyperion.ledCount):
|
for i in range(hyperion.ledCount):
|
||||||
if random.randrange(10) == 1:
|
if random.randrange(10) == 1:
|
||||||
hue = random.random()
|
rgb = colorsys.hsv_to_rgb(random.random(), saturation, 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 ] = int(255*rgb[0])
|
||||||
ledData[i*3+1] = int(255*rgb[1])
|
ledData[i*3+1] = int(255*rgb[1])
|
||||||
ledData[i*3+2] = int(255*rgb[2])
|
ledData[i*3+2] = int(255*rgb[2])
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
"script" : "snake.py",
|
"script" : "snake.py",
|
||||||
"args" :
|
"args" :
|
||||||
{
|
{
|
||||||
"rotation-time" : 10.0,
|
"rotation-time" : 12.0,
|
||||||
"color" : [255, 0, 0],
|
"color" : [255, 0, 0],
|
||||||
"percentage" : 25
|
"percentage" : 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ for i in range(hyperion.ledCount-snakeLeds):
|
|||||||
ledData += bytearray((0, 0, 0))
|
ledData += bytearray((0, 0, 0))
|
||||||
|
|
||||||
for i in range(1,snakeLeds+1):
|
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)))
|
ledData += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255)))
|
||||||
|
|
||||||
# Calculate the sleep time and rotation increment
|
# Calculate the sleep time and rotation increment
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name" : "Sparks color",
|
"name" : "Sparks Color",
|
||||||
"script" : "sparks-color.py",
|
"script" : "sparks.py",
|
||||||
"args" :
|
"args" :
|
||||||
{
|
{
|
||||||
|
"rotation-time" : 3.0,
|
||||||
|
"sleep-time" : 0.05,
|
||||||
|
"brightness" : 1.0,
|
||||||
|
"saturation" : 1.0,
|
||||||
|
"reverse" : false,
|
||||||
|
"color" : [255,255,255],
|
||||||
|
"random-color" : true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
|
@ -3,5 +3,12 @@
|
|||||||
"script" : "sparks.py",
|
"script" : "sparks.py",
|
||||||
"args" :
|
"args" :
|
||||||
{
|
{
|
||||||
|
"rotation-time" : 3.0,
|
||||||
|
"sleep-time" : 0.05,
|
||||||
|
"brightness" : 1.0,
|
||||||
|
"saturation" : 1.0,
|
||||||
|
"reverse" : false,
|
||||||
|
"color" : [255,255,255],
|
||||||
|
"random-color" : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import hyperion
|
import hyperion, time, colorsys, random
|
||||||
import time
|
|
||||||
import colorsys
|
|
||||||
import random
|
|
||||||
|
|
||||||
# Get the parameters
|
# Get the parameters
|
||||||
rotationTime = float(hyperion.args.get('rotation-time', 3.0))
|
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))
|
brightness = float(hyperion.args.get('brightness', 1.0))
|
||||||
saturation = float(hyperion.args.get('saturation', 1.0))
|
saturation = float(hyperion.args.get('saturation', 1.0))
|
||||||
reverse = bool(hyperion.args.get('reverse', False))
|
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
|
# Check parameters
|
||||||
rotationTime = max(0.1, rotationTime)
|
rotationTime = max(0.1, rotationTime)
|
||||||
@ -19,15 +19,19 @@ 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.05
|
|
||||||
|
|
||||||
# Start the write data loop
|
# Start the write data loop
|
||||||
while not hyperion.abort():
|
while not hyperion.abort():
|
||||||
ledData[:] = bytearray(3*hyperion.ledCount)
|
ledData[:] = bytearray(3*hyperion.ledCount)
|
||||||
for i in range(hyperion.ledCount):
|
for i in range(hyperion.ledCount):
|
||||||
if random.random() < 0.005:
|
if random.random() < 0.005:
|
||||||
ledData[i*3] = 255
|
|
||||||
ledData[i*3+1] = 255
|
if randomColor:
|
||||||
ledData[i*3+2] = 255
|
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)
|
hyperion.setColor(ledData)
|
||||||
time.sleep(sleepTime)
|
time.sleep(sleepTime)
|
||||||
|
Loading…
Reference in New Issue
Block a user