forked from osresearch/LEDscape
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-test
More file actions
Latest commit
executable file
·51 lines (41 loc) · 1.29 KB
/
Copy pathpython-test
File metadata and controls
executable file
·51 lines (41 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
# Draw images with PIL and send them to the display.
# Dual scrolling example with fixed time on each side and
# the date scrolling around.
#
importImage, ImageFont, ImageDraw
importsocket
importtime, datetime
fromcolorsysimporthsv_to_rgb
sock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dest= ("localhost", 9999)
#print im.format, im.size, im.mode
# use a truetype font
font=ImageFont.truetype("spincycle.ttf", 18)
font_sm=ImageFont.truetype("pf_tempesta_seven.ttf", 8)
i=0
width=256
disp=Image.new("RGB", (256,16), "black")
im=Image.new("RGB", (width,16), "black")
im_draw=ImageDraw.Draw(im)
disp_draw=ImageDraw.Draw(disp)
defrainbow(i):
rgb= [int(x*256) forxinhsv_to_rgb(i/256.0,0.8,0.8)]
return (rgb[0],rgb[1],rgb[2])
whileTrue:
im.paste("black", (0,0,width,16))
now=datetime.datetime.now()
d=now.strftime("%a %d %b %Y")
t=now.strftime("%H:%M")
# Draw the date
im_draw.text((0, -2), d, font=font, fill=rainbow(i))
# Make it scroll
disp.paste(im.crop((0,0,i,16)), (256-i,0))
disp.paste(im.crop((i+1,0,255,16)), (0,0))
# draw the time on each face
forxinrange(0,7):
disp_draw.text((4+x*32, 8-3), t, font=font_sm)
# Send it to the drawing server
sock.sendto(chr(1) +disp.tostring(), dest)
i= (i+1) %width
time.sleep(0.025)