Skip to content

Commit 0c3ef8c

Browse files
authored
Merge pull request adafruit#1137 from ladyada/master
demo code for RGB matrix
2 parents 362439a + 31aba82 commit 0c3ef8c

File tree

1 file changed

+196
-0
lines changed

1 file changed

+196
-0
lines changed

Say_Their_Names_LEDMatrix/code.py

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
import time
2+
import board
3+
import displayio
4+
import framebufferio
5+
import rgbmatrix
6+
import terminalio
7+
import adafruit_display_text.label
8+
9+
names = [
10+
"Rodney King",
11+
"Abner Louima",
12+
"Amadou Diallo",
13+
"Sean Bell",
14+
"Oscar Grant",
15+
"Eric Garner",
16+
"Michael Brown",
17+
"Laquan McDonald",
18+
"Freddie Gray",
19+
"Antwon Rose Jr",
20+
"Ahmaud Arbery",
21+
"Breonna Taylor",
22+
"John Crawford III",
23+
"Ezell Ford",
24+
"Dante Parker",
25+
"Michelle Cusseaux",
26+
"Laquan Mcdonald",
27+
"George Mann",
28+
"Tanisha Anderson",
29+
"Akai Gurley",
30+
"Tamir Rice",
31+
"Rumain Brisbon",
32+
"Jerame Reid",
33+
"Matthew Ajibade",
34+
"Frank Smart",
35+
"Nastasha McKenna",
36+
"Tony Robinson",
37+
"Anthony Hill",
38+
"Mya Hall",
39+
"Phillip White",
40+
"Eric Harris",
41+
"Walter Scott",
42+
"William Chapman II",
43+
"Alexia Christian",
44+
"Brendon Glenn",
45+
"Victor Maunel Larosa",
46+
"Jonathan Sanders",
47+
"Freddie Blue",
48+
"Joseph Mann",
49+
"Salvado Ellswood",
50+
"Sanda Bland",
51+
"Albert Joseph Davis",
52+
"Darrius Stewart",
53+
"Billy Ray Davis",
54+
"Samuel Dubose",
55+
"Michael Sabbie",
56+
"Brian Keith Day",
57+
"Christian Taylor",
58+
"Troy Robinson",
59+
"Asshams Pharoah Manley",
60+
"Felix Kumi",
61+
"Keith Harrison Mcleod",
62+
"Junior Prosper",
63+
"Lamontez Jones",
64+
"Paterson Brown",
65+
"Dominic Hutchinson",
66+
"Anthony Ashford",
67+
"Alonzo Smith",
68+
"Tyree Crawford",
69+
"India Kager",
70+
"La'vante Biggs",
71+
"Michael Lee Marshall",
72+
"Jamar Clark",
73+
"Richard Perkins",
74+
"Nathaniel Harris Pickett",
75+
"Benni Lee Tignor",
76+
"Miguel Espinal",
77+
"Michael Noel",
78+
"Kevin Matthews",
79+
"Bettie Jones",
80+
"Quintonio Legrier",
81+
"Keith Childress Jr",
82+
"Janet Wilson",
83+
"Randy Nelson",
84+
"Antronie Scott",
85+
"Wendell Celestine",
86+
"David Joseph",
87+
"Calin Roquemore",
88+
"Dyzhawn Perkins",
89+
"Christoper Davis",
90+
"Marco Loud",
91+
"Peter Gaines",
92+
"Torry Robison",
93+
"Darius Robinson",
94+
"Kevin Hicks",
95+
"Mary Truxillo",
96+
"Demarcus Semer",
97+
"Willie Tillman",
98+
"Terrill Thomas",
99+
"Sylville Smith",
100+
"Sean Reed",
101+
"Alton Streling",
102+
"Philando Castile",
103+
"Terence Crutcher",
104+
"Paul O'Neal",
105+
"Alteria Woods",
106+
"Jordan Edwards",
107+
"Aaron Bailey",
108+
"Ronell Foster",
109+
"Stephon Clark",
110+
"Antwon Rose II",
111+
"Botham Jean",
112+
"Pamela Turner",
113+
"Dominique Clayton",
114+
"Atatiana Jefferson",
115+
"Christopher Whitfield",
116+
"Christopher Mccovey",
117+
"Eric Reason",
118+
"Michael Lorenzo Dean",
119+
"Tony McDade",
120+
"David McAtee",
121+
"George Floyd",
122+
]
123+
124+
displayio.release_displays()
125+
matrix = rgbmatrix.RGBMatrix(
126+
width=64,
127+
bit_depth=4,
128+
rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12],
129+
addr_pins=[board.A5, board.A4, board.A3, board.A2],
130+
clock_pin=board.D13,
131+
latch_pin=board.D0,
132+
output_enable_pin=board.D1,
133+
)
134+
display = framebufferio.FramebufferDisplay(matrix)
135+
136+
# Create a 3 line set of small font text
137+
blm_font = [None, None, None]
138+
for line in range(3):
139+
label = adafruit_display_text.label.Label(
140+
terminalio.FONT, color=0xFFFFFF, x=2, y=line * 10 - 2, max_glyphs=16
141+
)
142+
blm_font[line] = label
143+
144+
# Create a 2 line set of font text
145+
names_font = [None, None]
146+
for line in range(2):
147+
label = adafruit_display_text.label.Label(
148+
terminalio.FONT,
149+
color=0xFFFFFF,
150+
x=36,
151+
y=line * 14, # these will center text when anchor is top-middle
152+
max_glyphs=16,
153+
)
154+
label.anchor_point = (0.5, 0)
155+
names_font[line] = label
156+
157+
g = displayio.Group(max_size=10)
158+
for line in blm_font:
159+
g.append(line)
160+
for line in names_font:
161+
g.append(line)
162+
display.show(g)
163+
164+
165+
while True:
166+
# show three small font lines in white
167+
for line in blm_font:
168+
line.color = 0xFFFFFF
169+
# set up text
170+
blm_font[0].text = "BLACK"
171+
blm_font[1].text = "LIVES"
172+
blm_font[2].text = "MATTER"
173+
time.sleep(1)
174+
175+
blm_font[1].color = blm_font[2].color = 0 # hide lines 2&3
176+
time.sleep(1)
177+
blm_font[1].color = 0xFFFFFF # show middle line
178+
blm_font[0].color = blm_font[2].color = 0 # hide lines 1&3
179+
time.sleep(1)
180+
blm_font[2].color = 0xFFFFFF # show last line
181+
blm_font[0].color = blm_font[1].color = 0 # hide lines 1&2
182+
time.sleep(1)
183+
184+
# hide the three small text lines
185+
for line in blm_font:
186+
line.color = 0
187+
time.sleep(1)
188+
189+
for name in names:
190+
# say their names!
191+
print(name)
192+
lines = name.split(" ")
193+
names_font[0].text = lines[0]
194+
names_font[1].text = lines[1]
195+
time.sleep(5)
196+
names_font[0].text = names_font[1].text = ""

0 commit comments

Comments
 (0)