Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
214 Kevin 1
'''Generates the byte array for setting the global brightness.'''
2
def CMD_Set_BC(brightness):
3
	barray = bytearray.fromhex('7E 00 02 0A')
4
	barray.extend([brightness])
5
	barray.extend([Calculate_Checksum(barray)])
6
	return barray
7
 
8
'''Generates the byte array for clearing all pixels.'''
9
def CMD_Clear():
10
	return bytearray.fromhex('7E 00 01 0B F4')
11
 
12
'''Generates the command for setting a specific pixel.'''
13
def CMD_Set_Pixel(layer, row, column, r, g, b):
14
	barray = bytearray.fromhex('7E 00 07 10')
15
	barray.extend([layer,row,column,r,g,b,])
16
	barray.extend([Calculate_Checksum(barray)])
17
	return barray
18
 
19
'''Generates the command for setting an entire layer.'''
20
def CMD_Set_Layer(layer, leds):
21
	barray = bytearray.fromhex('7E 01 22 11')
22
	barray.extend([layer])
23
	barray.extend(leds)
24
	barray.extend([Calculate_Checksum(barray)])
25
	return barray
26
 
27
'''Generates the command for setting the rotating overlay text.'''
28
def CMD_Start_Text(r, g, b, string):
29
	length = len(string) + 4
30
	barray = bytearray.fromhex('7E 00') 
31
	barray.extend([length, 0x20, r, g, b])
32
	barray.extend(string.encode())
33
	barray.extend([Calculate_Checksum(barray)])
34
	return barray
35
 
36
'''Generates the command for stopping the rotating overlay text.'''
37
def CMD_Stop_Text():
38
	return bytes.fromhex('7E 00 01 21 DE')
39
 
40
def Calculate_Checksum(barray):
41
	s = 0
42
	for entry in range(3,len(barray)):
43
		s += barray[entry]
44
	return 255 - (s & 0xFF)