aboutsummaryrefslogtreecommitdiff
path: root/renderer.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-08-31 15:55:42 -0400
committerGravatar rcoh <rcoh@mit.edu>2011-08-31 15:55:42 -0400
commit6c867df7bbd312f3245b594bb2601651ff322351 (patch)
tree9d14bf02709dbc929b9e5c374036571dfd5e0c74 /renderer.py
parentb28103e7243539cea13d4a3980f14d4b9d2bc1a7 (diff)
fixed the renderer :).
Diffstat (limited to 'renderer.py')
-rw-r--r--renderer.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/renderer.py b/renderer.py
index db929e5..a950447 100644
--- a/renderer.py
+++ b/renderer.py
@@ -138,12 +138,13 @@ class LedRenderer(Renderer):
Renderer for the LEDs. Based heavily on IndoorRenderer in Smootlight and
general Smootlight abstraction patterns
"""
- POWER_SUPPLY_IPS = ['10.32.97.17',0,0,0] #TODO: Fill in
+ POWER_SUPPLY_IPS = ['10.32.0.32','10.32.0.32', '10.32.0.31', '10.32.0.31',0,0] #TODO: Fill in
SOCK_PORT = 6038
sockets = {}
def render_game(self, game_board):
packets = self.map_to_packets(game_board)
+
packets_with_destinations = zip(self.POWER_SUPPLY_IPS, packets)
for (ip, (port, packet)) in packets_with_destinations:
if not ip in self.sockets:
@@ -155,7 +156,11 @@ class LedRenderer(Renderer):
except:
print 'failure sending packet'
def color_deref(self, color):
- return (255, 0, 0)
+ return Color(color)[0:3]
+ def fake_map_to_packets(self, game_board):
+ strip = zeros((50,3), 'ubyte')
+ strip[:] = (255,255,0)
+ return [(1, strip), (2, strip)] * 4
def map_to_packets(self, game_board):
"""
Performs the mapping between a game_board and a list of (port,packet) pairs. The port,packet
@@ -164,19 +169,22 @@ class LedRenderer(Renderer):
#This is hardcoded, mostly because I'm curious of the complexity
packets = []
board_x_min = 0
- board_x_max = 10
+ board_x_max = 9
section_width = 10
section_height = 5
- for board_x_min in [0, 10]:
- packet = []
- for board_y_min in [20, 15, 10, 5]:
+ for board_x_min in [0, 10]: #for each board:
+ for board_y_min in [0, 5, 10, 15]:
strip = zeros((50,3),'ubyte')
index = 0
- for y in range(board_y_min, board_y_min-section_height, -1):
- for x in range(board_x_min+section_width, board_x_min, -1):
+ for y in range(board_y_min, board_y_min+section_height, 1):
+ strand_dir = 1 if y % 5 % 2 == 0 else -1
+ left_x = board_x_min+section_width-1 if strand_dir < 0 else board_x_min
+ right_x = board_x_min-1 if strand_dir < 0 else board_x_min+section_width
+ for x in range(left_x, right_x, strand_dir):
+ print (x,y), index
+ #strip[index] = (x*10,0,y*10)
if (x,y) in game_board:
strip[index] = self.color_deref(game_board[(x,y)])
- packet.append((1+len(packet), strip))
- index += 1
- packets += packet
+ index += 1
+ packets.append((1+(len(packets) % 2), strip))
return packets