The easiest way to get started with RGBMatrix is with the RGB Matrix FeatherWing. Now you can quickly and easily create projects featuring your favorite 16 or 32-pixel tall matrix boards.
Please note: This wing is only tested/designed to work with the SAMD51 M4 Feather or the nRF52840 Feather. It may be possible to use the extra holes as a prototyping area to adapt it to other Feathers, but that's beyond the scope of this guide.
This wing can be assembled in one of two ways. You can either solder in a 2x8 IDC shrouded header on the top, then plug in the IDC cable that came with your matrix. This makes it easy to stack on top of your Feather. Or, you can solder in the 2x10 socket header on the bottom of the Wing, and then stack your Feather on top. That way you can plug it directly into the back of the matrix *mind blown*
Either way you decide to go, you can plug a 5V DC power pack into the 2.1mm DC jack. That 5V is polarity protected and then output on the other side to a 5.08mm terminal block. An onboard regulator will provide 3.3V power to your Feather, so you don't need a separate USB or battery. This makes for a very compact build!
Each 'Wing kit comes with one FeatherWing PCB with surface mount parts attached, a 2x8 IDC header, a 2x10 female socket, 2.1mm DC jack, 5.08mm terminal block, and some male header. You may also want some Feather stacking headers or female headers depending on how you plan to attach/stack your Feather.
Use the following block of code to initialize a 64x32 matrix.
displayio.release_displays() matrix = rgbmatrix.RGBMatrix( width=64, bit_depth=4, rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12], addr_pins=[board.D25, board.D24, board.A3, board.A2], clock_pin=board.D13, latch_pin=board.D0, output_enable_pin=board.D1) display = framebufferio.FramebufferDisplay(matrix)
Use the following block of code to initialize a 32x16 matrix. In this mode, you may not use pin A2 unless you cut the trace connecting it to the header, because it is connected to GND on the RGB matrix.
displayio.release_displays() matrix = rgbmatrix.RGBMatrix( width=32, bit_depth=4, rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12], addr_pins=[board.D25, board.D24, board.A3], clock_pin=board.D13, latch_pin=board.D0, output_enable_pin=board.D1) display = framebufferio.FramebufferDisplay(matrix)
Complete example: RP2040 Feather Scroller
Save the below file (called rp2040.py to CIRCUITPY as code.py and also save the bitmap image file pi-logo32b.bmp to CIRCUITPY. The 64x32 matrix will scroll the text "RP2040 Feather" over a Raspberry Pi logo.
# SPDX-FileCopyrightText: 2021 Jeff Epler for Adafruit Industries # # SPDX-License-Identifier: MIT import time from math import sin import board import displayio import rgbmatrix import framebufferio import adafruit_imageload import terminalio from adafruit_display_text.label import Label displayio.release_displays() matrix = rgbmatrix.RGBMatrix( width=64, bit_depth=6, rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12], addr_pins=[board.D25, board.D24, board.A3, board.A2], clock_pin=board.D13, latch_pin=board.D0, output_enable_pin=board.D1, doublebuffer=True) display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False) g = displayio.Group() b, p = adafruit_imageload.load("pi-logo32b.bmp") t = displayio.TileGrid(b, pixel_shader=p) t.x = 20 g.append(t) l = Label(text="Feather\nRP2040", font=terminalio.FONT, color=0xffffff, line_spacing=.7) g.append(l) display.root_group = g target_fps = 50 ft = 1/target_fps now = t0 = time.monotonic_ns() deadline = t0 + ft p = 1 q = 17 while True: tm = (now - t0) * 1e-9 x = l.x - 1 if x < -40: x = 63 y = round(12 + sin(tm / p) * 6) l.x = x l.y = y display.refresh(target_frames_per_second=target_fps, minimum_frames_per_second=0) while True: now = time.monotonic_ns() if now > deadline: break time.sleep((deadline - now) * 1e-9) deadline += ft
Text editor powered by tinymce.