|
12 | 12 | import framebufferio
|
13 | 13 | import rgbmatrix
|
14 | 14 | import terminalio
|
| 15 | + |
| 16 | +# If there was a display before (protomatter, LCD, or E-paper), release it so |
| 17 | +# we can create ours |
15 | 18 | displayio.release_displays()
|
16 | 19 |
|
| 20 | +# This next call creates the RGB Matrix object itself. It has the given width |
| 21 | +# and height. bit_depth can range from 1 to 6; higher numbers allow more color |
| 22 | +# shades to be displayed, but increase memory usage and slow down your Python |
| 23 | +# code. If you just want to show primary colors plus black and white, use 1. |
| 24 | +# Otherwise, try 3, 4 and 5 to see which effect you like best. |
| 25 | +# |
| 26 | +# These lines are for the Feather M4 Express. If you're using a different board, |
| 27 | +# check the guide to find the pins and wiring diagrams for your board. |
| 28 | +# If you have a matrix with a different width or height, change that too. |
| 29 | +# If you have a 16x32 display, try with just a single line of text. |
17 | 30 | matrix = rgbmatrix.RGBMatrix(
|
18 | 31 | width=64, height=32, bit_depth=1,
|
19 | 32 | rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12],
|
20 | 33 | addr_pins=[board.A5, board.A4, board.A3, board.A2],
|
21 | 34 | clock_pin=board.D13, latch_pin=board.D0, output_enable_pin=board.D1)
|
| 35 | + |
| 36 | +# Associate the RGB matrix with a Display so that we can use displayio features |
22 | 37 | display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False)
|
23 | 38 |
|
| 39 | +# Create two lines of text to scroll. Besides changing the text, you can also |
| 40 | +# customize the color and font (using Adafruit_CircuitPython_Bitmap_Font). |
| 41 | +# To keep this demo simple, we just used the built-in font. |
| 42 | +# The Y coordinates of the two lines were chosen so that they looked good |
| 43 | +# but if you change the font you might find that other values work better. |
24 | 44 | line1 = adafruit_display_text.label.Label(
|
25 | 45 | terminalio.FONT,
|
26 | 46 | color=0xff0000,
|
|
35 | 55 | line2.x = display.width
|
36 | 56 | line2.y = 24
|
37 | 57 |
|
38 |
| -g = displayio.Group(max_size=2) |
| 58 | +# Put each line of text into a Group, then show that group. |
| 59 | +g = displayio.Group() |
39 | 60 | g.append(line1)
|
40 | 61 | g.append(line2)
|
41 | 62 | display.show(g)
|
42 | 63 |
|
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 |
| 64 | +# This function will scoot one label a pixel to the left and send it back to |
| 65 | +# the far right if it's gone all the way off screen. This goes in a function |
| 66 | +# because we'll do exactly the same thing with line1 and line2 below. |
45 | 67 | def scroll(line):
|
46 | 68 | line.x = line.x - 1
|
47 | 69 | line_width = line.bounding_box[2]
|
|
0 commit comments