Skip to content

Commit a9deb63

Browse files
committed
CircuitPython_RGBMatrix: add simple_scroller example
1 parent bb773d1 commit a9deb63

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This example implements a simple two line scroller using
2+
# Adafruit_CircuitPython_Display_Text. Each line has its own color
3+
# and it is possible to modify the example to use other fonts and non-standard
4+
# characters.
5+
6+
import array
7+
8+
from _pixelbuf import wheel
9+
import adafruit_display_text.label
10+
import board
11+
import displayio
12+
import framebufferio
13+
import rgbmatrix
14+
import terminalio
15+
displayio.release_displays()
16+
17+
matrix = rgbmatrix.RGBMatrix(
18+
width=64, height=32, bit_depth=1,
19+
rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12],
20+
addr_pins=[board.A5, board.A4, board.A3, board.A2],
21+
clock_pin=board.D13, latch_pin=board.D0, output_enable_pin=board.D1)
22+
display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False)
23+
24+
line1 = adafruit_display_text.label.Label(
25+
terminalio.FONT,
26+
color=0xff0000,
27+
text="This scroller is brought to you by CircuitPython RGBMatrix")
28+
line1.x = display.width
29+
line1.y = 8
30+
31+
line2 = adafruit_display_text.label.Label(
32+
terminalio.FONT,
33+
color=0x0080ff,
34+
text="Hello to all CircuitPython contributors worldwide <3")
35+
line2.x = display.width
36+
line2.y = 24
37+
38+
g = displayio.Group(max_size=2)
39+
g.append(line1)
40+
g.append(line2)
41+
display.show(g)
42+
43+
# Scoot one label a pixel to the left; send it back to the far right
44+
# if it's gone all the way off screen
45+
def scroll(line):
46+
line.x = line.x - 1
47+
line_width = line.bounding_box[2]
48+
if line.x < -line_width:
49+
line.x = display.width
50+
51+
# You can add more effects in this loop. For instance, maybe you want to set the
52+
# color of each label to a different value
53+
while True:
54+
scroll(line1)
55+
scroll(line2)
56+
display.refresh(minimum_frames_per_second=0)

0 commit comments

Comments
 (0)