2017-04-09 22:28:32 +02:00
|
|
|
import hyperion, time, math
|
2013-11-30 17:42:57 +01:00
|
|
|
|
2017-04-14 07:58:34 +02:00
|
|
|
# set minimum image size - must be done asap
|
|
|
|
hyperion.imageMinSize(32,32)
|
|
|
|
|
2013-11-30 17:46:07 +01:00
|
|
|
# Get the parameters
|
2013-12-08 16:23:01 +01:00
|
|
|
rotationTime = float(hyperion.args.get('rotation-time', 3.0))
|
2016-09-21 22:01:50 +02:00
|
|
|
reverse = bool(hyperion.args.get('reverse', False))
|
|
|
|
centerX = float(hyperion.args.get('center_x', 0.5))
|
|
|
|
centerY = float(hyperion.args.get('center_y', 0.5))
|
2013-11-30 17:42:57 +01:00
|
|
|
|
2017-04-09 22:28:32 +02:00
|
|
|
minStepTime = float(hyperion.latchTime)/1000.0
|
2016-09-21 22:01:50 +02:00
|
|
|
sleepTime = max(0.1, rotationTime) / 360
|
|
|
|
angle = 0
|
2017-04-14 07:58:34 +02:00
|
|
|
centerX = int(round(float(hyperion.imageWidth())*centerX))
|
|
|
|
centerY = int(round(float(hyperion.imageHeight())*centerY))
|
2016-09-21 22:01:50 +02:00
|
|
|
increment = -1 if reverse else 1
|
2013-12-01 15:22:51 +01:00
|
|
|
|
2017-04-09 22:28:32 +02:00
|
|
|
# adapt sleeptime to hardware
|
|
|
|
if minStepTime > sleepTime:
|
|
|
|
increment *= int(math.ceil(minStepTime / sleepTime))
|
|
|
|
sleepTime = minStepTime
|
|
|
|
|
2016-09-21 22:01:50 +02:00
|
|
|
# table of stop colors for rainbow gradient, first is the position, next rgb, all values 0-255
|
|
|
|
rainbowColors = bytearray([
|
2016-10-01 21:34:30 +02:00
|
|
|
0 ,255,0 ,0, 255,
|
|
|
|
25 ,255,230,0, 255,
|
|
|
|
63 ,255,255,0, 255,
|
|
|
|
100,0 ,255,0, 255,
|
|
|
|
127,0 ,255,200, 255,
|
|
|
|
159,0 ,255,255, 255,
|
|
|
|
191,0 ,0 ,255, 255,
|
|
|
|
224,255,0 ,255, 255,
|
|
|
|
255,255,0 ,127, 255,
|
|
|
|
#0, 255, 0, 0, 255,
|
|
|
|
#42, 255, 255, 0, 255,
|
|
|
|
#85, 0, 255, 0, 255,
|
|
|
|
#128, 0, 255, 255, 255,
|
|
|
|
#170, 0, 0, 255, 255,
|
|
|
|
#212, 255, 0, 255, 255,
|
|
|
|
#255, 255, 0, 0, 255,
|
2016-09-21 22:01:50 +02:00
|
|
|
])
|
2013-11-30 17:42:57 +01:00
|
|
|
|
2016-09-21 22:01:50 +02:00
|
|
|
# effect loop
|
2013-11-30 17:42:57 +01:00
|
|
|
while not hyperion.abort():
|
2016-09-21 22:01:50 +02:00
|
|
|
angle += increment
|
|
|
|
if angle > 360: angle=0
|
|
|
|
if angle < 0: angle=360
|
|
|
|
|
|
|
|
hyperion.imageCanonicalGradient(centerX, centerY, angle, rainbowColors)
|
|
|
|
|
|
|
|
hyperion.imageShow()
|
2013-11-30 17:42:57 +01:00
|
|
|
time.sleep(sleepTime)
|