mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
41 lines
1010 B
Python
41 lines
1010 B
Python
import hyperion
|
|
import time
|
|
import colorsys
|
|
|
|
# Get the rotation time
|
|
rotationTime = hyperion.args.get('rotation-time', 3.0)
|
|
|
|
# Get the brightness
|
|
brightness = hyperion.args.get('brightness', 1.0)
|
|
|
|
# Get the saturation
|
|
saturation = hyperion.args.get('saturation', 1.0)
|
|
|
|
# Get the direction
|
|
reverse = hyperion.args.get('reverse', False)
|
|
|
|
# Initialize the led data
|
|
ledData = bytearray()
|
|
for i in range(hyperion.ledCount):
|
|
hue = float(i)/hyperion.ledCount
|
|
rgb = colorsys.hsv_to_rgb(hue, saturation, brightness)
|
|
ledData += bytearray((int(255*rgb[0]), int(255*rgb[1]), int(255*rgb[2])))
|
|
|
|
# Calculate the sleep time and rotation increment
|
|
increment = 3
|
|
sleepTime = rotationTime / hyperion.ledCount
|
|
while sleepTime < 0.05:
|
|
increment *= 2
|
|
sleepTime *= 2
|
|
increment %= hyperion.ledCount
|
|
|
|
# Switch direction if needed
|
|
if reverse:
|
|
increment = -increment
|
|
|
|
# Start the write data loop
|
|
while not hyperion.abort():
|
|
hyperion.setColor(ledData)
|
|
ledData = ledData[-increment:] + ledData[:-increment]
|
|
time.sleep(sleepTime)
|