light clock (#260)

* extend image effects
add a basic light clock

* add alpha values  to rainbow

* some effect tuning

* make seconds hand optional and change color to yellow
make blue hours hand always visible
This commit is contained in:
redPanther
2016-10-01 21:34:30 +02:00
committed by GitHub
parent 5aa9edc1cd
commit 89afedf3d5
5 changed files with 131 additions and 16 deletions

8
effects/light-clock.json Normal file
View File

@@ -0,0 +1,8 @@
{
"name" : "Light clock",
"script" : "light-clock.py",
"args" :
{
"show_seconds" : true
}
}

54
effects/light-clock.py Normal file
View File

@@ -0,0 +1,54 @@
import hyperion, time, datetime
# Get the parameters
showSeconds = bool(hyperion.args.get('show_seconds', True))
centerX = int(round(hyperion.imageWidth)/2)
centerY = int(round(float(hyperion.imageHeight)/2))
colorsSecond = bytearray([
0, 255,255,0,255,
5, 255,255,0,255,
30, 0,0,0,0,
])
colorsMinute = bytearray([
0, 0,255,0,255,
5, 0,255,0,250,
90, 0,0,0,0,
])
colorsHour = bytearray([
0, 0,0,255,255,
10, 0,0,255,255,
127, 0,0,196,127,
255, 0,0,196,5,
])
colorsHourTop = bytearray([
0, 0,0,255,250,
10, 0,0,255,128,
20, 0,0,0,0,
])
# effect loop
while not hyperion.abort():
now = datetime.datetime.now()
angleH = 449 - 30*(now.hour if now.hour<12 else now.hour-12)
angleM = 449 - 6*now.minute
angleS = 449 - 6*now.second
angleH -= 0 if angleH<360 else 360
angleM -= 0 if angleM<360 else 360
angleS -= 0 if angleS<360 else 360
hyperion.imageSolidFill(127,127,127);
hyperion.imageCanonicalGradient(centerX, centerY, angleH, colorsHour)
hyperion.imageCanonicalGradient(centerX, centerY, angleM, colorsMinute)
hyperion.imageCanonicalGradient(centerX, centerY, angleH, colorsHourTop)
if showSeconds:
hyperion.imageCanonicalGradient(centerX, centerY, angleS, colorsSecond)
hyperion.imageShow()
time.sleep(0.01 )

View File

@@ -14,15 +14,22 @@ increment = -1 if reverse else 1
# table of stop colors for rainbow gradient, first is the position, next rgb, all values 0-255
rainbowColors = bytearray([
0 ,255,0 ,0,
25 ,255,230,0,
63 ,255,255,0,
100,0 ,255,0,
127,0 ,255,200,
159,0 ,255,255,
191,0 ,0 ,255,
224,255,0 ,255,
255,255,0 ,127,
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,
])
# effect loop