mikroavr

running text p5

Aug 20th, 2026
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
  2. #include "FreeSansBold9pt7b.h"
  3. #include <Adafruit_GFX.h>
  4.  
  5. // Define the panel dimensions and configuration
  6. #define MATRIX_WIDTH 64
  7. #define MATRIX_HEIGHT 32
  8. #define MATRIX_CHAIN_LENGTH 1  // Number of panels chained horizontally
  9.  
  10. // Define the pin mapping for your specific setup
  11. // These are default pins, adjust if your wiring differs
  12. #define R1_PIN 19
  13. #define G1_PIN 13
  14. #define B1_PIN 18
  15. #define R2_PIN 5
  16. #define G2_PIN 12
  17. #define B2_PIN 17
  18. #define A_PIN 16
  19. #define B_PIN 14
  20. #define C_PIN 4
  21. #define D_PIN 27
  22. #define E_PIN -1  // Use -1 for 1/16 scan panels (like 64x32), or a valid pin for 1/32 scan (like 64x64)
  23. #define LAT_PIN 21
  24. #define OE_PIN 15
  25. #define CLK_PIN 2
  26.  
  27. // Create the pin configuration structure
  28. HUB75_I2S_CFG::i2s_pins _pins = {
  29.   R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN,
  30.   A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN
  31. };
  32.  
  33. // Create the matrix configuration structure
  34. HUB75_I2S_CFG mxconfig(
  35.   MATRIX_WIDTH,
  36.   MATRIX_HEIGHT,
  37.   MATRIX_CHAIN_LENGTH,
  38.   _pins);
  39.  
  40. // Declare the MatrixPanel_I2S_DMA object
  41. MatrixPanel_I2S_DMA *dma_display = nullptr;
  42.  
  43. void setup() {
  44.   Serial.begin(115200);
  45.   Serial1.begin(9600, SERIAL_8N1, 35, 23);
  46.  
  47.   // Initialize the display
  48.   dma_display = new MatrixPanel_I2S_DMA(mxconfig);
  49.   dma_display->begin();
  50.  
  51.   // Set brightness (adjust as needed, 32 or lower is often good for a single 64x32 panel)
  52.   dma_display->setPanelBrightness(32);
  53.  
  54.   // Clear the display
  55.   dma_display->fillScreen(dma_display->color565(0, 0, 0));  // Black
  56. }
  57.  
  58. void loop() {
  59.   // Example: Display scrolling text
  60.  
  61.   while (Serial1.available()) {
  62.     Serial.write(Serial1.read());
  63.   }
  64.  
  65.   dma_display->fillScreen(dma_display->color565(0, 0, 0));        // Clear screen
  66.   dma_display->setTextWrap(false);                                // No text wrapping
  67.   dma_display->setFont(&FreeSansBold9pt7b);                       // Example font, requires Adafruit_GFX library with fonts
  68.   dma_display->setTextColor(dma_display->color565(255, 255, 0));  // Yellow text
  69.  
  70.   for (int x = MATRIX_WIDTH; x > -150; x--) {  // Scroll text from right to left
  71.     dma_display->fillScreen(dma_display->color565(0, 0, 0));
  72.     dma_display->setCursor(x, 15);  // Adjust Y-position as needed
  73.     dma_display->print("Hello, ESP32!");
  74.     delay(30);  // Adjust scroll speed
  75.   }
  76.  
  77.   delay(1000);  // Pause after scrolling
  78. }
Advertisement
Add Comment
Please, Sign In to add comment