MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

项目背景与痛点

在物联网时代,智能显示设备日益普及,诸如广告牌、电子广告牌和交互式显示等应用场景对高刷新率的需求越来越明显。对于开发者来说,如何高效驱动 HUB75 LED 矩阵面板并确保其能够达到高刷新率是一项技术挑战。传统的驱动方式可能会因为硬件限制导致画面卡顿和刷新率不稳定。mrcodetastic/ESP32-HUB75-MatrixPanel-DMA 项目正是为了解决这些问题而生,它依赖于 ESP32 系列微控制器的 DMA 技术,使得 LED 矩阵面板可以实现高刷新率。

核心技术揭秘

项目的核心技术在于巧妙利用 ESP32 系列微控制器内部的 DMA(直接内存访问)技术,简化了数据传输路径,从而实现了高刷新率的显示效果。此外,项目还融合了 Adafruit GFX 兼容库的高效位图绘制功能,提供了丰富的绘制接口和色彩管理。

graph TD A[用户代码调用] --> B[DMA 数据准备] B --> C{"DMA 通道选择"} C -->|"选择通道"| D[DMA 数据传输] B -->|"未选择通道"| E[错误处理] D --> F[显示缓冲刷新] F --> G[显示效果]

ADAfruit GFX 图形库是这个项目的基础之一,它简化了图形绘制逻辑,实现了丰富的图形功能。通过使用 DMA 提供低延迟的通信支持,项目能够显著提升图层绘制的效率。想象一下,当你需要在 LED 矩阵面板上绘制复杂图形并始终保持流畅效果时,这样的架构设计会大大降低开发者的实现难度。

功能亮点与差异

相比其他仅提供基础驱动的同类库,该项目着重于提供高效的数据流水线解决方案,尤其适用于大规模矩阵的驱动控制。它能驱动多个 HUB75 面板进行级联显示,并持续维持较高刷新率,这是同类库所不具备的。另外,项目的自定义性高适配性强,支持多种 ESP32 系列单片机,可以轻松融入各种智能显示设备的设计。

应用场景与落地建议

在生产环境中使用此项目时,开发者需要注意合理配置和优化 DMA 任务队列,以确保数据在高速传输过程中不会造成系统资源的瓶颈。此外,根据应用场景调整数据传输流控机制也是关键。对于复杂的拼接屏幕需求,开发者可以利用链式面板的功能模块,实现无缝拼接并保持一致的刷新率。

综合评价

该项目凭借高效的 DMA 数据传输方案和其 Adafruit GFX 图形库的支持,提供了一套完整的 LED 矩阵面板驱动解决方案。尽管用户需要深入了解 DMA 架构细节以优化使用体验,但项目在高刷新率显示方面展现出了独特优势。对于追求卓越显示效果的开发者而言,这是值得一试的技术工具。

关于

GitHub 原始描述(英文)

An Adafruit GFX Compatible Library for the ESP32/S2/S3/P4 to drive HUB75 LED matrix panels using DMA for high refresh rates. Supports panel chaining.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
2390
价值分
1089
活跃状态
活跃

语言占比

C
C++
CMake
Makefile
Python

Release

README

HUB75 RGB LED Matrix Panel Library Using ESP32 DMA

BUILD OPTIONS | EXAMPLES | PlatformIO CI

Table of Contents


Introduction

  • An Arduino and ESP-IDF library for HUB75 and HUB75E RGB LED panels using the ESP32.
  • Works out of the box with standard HUB75 panels where two rows are updated at the same time (referred to as “two scan” panels in this document).
  • Also supports 1/4, 1/8 scan panels. For usage, please see the VirtualMatrixPanel example, or refer to instructions found in the various issues within this repository.
  • Uses the ESP32’s hardware DMA (“LCD Mode”) for high-speed output with low CPU usage.

Features

  • Low CPU usage — Pixel data streams directly using hardware DMA without using CPU resources.
  • Fast performance — Fast bitwise operations on the DMA buffer avoid pin toggling or blocking calls.
  • Full-screen BCM — Uses binary-code modulation across the entire matrix for smooth color depth and brightness.
  • Variable color depth — Supports up to 24-bit TrueColor depending on panel size and refresh rate.
  • Natural dimming — Includes CIE 1931 luminance correction for human eye brightness perception.
  • Adafruit GFX compatible — Works with Adafruit GFX, a simplified GFX implementation, or standalone without any GFX library.

Hardware Compatibility

Important Buying Advice: Before buying an LED matrix panel, ask the seller to confirm that the panel is NOT an “S-PWM” chip and uses standard shift-register driver chips such as the FM6124.

New panel driver chips are released frequently. Always check with the seller before purchasing.

Supported ESP32 Variants

  • ESP32 (Original module, such as ESP-WROOM-32 with ESP32-D0WDQ6 chip)
  • ESP32-S2
  • ESP32-S3

Note: RISC-V ESP32 variants (such as the ESP32-C3) are not supported because they lack the required hardware LCD mode.

A quick introduction to LED Matrix Panel ‘Scan’ types

  • “Two scan” panels (two rows updated in parallel):

    • 64x32 indoor panels (1/16 scan rate).
    • 64x64 indoor panels (1/32 scan rate).
  • “Four scan” panels (four rows updated in parallel):

    • 32x16 indoor panels (1/4 scan rate) using the method shown in the Four_Scan_Panel example.
    • 128x64 panels with the SM5266P chip.
    • 80x40 panels (1/10 scan rate) with 8-pixel column reversal. See 80x40 4-scan (ZIGZAG8).

For technical background on matrix panel hardware, read this SparkFun article.

Panel Scan Types

Tested Driver Chips

The following driver chips work well with this library:

Unsupported Panels & Driver Chips

The following panels and driver chips are known to be NOT supported (there are likely many more):

  • S-PWM or PWM panels chipset based panels (e.g., RUL6024, MBI6024, HX6158SP, MBI5051, MBI5052, MBI5053, ICND2055CP). These panels work completely different are essentially their own framebuffers + PWM on chip, which is incompatible with this library.
  • SM1620B
  • Panels using RUL5358 or SHIFTREG_ABC_BIN_DE.
  • Panels using ICN2053 or FM6353. Use this library fork instead (see discussion).

If your panel is not supported, consider using the PxMatrix library.

Memory Requirements

DMA buffers use the microcontroller’s internal SRAM memory. Check the Memory Calculator to calculate expected SRAM usage.

Memory Calculator

  • ESP32-S3: You can store the DMA buffer in external PSRAM only if using Octal SPI PSRAM (e.g., ESP32-S3-N8R8). Max output frequency is limited to ~13 MHz to avoid image flickering. Do not use Quad-SPI (Q-SPI) PSRAM because it is too slow. See Build Options to enable PSRAM.
  • Standard ESP32 & ESP32-S2: You must use internal SRAM. You are limited to available internal RAM (~200 KB free memory), regardless of attached external PSRAM.

Important Hardware Notes

  • High-frequency DMA signals may cause Wi-Fi interference on some board designs.
  • The Adafruit MatrixPortal S3 can experience Wi-Fi radio issues with this library. It is not recommended if you need Wi-Fi. See discussion.

Getting Started

1. Library Installation

  1. Open Arduino IDE, go to Library Manager, and install Adafruit_GFX.
  2. Search for and install this library from the Library Manager.

PlatformIO: Add the library to the lib/ folder or add it to lib_deps inside platformio.ini. See Build Options and PlatformIO lib_deps.

2. Wiring the ESP32 to an LED Matrix Panel

Check default pin maps in default-pins.hpp under the platforms folder.

You can customize pin assignments in code:

// Change these pins as needed
#define R1_PIN 25
#define G1_PIN 26
#define B1_PIN 27
#define R2_PIN 14
#define G2_PIN 12
#define B2_PIN 13
#define A_PIN 23
#define B_PIN 19
#define C_PIN 5
#define D_PIN 17
#define E_PIN -1 // Required for 1/32 scan panels (e.g., 64x64px). Use any open pin, e.g., IO32
#define LAT_PIN 4
#define OE_PIN 15
#define CLK_PIN 16

HUB75_I2S_CFG::i2s_pins _pins={R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN};
HUB75_I2S_CFG mxconfig(
	64, // Module width
	32, // Module height
	2, // Chain length
	_pins // Pin mapping
);
dma_display = new MatrixPanel_I2S_DMA(mxconfig);

Grounding: Connect at least one Ground (GND) pin on the HUB75 connector to an ESP32 GND pin to prevent visual artifacts.

Using Adapter Boards & Shields

Custom adapter PCBs make wiring easier:

Configuring Off-the-Shelf Boards (e.g., Adafruit MatrixPortal)

Find your board’s pin numbers in the Adafruit Protomatter examples (e.g., doublebuffer_scrolltext.ino) and update your #define values.

Example for MatrixPortal S3:

Protomatter definition:

uint8_t rgbPins[]  = {42, 41, 40, 38, 39, 37};
uint8_t addrPins[] = {45, 36, 48, 35, 21};
uint8_t clockPin   = 2;
uint8_t latchPin   = 47;
uint8_t oePin      = 14;

Library config:

#define R1_PIN 42
#define G1_PIN 41
#define B1_PIN 40
#define R2_PIN 38
#define G2_PIN 39
#define B2_PIN 37
#define A_PIN  45
#define B_PIN  36
#define C_PIN  48
#define D_PIN  35
#define E_PIN  21 
#define LAT_PIN 47
#define OE_PIN  14
#define CLK_PIN 2

HUB75_I2S_CFG::i2s_pins _pins={R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN};

HUB75_I2S_CFG mxconfig(
  PANEL_RES_X,   // Module width
  PANEL_RES_Y,   // Module height
  PANEL_CHAIN,   // Chain length
  _pins          // Pin mapping
);

Using 64x64 Square Panels (HUB75E)

For 64x64 panels (HUB75E), you must assign a valid E_PIN and connect it to the E pin on the panel header.

3. Running a Test Sketch

Call begin() before drawing shapes, lines, or text.

Minimal example:

void setup() {
    dma_display->begin();
    dma_display->drawPixel(0, 0, dma_display->color565(255, 255, 255)); // Draw a white dot at top-left
}

void loop() {}

After verifying basic operation, test with the PIO Test Patterns example. This sketch displays test patterns to help identify flickering, ghosting, or pin mapping issues.


Usage & Configuration

Chaining Multiple Panels

Yes, panels can be connected together in sequence using HUB75 ribbon cables.

  • Horizontal Chaining: Connect panels end-to-end (e.g., two 64x32 panels for a 128x32 display). Update the chain length setting in mxconfig. See Pattern Plasma.
  • Grid Layouts: To chain four 64x32 panels into a 2x2 grid (128x64 display), see the VirtualMatrixPanel and AuroraDemo examples.

Resolutions above 128x64 may cause memory errors due to ESP32 internal SRAM limits.

ezgif com-video-to-gif

Adjusting Panel Brightness

Default brightness is set to 128 (50%). Change brightness using setPanelBrightness(val) or setBrightness8(val).

  • Value range: 0 (off) to 255 (full brightness).

Example:

void setup() {
    Serial.begin(115200);
    dma_display->begin();
    dma_display->setBrightness8(192); // Set brightness (~75%)
    dma_display->clearScreen();	
}

Brightness Samples

Build-Time Options

For IDEs supporting compile-time flags (such as PlatformIO or Eclipse), view the Build Options Document.

Latch Blanking

If pixels repeat horizontally (ghosting), adjust Latch Blanking using setLatBlanking(uint8_t v).

Latch blanking disables display output via OE during LAT pin transitions to hide row switching artifacts.

  • Range: 1 to 4 (default is 1). Higher values reduce overall display brightness.

Example:

dma_display->setLatBlanking(2);

Clock Phase

If pixels appear shifted by 1 pixel or show ghosting, change the clock edge mode. Some panels update on the rising clock edge; others update on the falling clock edge.

Default behavior is positive clock edge. To switch to negative clock edge, set:

mxconfig.clkphase = false;

See the Simple Test Shapes Example.

Power Requirements

A stable power supply is critical:

  1. Solder a 1000 µF–2000 µF capacitor across the VCC and GND pins on the back of each panel to stabilize power spikes.
  2. ESP32 outputs 3.3V signals. Some panels require 5V logic inputs. Use level shifters if panel inputs do not recognize 3.3V signals reliably.

Useful resources:


Community & Acknowledgments

Inspiration

This project was inspired by:

Projects Using This Library

Thanks & Acknowledgments

  • Brian Lough (YouTube) for code contributions, testing hardware, and suggestions.
  • Vortigont for performance optimizations and major code contributions.
  • Galaxy Man for donating 1/16 scan panels to help implement virtual display chaining.
  • Pipimaxi for donating an ESP32-S2 module, and Radu for donating an ESP32-S3 module.
  • Mark Donners (YouTube) for donating a 1/8 scan panel.
  • PaintYourDragon for ESP32-S3 DMA logic.

Support & Donations

This library is developed as a free open-source personal project. To support ongoing development or help fund hardware panel purchases, see this discussion thread or visit mrcodetastic on GitHub.

Music

An AI-generated song about this library: Listen on Suno 😊

It's better in real life

评论

暂无评论