Subversion Repositories Code-Repo

Rev

Rev 265 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 265 Rev 266
Line 85... Line 85...
85
        txColorCh = "%02x" % c
85
        txColorCh = "%02x" % c
86
        txData = ''.join( ["%02x" % (x) for x in frame_buffer[c::3]])
86
        txData = ''.join( ["%02x" % (x) for x in frame_buffer[c::3]])
87
        payload = txFrame + txOpcode + txColorCh.decode('hex') + txData.decode('hex')
87
        payload = txFrame + txOpcode + txColorCh.decode('hex') + txData.decode('hex')
88
        sock.send(payload)
88
        sock.send(payload)
89
 
89
 
90
def cube_update_text(string, r, g, b, update_rate):
90
def cube_update_text_scrolling(string, r, g, b, update_rate):
91
    '''Sets the scrolling text on the cube.'''
91
    '''Sets the scrolling text on the cube.'''
92
    txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, len(string) + 6)
92
    txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, len(string) + 6)
93
    txOpcode = "20".decode('hex')
93
    txOpcode = "20".decode('hex')
94
    txData = ''.join("%02x%02x%02x%02x%02x" % (len(string), r, g, b, update_rate))
94
    txData = ''.join("%02x%02x%02x%02x%02x" % (len(string), r, g, b, update_rate))
95
    txString = string.encode('hex')
95
    txString = string.encode('hex')
96
    sock.send(txFrame + txOpcode + txData.decode('hex') + txString.decode('hex'))
96
    sock.send(txFrame + txOpcode + txData.decode('hex') + txString.decode('hex'))
97
 
97
 
-
 
98
def cube_update_text_static(string, r, g, b):
-
 
99
    '''Sets the static text on the cube.'''
-
 
100
    txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, len(string) + 5)
-
 
101
    txOpcode = "21".decode('hex')
-
 
102
    txData = ''.join("%02x%02x%02x%02x" % (len(string), r, g, b))
-
 
103
    txString = string.encode('hex')
-
 
104
    sock.send(txFrame + txOpcode + txData.decode('hex') + txString.decode('hex'))
-
 
105
 
-
 
106
def cube_update_text_insert(character, r, g, b):
-
 
107
    '''Appends a character to the beginning of the text buffer.'''
-
 
108
    txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, 5)
-
 
109
    txOpcode = "22".decode('hex')
-
 
110
    txData = ''.join("%02x%02x%02x%02x" % (r, g, b, character))
-
 
111
    sock.send(txFrame + txOpcode + txData.decode('hex'))
-
 
112
 
98
def cube_update_waterfall(c0, c1, c2, c3, c4, c5, c6, c7):
113
def cube_update_waterfall(c0, c1, c2, c3, c4, c5, c6, c7):
99
    '''Fills in one row and shifts rows by one.'''
114
    '''Fills in one row and shifts rows by one.'''
100
    txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, 9)
115
    txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, 9)
101
    txOpcode = "30".decode('hex')
116
    txOpcode = "30".decode('hex')
102
    txData = ''.join("%02x%02x%02x%02x%02x%02x%02x%02x" % (c0, c1, c2, c3, c4, c5, c6, c7))
117
    txData = ''.join("%02x%02x%02x%02x%02x%02x%02x%02x" % (c0, c1, c2, c3, c4, c5, c6, c7))