1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
| import spidev
import time
spi = spidev.SpiDev()
spi.open(0,0)
def Initialise():
# decoding :BCD
spi.writebytes([0x09])
spi.writebytes([0x00])
# brightness
spi.writebytes([0x0a])
spi.writebytes([0x03])
# scanlimit; 8 LEDs
spi.writebytes([0x0b])
spi.writebytes([0x07])
# power-down mode: 0. normal mode:1
spi.writebytes([0x0c])
spi.writebytes([0x01])
# test display: 1; EOT. display: 0
spi.writebytes([0x0f])
spi.writebytes([0x00])
Matrix = [[0 for x in xrange(8)] for x in xrange(38)]
Matrix[0] = [0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C] #0
Matrix[1] = [0x4,0xC,0x14,0x4,0x4,0x4,0x4,0x4] #1
Matrix[2] = [0x7E,0x2,0x2,0x7E,0x40,0x40,0x40,0x7E] #2
Matrix[3] = [0x3E,0x2,0x2,0x3E,0x2,0x2,0x3E,0x0] #3
Matrix[4] = [0x8,0x18,0x28,0x48,0xFE,0x8,0x8,0x8] #4
Matrix[5] = [0x3C,0x20,0x20,0x3C,0x4,0x4,0x3C,0x0] #5
Matrix[6] = [0x3C,0x20,0x20,0x3C,0x24,0x24,0x3C,0x0] #6
Matrix[7] = [0x3E,0x22,0x4,0x8,0x8,0x8,0x8,0x8] #7
Matrix[8] = [0x0,0x3E,0x22,0x22,0x3E,0x22,0x22,0x3E] #8
Matrix[9] = [0x3E,0x22,0x22,0x3E,0x2,0x2,0x2,0x3E] #9
Matrix[10] = [0x8,0x14,0x22,0x3E,0x22,0x22,0x22,0x22] #A
Matrix[11] = [0x3C,0x22,0x22,0x3E,0x22,0x22,0x3C,0x0] #B
Matrix[12] = [0x3C,0x40,0x40,0x40,0x40,0x40,0x3C,0x0] #C
Matrix[13] = [0x7C,0x42,0x42,0x42,0x42,0x42,0x7C,0x0] #D
Matrix[14] = [0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x7C] #E
Matrix[15] = [0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x40] #F
Matrix[16] = [0x3C,0x40,0x40,0x40,0x40,0x44,0x44,0x3C] #G
Matrix[17] = [0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44] #H
Matrix[18] = [0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x7C] #I
Matrix[19] = [0x3C,0x8,0x8,0x8,0x8,0x8,0x48,0x30] #J
Matrix[20] = [0x0,0x24,0x28,0x30,0x20,0x30,0x28,0x24] #K
Matrix[21] = [0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C] #L
Matrix[22] = [0x81,0xC3,0xA5,0x99,0x81,0x81,0x81,0x81] #M
Matrix[23] = [0x0,0x42,0x62,0x52,0x4A,0x46,0x42,0x0] #N
Matrix[24] = [0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C] #O
Matrix[25] = [0x3C,0x22,0x22,0x22,0x3C,0x20,0x20,0x20] #P
Matrix[26] = [0x1C,0x22,0x22,0x22,0x22,0x26,0x22,0x1D] #Q
Matrix[27] = [0x3C,0x22,0x22,0x22,0x3C,0x24,0x22,0x21] #R
Matrix[28] = [0x0,0x1E,0x20,0x20,0x3E,0x2,0x2,0x3C] #S
Matrix[29] = [0x0,0x3E,0x8,0x8,0x8,0x8,0x8,0x8] #T
Matrix[30] = [0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1C] #U
Matrix[31] = [0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18] #V
Matrix[32] = [0x0,0x49,0x49,0x49,0x49,0x2A,0x1C,0x0] #W
Matrix[33] = [0x0,0x41,0x22,0x14,0x8,0x14,0x22,0x41] #X
Matrix[34] = [0x41,0x22,0x14,0x8,0x8,0x8,0x8,0x8] #Y
Matrix[35] = [0x0,0x7F,0x2,0x4,0x8,0x10,0x20,0x7F] #Z
columns = [0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8]
Initialise()
for j in range(0, 38):
for i in range(0,8):
resp = spi.xfer([columns[i],Matrix[j][i]])
print '0x%02X 0x%02X' % (columns[i], Matrix[j][i])
time.sleep(1)
print
spi.close |