hyperion.ng/effects/sparks.py
redpanther de5b284975 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
2016-01-20 22:36:21 +01:00

38 lines
1.1 KiB
Python

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)