diff options
author | rcoh <rcoh@mit.edu> | 2011-08-23 22:11:41 -0700 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2011-08-23 22:11:41 -0700 |
commit | c5c1afaad86f4db6700bd540af9cd5e1999e10bc (patch) | |
tree | ea3001072705eb416616e5ed75280accef65568f /util.py | |
parent | dae7c73578819575aaac2790546509343d7c7074 (diff) |
Added Pygame renderer and a demo of usage. Also added a renderer for the main lights which is
waiting on a layout.
Diffstat (limited to 'util.py')
-rw-r--r-- | util.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -0,0 +1,20 @@ +from numpy import zeros +argDict = {'flags': 0, 'startcode': 0x0fff, 'pad':0} + +# Allocate a buffer for transmitted packets and fill it with magic +# Only works for strips of 50 pixels +xmit = zeros(174, dtype='ubyte') +xmit[:8], xmit[20:24] = [4,1,220,74,1,0,8,1], [150,0,255,15] + +def composePixelStripPacket(values, port): + xmit[16], xmit[24:] = port, values.ravel() + return xmit + +import socket +def getConnectedSocket(ip,port): + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + try: + sock.connect((ip, port)) + return sock + except Exception as inst: + print 'socket failure' |