This commit is contained in:
brindosch 2017-04-17 14:26:35 +02:00
parent 89347b118c
commit a5b40a7ea8

View File

@ -1,35 +1,45 @@
import hyperion, time, datetime
hyperion.imageMinSize(32,32)
# Get the parameters
showSeconds = bool(hyperion.args.get('show_seconds', True))
centerX = int(round(hyperion.imageWidth())/2)
centerY = int(round(float(hyperion.imageHeight())/2))
showSec = bool(hyperion.args.get('show_seconds', True))
hC = hyperion.args.get('hour-color', (0,0,255))
mC = hyperion.args.get('minute-color', (0,255,0))
sC = hyperion.args.get('second-color', (255,0,0))
bgC = hyperion.args.get('background-color', (0,0,0))
markD = int(hyperion.args.get('marker-depth', 5))/100.0
markW = int(hyperion.args.get('marker-width', 5))/100.0
markC = hyperion.args.get('marker-color', (255,255,255))
#calculate some stuff
centerX = int(round(hyperion.imageWidth())/2)
centerY = int(round(float(hyperion.imageHeight())/2))
markDepthX = int(round(hyperion.imageWidth()*markD))
markDepthY = int(round(hyperion.imageHeight()*markD))
markThick = int(round(hyperion.imageHeight()*markW))
colorsSecond = bytearray([
0, 255,255,0,255,
5, 255,255,0,255,
30, 0,0,0,0,
0, sC[0],sC[1],sC[2],255,
8, sC[0],sC[1],sC[2],255,
10, 0,0,0,0,
])
colorsMinute = bytearray([
0, 0,255,0,255,
5, 0,255,0,250,
0, mC[0],mC[1],mC[2],255,
35, mC[0],mC[1],mC[2],255,
50, mC[0],mC[1],mC[2],127,
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,
0, hC[0],hC[1],hC[2],255,
90, hC[0],hC[1],hC[2],255,
150, hC[0],hC[1],hC[2],127,
191, 0,0,0,0,
])
colorsHourTop = bytearray([
0, 0,0,255,250,
10, 0,0,255,128,
20, 0,0,0,0,
])
# effect loop
while not hyperion.abort():
@ -38,17 +48,30 @@ while not hyperion.abort():
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:
#reset image
hyperion.imageSolidFill(bgC[0],bgC[1],bgC[2])
#paint clock
if angleH-angleM < 90 and angleH-angleM > 0:
hyperion.imageCanonicalGradient(centerX, centerY, angleM, colorsMinute)
hyperion.imageCanonicalGradient(centerX, centerY, angleH, colorsHour)
else:
hyperion.imageCanonicalGradient(centerX, centerY, angleH, colorsHour)
hyperion.imageCanonicalGradient(centerX, centerY, angleM, colorsMinute)
if showSec:
hyperion.imageCanonicalGradient(centerX, centerY, angleS, colorsSecond)
if markD > 0.0:
#marker left, right, top, bottom
hyperion.imageDrawLine(0, centerY, 0+markDepthX, centerY, markThick, markC[0], markC[1], markC[2])
hyperion.imageDrawLine(int(hyperion.imageWidth()), centerY, int(hyperion.imageWidth())-markDepthX, centerY, markThick, markC[0], markC[1], markC[2])
hyperion.imageDrawLine(centerX, 0, centerX, 0+markDepthY, markThick, markC[0], markC[1], markC[2])
hyperion.imageDrawLine(centerX, int(hyperion.imageHeight()), centerX, int(hyperion.imageHeight())-markDepthY, markThick, markC[0], markC[1], markC[2])
hyperion.imageShow()
time.sleep(0.5 )
time.sleep(1)