Skip to content

Commit

Permalink
Scrolling time display works.
Browse files Browse the repository at this point in the history
  • Loading branch information
osresearch committed Sep 15, 2013
1 parent a96e40a commit 90d571c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions python-test
Original file line number Original file line Diff line number Diff line change
@@ -1,15 +1,33 @@
#!/usr/bin/python #!/usr/bin/python
# Draw images with PIL and send them to the display. # Draw images with PIL and send them to the display.
# #
import Image import Image, ImageFont, ImageDraw
import socket import socket
import time, datetime


sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dest = ("localhost", 9999) dest = ("localhost", 9999)


#im = Image.new("RGB", (256,16), "black") logo = Image.open("futurecrew.png")
im = Image.open("futurecrew.png") #print im.format, im.size, im.mode
print im.format, im.size, im.mode # use a truetype font
font = ImageFont.truetype("spincycle.ttf", 24)


sock.sendto(chr(1) + im.convert("RGB").tostring(), dest) i = 0
width = 256
disp = Image.new("RGB", (256,16), "black")
im = Image.new("RGB", (width,16), "black")
draw = ImageDraw.Draw(im)


while True:
im.paste("black", (0,0,width,16))
t = datetime.datetime.now().strftime("%a %d %b %H:%M:%S")
draw.text((0, -4), t, font=font)

disp.paste(im.crop((0,0,i,16)), (256-i,0))
disp.paste(im.crop((i+1,0,255,16)), (0,0))

# Slice a 256 size image from the large image
sock.sendto(chr(1) + disp.tostring(), dest)
i = (i+1) % width
time.sleep(0.025)
Binary file added spincycle.ttf
Binary file not shown.

0 comments on commit 90d571c

Please sign in to comment.