### 1/4 Scan Panel Example (Not Working) Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md Example for using the library with a 32x16 1/4 Scan LED Matrix Panel. Custom coordinate remapping is required, and this example is noted as NOT WORKING. ```cpp #include #include // Define the matrix dimensions and options for a 1/4 scan panel #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 #define SCAN_RATE 4 // 1/4 scan // Pin definitions (adjust as needed) #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 // Create a MatrixPanel object MatrixPanel_DMA *matrix; void setup() { Serial.begin(115200); // Initialize the matrix panel with 1/4 scan rate // Note: Custom coordinate remapping might be needed for correct display. matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN, SCAN_RATE); matrix->begin(); matrix->clear(); // Example: Draw a red square (may not display correctly due to remapping issues) matrix->fillRect(5, 5, 10, 10, matrix->color565(255, 0, 0)); } void loop() { // Nothing to do in the loop for this example delay(1000); } ``` -------------------------------- ### Chain Multiple LED Matrix Panels Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md Demonstrates how to chain multiple LED Matrix Panels together to create a larger display using the 'VirtualMatrixPanel' class. Refer to the example's README for detailed setup instructions. ```cpp #include #include #include // Define the dimensions of individual panels #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 // Define the total number of panels and their arrangement #define NUM_PANELS_X 2 // Number of panels horizontally #define NUM_PANELS_Y 1 // Number of panels vertically // Define the matrix dimensions and options for the first panel #define PANEL1_R1_PIN 22 #define PANEL1_G1_PIN 21 #define PANEL1_B1_PIN 19 #define PANEL1_R2_PIN 18 #define PANEL1_G2_PIN 5 #define PANEL1_B2_PIN 17 #define PANEL1_CLK_PIN 27 #define PANEL1_LAT_PIN 26 #define PANEL1_OE_PIN 25 #define PANEL1_ROW1_PIN 15 #define PANEL1_ROW2_PIN 16 #define PANEL1_ROW3_PIN 4 #define PANEL1_ROW4_PIN 0 // Define the matrix dimensions and options for the second panel (if applicable) // For simplicity, assuming the second panel uses the same pins as the first in this example. // In a real scenario, you might need different pins or a different setup. #define PANEL2_R1_PIN 22 #define PANEL2_G1_PIN 21 #define PANEL2_B1_PIN 19 #define PANEL2_R2_PIN 18 #define PANEL2_G2_PIN 5 #define PANEL2_B2_PIN 17 #define PANEL2_CLK_PIN 27 #define PANEL2_LAT_PIN 26 #define PANEL2_OE_PIN 25 #define PANEL2_ROW1_PIN 15 #define PANEL2_ROW2_PIN 16 #define PANEL2_ROW3_PIN 4 #define PANEL2_ROW4_PIN 0 // Create a VirtualMatrixPanel object VirtualMatrixPanel *matrix; void setup() { Serial.begin(115200); // Initialize the first panel MatrixPanel_DMA *panel1 = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL1_R1_PIN, PANEL1_G1_PIN, PANEL1_B1_PIN, PANEL1_R2_PIN, PANEL1_G2_PIN, PANEL1_B2_PIN, PANEL1_CLK_PIN, PANEL1_LAT_PIN, PANEL1_OE_PIN, PANEL1_ROW1_PIN, PANEL1_ROW2_PIN, PANEL1_ROW3_PIN, PANEL1_ROW4_PIN); panel1->begin(); panel1->clear(); // Initialize the second panel (if applicable) MatrixPanel_DMA *panel2 = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL2_R1_PIN, PANEL2_G1_PIN, PANEL2_B1_PIN, PANEL2_R2_PIN, PANEL2_G2_PIN, PANEL2_B2_PIN, PANEL2_CLK_PIN, PANEL2_LAT_PIN, PANEL2_OE_PIN, PANEL2_ROW1_PIN, PANEL2_ROW2_PIN, PANEL2_ROW3_PIN, PANEL2_ROW4_PIN); panel2->begin(); panel2->clear(); // Create the VirtualMatrixPanel and add the individual panels matrix = new VirtualMatrixPanel(NUM_PANELS_X, NUM_PANELS_Y); matrix->addPanel(panel1, 0, 0); matrix->addPanel(panel2, 1, 0); // Example: Draw a line across the chained panels matrix->drawLine(0, 0, NUM_PANELS_X * PANEL_WIDTH - 1, PANEL_HEIGHT - 1, matrix->color565(255, 0, 0)); } void loop() { // Nothing to do in the loop for this example delay(1000); } ``` -------------------------------- ### Initialize FM6126/FM6126A Panels Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md Example demonstrating how to initialize FM6126 or FM6126A type LED panels using the library. Ensure correct pin definitions for your specific panel. ```cpp #include #include // Define the matrix dimensions and options for FM6126/FM6126A #define PANEL_WIDTH 64 #define PANEL_HEIGHT 32 #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 #define PANEL_ROW5_PIN 2 // FM6126/FM6126A specific row pin // Create a MatrixPanel object MatrixPanel_DMA *matrix; void setup() { Serial.begin(115200); // Initialize the matrix panel with FM6126/FM6126A specific pins matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN, PANEL_ROW5_PIN); matrix->begin(); matrix->clear(); // Example: Draw a red square matrix->fillRect(10, 10, 20, 20, matrix->color565(255, 0, 0)); } void loop() { // Nothing to do in the loop for this example delay(1000); } ``` -------------------------------- ### Simple Test Shapes for ESP32 Matrix Panel Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md An introductory example for new users to display basic shapes on the LED matrix. No special setup is required beyond basic library initialization. ```cpp #include #include // Define the matrix dimensions and options #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 // Create a MatrixPanel object MatrixPanel_DMA *matrix; void setup() { Serial.begin(115200); // Initialize the matrix panel matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); matrix->begin(); matrix->clear(); // Draw basic shapes matrix->drawPixel(1, 1, matrix->color565(255, 0, 0)); // Red pixel matrix->drawLine(0, 0, PANEL_WIDTH - 1, PANEL_HEIGHT - 1, matrix->color565(0, 255, 0)); // Green line matrix->drawRect(5, 5, 10, 10, matrix->color565(0, 0, 255)); // Blue rectangle matrix->fillRect(15, 5, 10, 10, matrix->color565(255, 255, 0)); // Yellow filled rectangle } void loop() { // Nothing to do in the loop for this example delay(1000); } ``` -------------------------------- ### 1/8 Scan Panel Example Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md Example for using the library with a 64x32 1/8 Scan LED Matrix Panel. Custom coordinate remapping is required for correct display. ```cpp #include #include // Define the matrix dimensions and options for a 1/8 scan panel #define PANEL_WIDTH 64 #define PANEL_HEIGHT 32 #define SCAN_RATE 8 // 1/8 scan // Pin definitions (adjust as needed) #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 #define PANEL_ROW5_PIN 2 // Required for 1/8 scan #define PANEL_ROW6_PIN 12 // Required for 1/8 scan #define PANEL_ROW7_PIN 13 // Required for 1/8 scan #define PANEL_ROW8_PIN 14 // Required for 1/8 scan // Create a MatrixPanel object MatrixPanel_DMA *matrix; void setup() { Serial.begin(115200); // Initialize the matrix panel with 1/4 scan rate // Note: Custom coordinate remapping might be needed for correct display. matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN, PANEL_ROW5_PIN, PANEL_ROW6_PIN, PANEL_ROW7_PIN, PANEL_ROW8_PIN, SCAN_RATE); matrix->begin(); matrix->clear(); // Example: Draw a blue square (may not display correctly due to remapping issues) matrix->fillRect(10, 10, 20, 20, matrix->color565(0, 0, 255)); } void loop() { // Nothing to do in the loop for this example delay(1000); } ``` -------------------------------- ### Install Library via PlatformIO Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/README.md Install this library into your PlatformIO projects' lib/ folder or add it to your platformio.ini file. ```ini [lib_deps] https://github.com/mrcodetastic/ESP32-HUB75-MatrixPanel-DMA.git ``` -------------------------------- ### Aurora Demo for ESP32 Matrix Panel Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md A simple example demonstrating various animated effects, including aurora-like visuals. This is a good starting point for exploring dynamic animations. ```cpp #include #include // Define the matrix dimensions and options #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 // Create a MatrixPanel object MatrixPanel_DMA *matrix; // Aurora variables float aurora_phase = 0.0; void setup() { Serial.begin(115200); // Initialize the matrix panel matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); matrix->begin(); matrix->clear(); } void loop() { // Generate aurora effect for (int x = 0; x < PANEL_WIDTH; x++) { for (int y = 0; y < PANEL_HEIGHT; y++) { float value = sin(x * 0.1 + aurora_phase) * cos(y * 0.1 + aurora_phase); int brightness = map(value, -2.0, 2.0, 0, 255); matrix->drawPixel(x, y, matrix->color565(0, brightness, brightness)); } } aurora_phase += 0.05; delay(50); } ``` -------------------------------- ### Install Library via Arduino Library Manager Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/README.md Install this library from the Arduino Library manager. Adafruit_GFX is a required dependency. ```text Library > Manage Libraries ``` -------------------------------- ### Display Bitmap Icons on ESP32 Matrix Panel Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md A simple example showing how to display a bitmap image to the LED matrix. This requires a bitmap image file compatible with the library. ```cpp #include #include #include #include // Define the matrix dimensions and options #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 // Create a MatrixPanel object MatrixPanel_DMA *matrix; // Bitmap data (replace with your actual bitmap data) // This is a placeholder for a 32x16 bitmap const uint16_t bitmapData[] = { // ... your bitmap data here ... }; void setup() { Serial.begin(115200); // Initialize the matrix panel matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); matrix->begin(); matrix->clear(); // Display the bitmap matrix->drawBitmap(0, 0, bitmapData, PANEL_WIDTH, PANEL_HEIGHT, matrix->color565(255, 255, 255)); } void loop() { // Nothing to do in the loop for this example delay(1000); } ``` -------------------------------- ### Plasma Pattern for ESP32 Matrix Panel Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md An example for new users to display a dynamic plasma pattern. This showcases the library's ability to generate complex visual effects. ```cpp #include #include // Define the matrix dimensions and options #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 // Create a MatrixPanel object MatrixPanel_DMA *matrix; // Plasma variables int plasma_x = 0; int plasma_y = 0; void setup() { Serial.begin(115200); // Initialize the matrix panel matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); matrix->begin(); matrix->clear(); } void loop() { // Generate and display plasma pattern for (int x = 0; x < PANEL_WIDTH; x++) { for (int y = 0; y < PANEL_HEIGHT; y++) { int color = (sin(plasma_x + x) + sin(plasma_y + y) + sin(plasma_x + x + y) + sin(plasma_x - y)) * 127 + 128; matrix->drawPixel(x, y, matrix->color565(color, color, color)); } } plasma_x += 1; plasma_y += 1; delay(50); } ``` -------------------------------- ### Clone Required Repositories for ESP-IDF Project Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/esp-idf/with-gfx/README.md Clone the necessary GitHub repositories into your project's components directory. Ensure you have Git installed and configured. ```bash git clone https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git components/ESP32-HUB75-MatrixPanel-I2S-DMA git clone https://github.com/adafruit/Adafruit-GFX-Library.git components/Adafruit-GFX-Library git clone https://github.com/adafruit/Adafruit_BusIO.git components/Adafruit_BusIO git clone https://github.com/espressif/arduino-esp32.git components/arduino ``` -------------------------------- ### Display Animated GIFs on ESP32 Matrix Panel Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md Demonstrates how to display animated GIFs using Larry Bank's GIF Decoder library. This requires the GIFDecoder library to be installed. ```cpp #include #include #include #include #include // Define the matrix dimensions and options #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 // Create a MatrixPanel object MatrixPanel_DMA *matrix; // GIF Decoder object gif_decoder_t gif_decoder; void setup() { Serial.begin(115200); // Initialize the matrix panel matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); matrix->begin(); matrix->clear(); // Initialize SD card (if using SD card for GIFs) if (!SD.begin()) { Serial.println("SD Card initialization failed!"); return; } // Open the GIF file File gifFile = SD.open("/your_animation.gif"); // Replace with your GIF file name if (!gifFile) { Serial.println("Failed to open GIF file!"); return; } // Initialize the GIF decoder if (gif_decoder_open(&gif_decoder, gifFile.get_file_ptr()) != GIF_SUCCESS) { Serial.println("Failed to open GIF decoder!"); return; } } void loop() { // Decode and display each frame of the GIF while (gif_decoder_decode_frame(&gif_decoder) == GIF_SUCCESS) { for (int y = 0; y < gif_decoder.height; y++) { for (int x = 0; x < gif_decoder.width; x++) { uint16_t color = gif_decoder.frame_buffer[y * gif_decoder.width + x]; matrix->drawPixel(x, y, color); } } matrix->swapBuffers(); delay(gif_decoder.delay); } // Reset the decoder to loop the animation gif_decoder_close(&gif_decoder); File gifFile = SD.open("/your_animation.gif"); gif_decoder_open(&gif_decoder, gifFile.get_file_ptr()); } ``` -------------------------------- ### Create Virtual Display with Custom Scan Type Mapping Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/VirtualMatrixPanel/README.md Instantiate VirtualMatrixPanel_T with a custom scan type mapping for non-standard panels. This example uses a user-contributed mapping for four-scan 32-pixel high panels. ```cpp // --- Example 3: Single non-standard 1/4 Scan (Four-Scan 1/8) --- // Use an existing library user-contributed Scan Type pixel mapping using MyScanTypeMapping = ScanTypeMapping; // Create a pointer to the specific instantiation of the VirtualMatrixPanel_T class VirtualMatrixPanel_T* virtualDisp = nullptr; ``` -------------------------------- ### PlatformIO Build Flags Configuration Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/doc/BuildOptions.md Set build flags for the ESP32 HUB75 Matrix Panel DMA library in PlatformIO's .ini file. This example shows how to specify the framework, platform, library dependencies, and custom build flags. ```ini [env] framework = arduino platform = espressif32 lib_deps = ESP32 HUB75 LED MATRIX PANEL DMA Display build_flags = -DCORE_DEBUG_LEVEL=3 -DNO_GFX=1 (etc.....) ``` -------------------------------- ### Basic Test Sketch for ESP32 HUB75 Matrix Panel Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/README.md A minimal sketch to draw a single white dot. Ensure you call `begin()` before any pixel-drawing functions. This is a prerequisite for using more complex examples like PIO Test Patterns. ```cpp // Requires PlatformIO #include // Define your pin mapping here or use a predefined one // HUB75_I2S_CFG::i2s_pins _pins = { ... }; // HUB75_I2S_CFG mxconfig(PANEL_RES_X, PANEL_RES_Y, PANEL_CHAIN, _pins); // MatrixPanel_I2S_DMA *dma_display = new MatrixPanel_I2S_DMA(mxconfig); void setup() { // Initialize the display // dma_display->begin(); // Draw a single white dot in the top-left corner // dma_display->drawPixel(0, 0, dma_display->color565(255, 255, 255)); } ``` -------------------------------- ### Chained Panels Aurora Demo Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md Combines chaining multiple LED Matrix Panels with the Aurora Demo to show a large, trippy plasma animation across the combined display. Requires setup similar to ChainedPanels. ```cpp #include #include #include // Define the matrix dimensions and options #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 #define NUM_PANELS_X 2 #define NUM_PANELS_Y 1 // Pin definitions for the panels (assuming same pins for simplicity) #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 // Create a VirtualMatrixPanel object VirtualMatrixPanel *matrix; // Aurora variables float aurora_phase = 0.0; void setup() { Serial.begin(115200); // Initialize individual panels MatrixPanel_DMA *panel1 = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); panel1->begin(); panel1->clear(); MatrixPanel_DMA *panel2 = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); panel2->begin(); panel2->clear(); // Create the VirtualMatrixPanel and add the individual panels matrix = new VirtualMatrixPanel(NUM_PANELS_X, NUM_PANELS_Y); matrix->addPanel(panel1, 0, 0); matrix->addPanel(panel2, 1, 0); } void loop() { // Generate aurora effect across all panels for (int x = 0; x < NUM_PANELS_X * PANEL_WIDTH; x++) { for (int y = 0; y < PANEL_HEIGHT; y++) { float value = sin(x * 0.1 + aurora_phase) * cos(y * 0.1 + aurora_phase); int brightness = map(value, -2.0, 2.0, 0, 255); matrix->drawPixel(x, y, matrix->color565(0, brightness, brightness)); } } aurora_phase += 0.05; delay(50); } ``` -------------------------------- ### Adafruit MatrixPortal S3 Pin Mapping for HUB75 Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/README.md Adapt pin definitions from Adafruit's Protomatter library for use with the ESP32 HUB75 MatrixPanel DMA library. This example shows the conversion for a MatrixPortal S3 board. ```cpp #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}; // Module configuration HUB75_I2S_CFG mxconfig( PANEL_RES_X, // module width PANEL_RES_Y, // module height PANEL_CHAIN, // Chain length _pins // Pin mapping ); ``` -------------------------------- ### Build and Upload with Arduino Framework Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/PIO_TestPatterns/README.md Use this command to build and upload the project with the Arduino framework using PlatformIO. ```bash pio run -t upload ``` -------------------------------- ### Build and Upload with ESP32 IDF and Arduino Component Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/PIO_TestPatterns/README.md Use this command to build and upload the project using ESP32 IDF with the Arduino component via PlatformIO. ```bash pio run -t upload -e idfarduino ``` -------------------------------- ### Compile Virtual Matrix Panel App Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/testing/README.md Compile the virtual matrix panel simulation application using g++. ```bash g++ -o myapp.exe virtual.cpp ``` -------------------------------- ### Combining Multiple Compile Options Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/CMakeLists.txt Demonstrates how to apply multiple compile options simultaneously, such as disabling GFX and fast functions, by listing them within a single `target_compile_options` command. ```cmake # You can also use multiple options like this # target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX -DNO_FAST_FUNCTIONS) ``` -------------------------------- ### Arduino IDE Build Options Configuration Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/doc/BuildOptions.md Configure compile-time options for the ESP32 HUB75 Matrix Panel DMA library in the Arduino IDE by creating a 'build_opt.h' file. This file should contain build options on separate lines, such as '-DNO_GFX=1'. ```c -DNO_GFX=1 ``` -------------------------------- ### Component Registration and Dependency Linking Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/CMakeLists.txt Registers the component's source files and include directories. It then iterates through the build dependencies, ensuring each is linked to the component's library, using `target_link_libraries` as dependencies might be conditional on `sdkconfig`. ```cmake idf_component_register (SRCS "src/platforms/esp32/esp32_i2s_parallel_dma.cpp" "src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp" "src/ESP32-HUB75-MatrixPanel-leddrivers.cpp" ${extra_srcs} INCLUDE_DIRS "./src" ) # Dependencies cannot be added to the REQUIRES argument of `idf_component_register` because (according to the build process # listed at https://docs.espressif.com/projects/esp-idf/en/v4.2/esp32/api-guides/build-system.html#build-process) # `idf_component_register` is processed during the "Enumeration" stage which happens before the sdkconfig file is loaded # in the "Processing" stage. So if dependencies are going to be loaded based on certain CONFIG_* variables we must # use `target_link_libraries` instead. This is the method used by Arduino's CMakeLists.txt file. idf_build_get_property(components BUILD_COMPONENTS) foreach(component_name IN LISTS build_dependencies) if (NOT ${component_name} IN_LIST components) message(FATAL_ERROR "Missing component: ${component_name}") endif() idf_component_get_property(lib_name ${component_name} COMPONENT_LIB) target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name}) endforeach() ``` -------------------------------- ### Project CMakeLists.txt Configuration Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/esp-idf/without-gfx/CMakeLists.txt This is the primary CMakeLists.txt file for the project. It sets the minimum CMake version, includes the ESP-IDF build system, and defines the project name. This file is essential for CMake to understand how to build the project. ```cmake cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(without-gfx) ``` -------------------------------- ### Project CMakeLists.txt Configuration Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/esp-idf/with-gfx/CMakeLists.txt This is the main CMakeLists.txt file for an ESP-IDF project. It sets the minimum CMake version, includes the ESP-IDF build system, and defines the project name. Ensure the IDF_PATH environment variable is set correctly. ```cmake cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(with-gfx) ``` -------------------------------- ### Runtime GPIO Pin Mapping for HUB75 Matrix Panel Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/README.md Configure GPIO pins at runtime by providing a custom pin mapping structure during class initialization. Ensure all necessary pins for your panel type are defined. ```cpp #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, like 64x64px. Any available pin would do, i.e. 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); ``` -------------------------------- ### Set Build Dependencies Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/CMakeLists.txt Lists the required build dependencies based on the target architecture and configuration. This ensures necessary libraries like Arduino or esp_lcd are included. ```cmake if(ARDUINO_ARCH_ESP32 OR CONFIG_ESP32_HUB75_USE_GFX) list(APPEND build_dependencies arduino Adafruit-GFX-Library) else() list(APPEND build_dependencies esp_lcd driver) endif() ``` -------------------------------- ### Register App Sources with CMake Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/PIO_TestPatterns/src/CMakeLists.txt This CMakeLists.txt snippet is automatically generated for projects without a default CMakeLists.txt. It uses FILE(GLOB_RECURSE) to find all source files in the 'src' directory and then registers them with idf_component_register. ```cmake # This file was automatically generated for projects # without default 'CMakeLists.txt' file. FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.* ) idf_component_register(SRCS ${app_sources}) ``` -------------------------------- ### Pixel Mapping Test for Four Scan Panels Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/Pixel_Mapping_Test/README.md Run this initial code on a single panel to check if rows are filled sequentially from left to right and top to bottom. No modifications are needed if the output is as expected. ```c++ #include #include // Example usage for a 64x32 panel with 1/8 scan rate // Adjust these parameters based on your specific panel const int PANEL_WIDTH = 64; const int PANEL_HEIGHT = 32; const int SCAN_RATE = 8; MatrixPanel_DMA *matrix; void setup() { Serial.begin(115200); matrix = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, SCAN_RATE); matrix->begin(); matrix->setPixel(0, 0, matrix->color565(255, 0, 0)); // Red pixel at top-left matrix->setPixel(PANEL_WIDTH - 1, PANEL_HEIGHT - 1, matrix->color565(0, 0, 255)); // Blue pixel at bottom-right // Fill the rest of the panel with green for (int x = 1; x < PANEL_WIDTH - 1; x++) { for (int y = 1; y < PANEL_HEIGHT - 1; y++) { matrix->setPixel(x, y, matrix->color565(0, 255, 0)); } } matrix->swapBuffers(); } void loop() { // Nothing to do in loop for this example } ``` -------------------------------- ### Project Definition Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/CMakeLists.txt Defines the project name for the build system. This is a standard CMake command to set the project name. ```cmake project(ESP32-HUB75-MatrixPanel-I2S-DMA) ``` -------------------------------- ### Platform-Specific Source Files for ESP32-S3 Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/CMakeLists.txt Includes platform-specific source files for the ESP32-S3 target, particularly for the GDMA parallel 16-bit interface. Ensures the 'esp_lcd' dependency is met if not already present. ```cmake if(${target} STREQUAL "esp32s3") list(APPEND extra_srcs src/platforms/${target}/gdma_lcd_parallel16.cpp) # Required by gdma_lcd_parallel16.cpp if (NOT esp_lcd IN_LIST build_dependencies) list(APPEND build_dependencies esp_lcd) endif() endif() ``` -------------------------------- ### Chained Panels with FastLED Screen Buffer Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/README.md Utilizes the 'VirtualMatrixPanel' class along with a FastLED off-screen pixel buffer for advanced graphical effects on chained displays. Requires FastLED library. ```cpp #include #include #include #include // Define the matrix dimensions and options #define PANEL_WIDTH 32 #define PANEL_HEIGHT 16 #define NUM_PANELS_X 2 #define NUM_PANELS_Y 1 // Pin definitions for the panels (assuming same pins for simplicity) #define PANEL_R1_PIN 22 #define PANEL_G1_PIN 21 #define PANEL_B1_PIN 19 #define PANEL_R2_PIN 18 #define PANEL_G2_PIN 5 #define PANEL_B2_PIN 17 #define PANEL_CLK_PIN 27 #define PANEL_LAT_PIN 26 #define PANEL_OE_PIN 25 #define PANEL_ROW1_PIN 15 #define PANEL_ROW2_PIN 16 #define PANEL_ROW3_PIN 4 #define PANEL_ROW4_PIN 0 // Create a VirtualMatrixPanel object VirtualMatrixPanel *matrix; // FastLED buffer CRGB *leds; void setup() { Serial.begin(115200); // Initialize individual panels MatrixPanel_DMA *panel1 = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); panel1->begin(); panel1->clear(); MatrixPanel_DMA *panel2 = new MatrixPanel_DMA(PANEL_WIDTH, PANEL_HEIGHT, PANEL_R1_PIN, PANEL_G1_PIN, PANEL_B1_PIN, PANEL_R2_PIN, PANEL_G2_PIN, PANEL_B2_PIN, PANEL_CLK_PIN, PANEL_LAT_PIN, PANEL_OE_PIN, PANEL_ROW1_PIN, PANEL_ROW2_PIN, PANEL_ROW3_PIN, PANEL_ROW4_PIN); panel2->begin(); panel2->clear(); // Create the VirtualMatrixPanel and add the individual panels matrix = new VirtualMatrixPanel(NUM_PANELS_X, NUM_PANELS_Y); matrix->addPanel(panel1, 0, 0); matrix->addPanel(panel2, 1, 0); // Initialize FastLED buffer int total_width = NUM_PANELS_X * PANEL_WIDTH; int total_height = PANEL_HEIGHT; leds = new CRGB[total_width * total_height]; FastLED.addLeds(leds, total_width * total_height); } void loop() { // Example: Fill the FastLED buffer with a color and display it fill_solid(leds, NUM_PANELS_X * PANEL_WIDTH * PANEL_HEIGHT, CRGB::Red); FastLED.show(); // Copy FastLED buffer to the matrix panel for (int x = 0; x < NUM_PANELS_X * PANEL_WIDTH; x++) { for (int y = 0; y < PANEL_HEIGHT; y++) { matrix->drawPixel(x, y, matrix->color565(leds[y * (NUM_PANELS_X * PANEL_WIDTH) + x].red, leds[y * (NUM_PANELS_X * PANEL_WIDTH) + x].green, leds[y * (NUM_PANELS_X * PANEL_WIDTH) + x].blue)); } } delay(100); } ``` -------------------------------- ### Conditional Compilation for GFX and ESP32-S3 Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/CMakeLists.txt Sets compile options based on whether GFX support is enabled or if the target is ESP32-S3. It explicitly defines '-DNO_GFX' if GFX is not used and includes a commented-out option for PSRAM framebuffer on ESP32-S3. ```cmake # esp-idf does not have any GFX library support yet, so we need to define NO_GFX if(ARDUINO_ARCH_ESP32 OR CONFIG_ESP32_HUB75_USE_GFX) else() target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX) if(${target} STREQUAL "esp32s3") # Don't enable PSRAM based framebuffer just because it's an S3. # This is an advanced option and should only be used with an S3 with Octal-SPI RAM. # target_compile_options(${COMPONENT_TARGET} PUBLIC -DSPIRAM_FRAMEBUFFER) target_compile_options(${COMPONENT_TARGET} PUBLIC) endif() endif() ``` -------------------------------- ### Set Panel Brightness (ESP32) Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/README.md Adjusts the brightness of the LED matrix panel. The value should be between 0 (black screen) and 255 (maximum brightness). ```cpp void setup() { Serial.begin(115200); dma_display->begin(); // setup the LED matrix dma_display->setBrightness8(192); //0-255 dma_display->clearScreen(); } ``` -------------------------------- ### Swapping Row Blocks for Correct Order Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/Pixel_Mapping_Test/README.md If the top row is not the first to be filled, swap the expressions for the '1st, 3rd "block" of rows' with the '2nd, 4th "block" of rows'. This corrects the order in which rows are displayed. ```c++ // Example conceptual swap: // Original: // row_block_1 = ...; // row_block_2 = ...; // row_block_3 = ...; // row_block_4 = ...; // // Swapped: // row_block_1 = ...; // 2nd block // row_block_2 = ...; // 1st block // row_block_3 = ...; // 4th block // row_block_4 = ...; // 3rd block ``` -------------------------------- ### Configure Other Driver Based LED Matrix Panels Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/4_OtherShiftDriverPanel/README.md Specify the driver for other supported LED matrix panels by assigning the appropriate enum value to mxconfig.driver. Ensure your panel chipset is compatible and check for any special reset sequence requirements. ```cpp mxconfig.driver = HUB75_I2S_CFG::FM6126A; ``` ```cpp mxconfig.driver = HUB75_I2S_CFG::ICN2038S; ``` ```cpp mxconfig.driver = HUB75_I2S_CFG::FM6124; ``` ```cpp mxconfig.driver = HUB75_I2S_CFG::MBI5124; ``` -------------------------------- ### Supported Four-Scan Modes Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/VirtualMatrixPanel/README.md Enumerates the predefined scan type mappings available for four-scan LED panels. ```cpp FOUR_SCAN_32PX_HIGH, ///< Four-scan mode, 32-pixel high panels. FOUR_SCAN_16PX_HIGH, ///< Four-scan mode, 16-pixel high panels. FOUR_SCAN_64PX_HIGH, ///< Four-scan mode, 64-pixel high panels. FOUR_SCAN_40PX_HIGH ///< Four-scan mode, 40-pixel high panels. ``` -------------------------------- ### Configure Clock Phase (ESP32) Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/README.md Adjusts the clock phase setting to correct pixel alignment or ghosting issues. Set `mxconfig.clkphase` to `false` for panels that clock data on a negative edge. ```cpp mxconfig.clkphase = false; ``` -------------------------------- ### Adjusting Pixel Base for Partial Row Filling Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/Pixel_Mapping_Test/README.md If your panel fills rows in segments (e.g., 4, 8, or 16 pixels), modify line 45 of the code to set the correct pixel base. This ensures entire rows are filled properly. ```c++ // Example modification for line 45 (conceptual): // matrix->setPixelBase(8); // Assuming a pixel base of 8 ``` -------------------------------- ### Register ESP32 Hub75 Matrix Panel DMA Component Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/esp-idf/without-gfx/main/CMakeLists.txt Use this function to register the component, specifying source and include directories, and its dependencies. Ensure the ESP32-HUB75-MatrixPanel-I2S-DMA component is listed as a requirement. ```c idf_component_register( SRC_DIRS "." ${SRCDIRS} INCLUDE_DIRS ${INCLUDEDIRS} REQUIRES ESP32-HUB75-MatrixPanel-I2S-DMA ) ``` -------------------------------- ### Register ESP32 Hub75 Matrix Panel DMA Component Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/esp-idf/with-gfx/main/CMakeLists.txt Use this function to register the component, specifying source and include directories, and its dependencies. Ensure the ESP32-HUB75-MatrixPanel-I2S-DMA component is listed as a requirement. ```c idf_component_register( SRC_DIRS "." ${SRCDIRS} INCLUDE_DIRS ${INCLUDEDIRS} REQUIRES ESP32-HUB75-MatrixPanel-I2S-DMA ) ``` -------------------------------- ### Clone HUB75 Matrix Panel DMA Component Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/esp-idf/without-gfx/README.md Clone the ESP32-HUB75-MatrixPanel-I2S-DMA repository into the components directory of your ESP-IDF project. ```bash git clone https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git components/ESP32-HUB75-MatrixPanel-I2S-DMA ``` -------------------------------- ### Convert BMP to Hex using bmp2hex.py Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/examples/BitmapIcons/README.md Use the bmp2hex.py script to convert a 1-bit color BMP image into a hex string suitable for embedding in code. Ensure the bitmap resolution matches your display configuration. ```bash bmp2hex.py -i -x ``` -------------------------------- ### Set Latch Blanking (ESP32) Source: https://github.com/mrcodetastic/esp32-hub75-matrixpanel-dma/blob/master/README.md Configures the latch blanking period to mitigate image ghosting issues. The value can range from 1 to 4, with 1 being the default. ```cpp dma_display->setLatBlanking(2); ```