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