rgbmatrix – Low-level routines for bitbanged LED matrices

For more information about working with RGB matrix panels in CircuitPython, see the dedicated learn guide.

Available on these boards
  • 0xCB Helios
  • 42. Keebs Frood
  • ARAMCON Badge 2019
  • ARAMCON2 Badge
  • Adafruit CLUE nRF52840 Express
  • Adafruit Circuit Playground Bluefruit
  • Adafruit Feather Bluefruit Sense
  • Adafruit Feather M4 CAN
  • Adafruit Feather M4 Express
  • Adafruit Feather RP2040
  • Adafruit Feather RP2040 CAN
  • Adafruit Feather RP2040 DVI
  • Adafruit Feather RP2040 Prop-Maker
  • Adafruit Feather RP2040 RFM
  • Adafruit Feather RP2040 Scorpio
  • Adafruit Feather RP2040 ThinkInk
  • Adafruit Feather RP2040 USB Host
  • Adafruit Feather STM32F405 Express
  • Adafruit Feather nRF52840 Express
  • Adafruit Grand Central M4 Express
  • Adafruit Hallowing M4 Express
  • Adafruit ItsyBitsy M4 Express
  • Adafruit ItsyBitsy RP2040
  • Adafruit ItsyBitsy nRF52840 Express
  • Adafruit KB2040
  • Adafruit LED Glasses Driver nRF52840
  • Adafruit Macropad RP2040
  • Adafruit Matrix Portal M4
  • Adafruit Metro M4 Airlift Lite
  • Adafruit Metro M4 Express
  • Adafruit Metro RP2040
  • Adafruit Metro nRF52840 Express
  • Adafruit Monster M4SK
  • Adafruit PyPortal
  • Adafruit PyPortal Pynt
  • Adafruit PyPortal Titano
  • Adafruit QT Py RP2040
  • Adafruit QT2040 Trinkey
  • AloriumTech Evo M51
  • Arduino Nano 33 BLE
  • Arduino Nano RP2040 Connect
  • AtelierDuMaker nRF52840 Breakout
  • BBQ20KBD
  • BDMICRO VINA-D51
  • BLE-SS dev board Multi Sensor
  • BLOK
  • BastBLE
  • BlueMicro840
  • COSMO-Pico
  • CP32-M4
  • Challenger NB RP2040 WiFi
  • Challenger RP2040 LTE
  • Challenger RP2040 LoRa
  • Challenger RP2040 SD/RTC
  • Challenger RP2040 SubGHz
  • Challenger RP2040 WiFi
  • Challenger RP2040 WiFi/BLE
  • CircuitBrains Deluxe
  • Cytron Maker Nano RP2040
  • Cytron Maker Pi RP2040
  • Datanoise PicoADK
  • DynOSSAT-EDU-OBC
  • E-Fidget
  • ELECFREAKS PICO:ED
  • Electrolama minik
  • Electronut Labs Blip
  • Electronut Labs Papyr
  • EncoderPad RP2040
  • Fig Pi
  • Hack Club Sprig
  • HiiBot BlueFi
  • IkigaiSense Vita nRF52840
  • LILYGO T-DISPLAY
  • MDBT50Q-DB-40
  • MDBT50Q-RX Dongle
  • MakerDiary nRF52840 MDK
  • MakerDiary nRF52840 MDK USB Dongle
  • Makerdiary M60 Keyboard
  • Makerdiary Pitaya Go
  • Makerdiary nRF52840 Connect Kit
  • Makerdiary nRF52840 M.2 Developer Kit
  • Melopero Shake RP2040
  • Mini SAM M4
  • Oak Dev Tech BREAD2040
  • Oak Dev Tech Cast-Away RP2040
  • Open Hardware Summit 2020 Badge
  • PCA10056 nRF52840-DK
  • PCA10059 nRF52840 Dongle
  • Pajenicko PicoPad
  • Particle Argon
  • Particle Boron
  • Particle Xenon
  • PillBug
  • Pimoroni Badger 2040
  • Pimoroni Badger 2040 W
  • Pimoroni Inky Frame 5.7
  • Pimoroni Interstate 75
  • Pimoroni Keybow 2040
  • Pimoroni Motor 2040
  • Pimoroni PGA2040
  • Pimoroni Pico DV Base W
  • Pimoroni Pico LiPo (16MB)
  • Pimoroni Pico LiPo (4MB)
  • Pimoroni Pico dv Base
  • Pimoroni PicoSystem
  • Pimoroni Plasma 2040
  • Pimoroni Plasma 2040W
  • Pimoroni Servo 2040
  • Pimoroni Tiny 2040 (2MB)
  • Pimoroni Tiny 2040 (8MB)
  • PyKey 18 Numpad
  • PyKey 44 Ergo
  • PyKey 60
  • PyKey 87 TKL
  • PyboardV1_1
  • RP2.65-F
  • RP2040 Stamp
  • Raspberry Pi Pico
  • Raspberry Pi Pico W
  • SAM32v26
  • SSCI ISP1807 Dev Board
  • SSCI ISP1807 Micro Board
  • Seeed XIAO nRF52840 Sense
  • Seeeduino XIAO RP2040
  • Silicognition LLC M4-Shim
  • Silicognition LLC RP2040-Shim
  • SparkFun MicroMod RP2040 Processor
  • SparkFun MicroMod SAMD51 Processor
  • SparkFun MicroMod nRF52840 Processor
  • SparkFun Pro Micro RP2040
  • SparkFun Pro nRF52840 Mini
  • SparkFun STM32 MicroMod Processor
  • SparkFun Thing Plus - RP2040
  • SparkFun Thing Plus - SAMD51
  • SparkFun Thing Plus - STM32
  • TG-Boards' Datalore IP M4
  • TG-Watch
  • Teknikio Bluebird
  • The Open Book Feather
  • TinkeringTech ScoutMakes Azul
  • UARTLogger II
  • VCC-GND Studio YD RP2040
  • W5100S-EVB-Pico
  • W5500-EVB-Pico
  • WarmBit BluePixel nRF52840
  • Waveshare RP2040-LCD-0.96
  • Waveshare RP2040-LCD-1.28
  • Waveshare RP2040-Plus (16MB)
  • Waveshare RP2040-Plus (4MB)
  • Waveshare RP2040-Zero
  • WeAct Studio Pico
  • WeAct Studio Pico 16MB
  • iLabs Challenger 840
  • nice!nano
  • nullbits Bit-C PRO
  • splitkb.com Liatris
  • takayoshiotake Octave RP2040
  • uGame22

class rgbmatrix.RGBMatrix(*, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: Sequence[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: circuitpython_typing.WriteableBuffer | None = None, height: int = 0, tile: int = 1, serpentine: bool = True)

Displays an in-memory framebuffer to a HUB75-style RGB LED matrix.

Create a RGBMatrix object with the given attributes. The height of the display is determined by the number of rgb and address pins and the number of tiles: len(rgb_pins) // 3 * 2 ** len(address_pins) * abs(tile). With 6 RGB pins, 4 address lines, and a single matrix, the display will be 32 pixels tall. If the optional height parameter is specified and is not 0, it is checked against the calculated height.

Up to 30 RGB pins and 8 address pins are supported.

The RGB pins must be within a single “port” and performance and memory usage are best when they are all within “close by” bits of the port. The clock pin must also be on the same port as the RGB pins. See the documentation of the underlying protomatter C library for more information. Generally, Adafruit’s interface boards are designed so that these requirements are met when matched with the intended microcontroller board. For instance, the Feather M4 Express works together with the RGB Matrix Feather.

The framebuffer is in “RGB565” format.

“RGB565” means that it is organized as a series of 16-bit numbers where the highest 5 bits are interpreted as red, the next 6 as green, and the final 5 as blue. The object can be any buffer, but array.array and ulab.ndarray objects are most often useful. To update the content, modify the framebuffer and call refresh.

If a framebuffer is not passed in, one is allocated and initialized to all black. In any case, the framebuffer can be retrieved by passing the RGBMatrix object to memoryview().

If doublebuffer is False, some memory is saved, but the display may flicker during updates.

A RGBMatrix is often used in conjunction with a framebufferio.FramebufferDisplay.

Parameters:
  • width (int) – The overall width of the whole matrix in pixels. For a matrix with multiple panels in row, this is the width of a single panel times the number of panels across.

  • tile (int) – In a multi-row matrix, the number of rows of panels

  • bit_depth (int) – The color depth of the matrix. A value of 1 gives 8 colors, a value of 2 gives 64 colors, and so on. Increasing bit depth increases the CPU and RAM usage of the RGBMatrix, and may lower the panel refresh rate. The framebuffer is always in RGB565 format regardless of the bit depth setting

  • serpentine (bool) – In a multi-row matrix, True when alternate rows of panels are rotated 180°, which can reduce wiring length

  • rgb_pins (Sequence[digitalio.DigitalInOut]) – The matrix’s RGB pins

  • addr_pins (Sequence[digitalio.DigitalInOut]) – The matrix’s address pins

  • clock_pin (digitalio.DigitalInOut) – The matrix’s clock pin

  • latch_pin (digitalio.DigitalInOut) – The matrix’s latch pin

  • output_enable_pin (digitalio.DigitalInOut) – The matrix’s output enable pin

  • doublebuffer (bool) – True if the output is double-buffered

  • framebuffer (Optional[WriteableBuffer]) – A pre-allocated framebuffer to use. If unspecified, a framebuffer is allocated

  • height (int) – The optional overall height of the whole matrix in pixels. This value is not required because it can be calculated as described above.

brightness: float

In the current implementation, 0.0 turns the display off entirely and any other value up to 1.0 turns the display on fully.

width: int

The width of the display, in pixels

height: int

The height of the display, in pixels

deinit() None

Free the resources (pins, timers, etc.) associated with this rgbmatrix instance. After deinitialization, no further operations may be performed.

refresh() None

Transmits the color data in the buffer to the pixels so that they are shown.