2016-01-24 08:10:36 +01:00
|
|
|
import hyperion, time
|
|
|
|
|
|
|
|
# Get the parameters
|
|
|
|
fadeTime = float(hyperion.args.get('fade-time', 5.0))
|
|
|
|
colorStart = hyperion.args.get('color-start', (255,174,11))
|
|
|
|
colorEnd = hyperion.args.get('color-end', (100,100,100))
|
|
|
|
|
|
|
|
color_step = (
|
|
|
|
(colorEnd[0] - colorStart[0]) / 256.0,
|
|
|
|
(colorEnd[1] - colorStart[1]) / 256.0,
|
|
|
|
(colorEnd[2] - colorStart[2]) / 256.0
|
|
|
|
)
|
|
|
|
|
|
|
|
# fade color
|
2016-01-28 05:50:32 +01:00
|
|
|
calcChannel = lambda i: min(max(int(colorStart[i] + color_step[i]*step),0),255)
|
2016-01-24 08:10:36 +01:00
|
|
|
for step in range(256):
|
|
|
|
if hyperion.abort():
|
|
|
|
break
|
|
|
|
|
2016-01-28 05:50:32 +01:00
|
|
|
hyperion.setColor( calcChannel(0),calcChannel(1),calcChannel(2) )
|
2016-01-24 08:10:36 +01:00
|
|
|
time.sleep( fadeTime / 256 )
|
|
|
|
|
|
|
|
# maintain color until effect end
|
2016-01-28 05:50:32 +01:00
|
|
|
hyperion.setColor(colorEnd[0],colorEnd[1],colorEnd[2])
|
2016-01-24 08:10:36 +01:00
|
|
|
while not hyperion.abort():
|
|
|
|
time.sleep(1)
|
|
|
|
|