Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
- #include "FreeSansBold9pt7b.h"
- #include <Adafruit_GFX.h>
- // Define the panel dimensions and configuration
- #define MATRIX_WIDTH 64
- #define MATRIX_HEIGHT 32
- #define MATRIX_CHAIN_LENGTH 1 // Number of panels chained horizontally
- // Define the pin mapping for your specific setup
- // These are default pins, adjust if your wiring differs
- #define R1_PIN 19
- #define G1_PIN 13
- #define B1_PIN 18
- #define R2_PIN 5
- #define G2_PIN 12
- #define B2_PIN 17
- #define A_PIN 16
- #define B_PIN 14
- #define C_PIN 4
- #define D_PIN 27
- #define E_PIN -1 // Use -1 for 1/16 scan panels (like 64x32), or a valid pin for 1/32 scan (like 64x64)
- #define LAT_PIN 21
- #define OE_PIN 15
- #define CLK_PIN 2
- // Create the pin configuration structure
- 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
- };
- // Create the matrix configuration structure
- HUB75_I2S_CFG mxconfig(
- MATRIX_WIDTH,
- MATRIX_HEIGHT,
- MATRIX_CHAIN_LENGTH,
- _pins);
- // Declare the MatrixPanel_I2S_DMA object
- MatrixPanel_I2S_DMA *dma_display = nullptr;
- void setup() {
- Serial.begin(115200);
- Serial1.begin(9600, SERIAL_8N1, 35, 23);
- // Initialize the display
- dma_display = new MatrixPanel_I2S_DMA(mxconfig);
- dma_display->begin();
- // Set brightness (adjust as needed, 32 or lower is often good for a single 64x32 panel)
- dma_display->setPanelBrightness(32);
- // Clear the display
- dma_display->fillScreen(dma_display->color565(0, 0, 0)); // Black
- }
- void loop() {
- // Example: Display scrolling text
- while (Serial1.available()) {
- Serial.write(Serial1.read());
- }
- dma_display->fillScreen(dma_display->color565(0, 0, 0)); // Clear screen
- dma_display->setTextWrap(false); // No text wrapping
- dma_display->setFont(&FreeSansBold9pt7b); // Example font, requires Adafruit_GFX library with fonts
- dma_display->setTextColor(dma_display->color565(255, 255, 0)); // Yellow text
- for (int x = MATRIX_WIDTH; x > -150; x--) { // Scroll text from right to left
- dma_display->fillScreen(dma_display->color565(0, 0, 0));
- dma_display->setCursor(x, 15); // Adjust Y-position as needed
- dma_display->print("Hello, ESP32!");
- delay(30); // Adjust scroll speed
- }
- delay(1000); // Pause after scrolling
- }
Advertisement
Add Comment
Please, Sign In to add comment