2016-01-20 22:36:21 +01:00
|
|
|
import hyperion, time, colorsys, random
|
2014-10-30 17:02:30 +01:00
|
|
|
|
|
|
|
# Get the parameters
|
|
|
|
rotationTime = float(hyperion.args.get('rotation-time', 3.0))
|
2016-01-20 22:36:21 +01:00
|
|
|
sleepTime = float(hyperion.args.get('sleep-time', 0.05))
|
2017-01-04 10:55:10 +01:00
|
|
|
brightness = float(hyperion.args.get('brightness', 100))/100.0
|
|
|
|
saturation = float(hyperion.args.get('saturation', 100))/100.0
|
2016-01-20 22:36:21 +01:00
|
|
|
color = list(hyperion.args.get('color', (255,255,255)))
|
|
|
|
randomColor = bool(hyperion.args.get('random-color', False))
|
2014-10-30 17:02:30 +01:00
|
|
|
|
|
|
|
# Check parameters
|
|
|
|
rotationTime = max(0.1, rotationTime)
|
|
|
|
|
|
|
|
# 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:
|
2016-01-20 22:36:21 +01:00
|
|
|
|
|
|
|
if randomColor:
|
2017-05-01 13:39:21 +02:00
|
|
|
rgb = colorsys.hsv_to_rgb(random.random(), saturation, brightness)
|
2016-01-20 22:36:21 +01:00
|
|
|
for n in range(3):
|
|
|
|
color[n] = int(rgb[n]*255)
|
|
|
|
|
|
|
|
for n in range(3):
|
|
|
|
ledData[i*3+n] = color[n]
|
|
|
|
|
2014-10-30 17:02:30 +01:00
|
|
|
hyperion.setColor(ledData)
|
|
|
|
time.sleep(sleepTime)
|