mrcodetastic / ESP32-HUB75-MatrixPanel-DMA

An Adafruit GFX Compatible Library for the ESP32, ESP32-S2, ESP32-S3 to drive HUB75 LED matrix panels using DMA for high refresh rates. Supports panel chaining.
MIT License
951 stars 211 forks source link

Please help to display simple scrolling text on P10 LED matrix chained 32x16 LED matrix #428

Closed abby3010 closed 1 year ago

abby3010 commented 1 year ago

I'm trying to create a project using 3 matrix panels of 32x16 P10 LED panels chained together.

I want to take 3 inputs from Bluetooth and display them on the LED panels. Input 1: Single letter (In image - Letter "M") Input 2: Single letter (In image - Letter "8") Input 3: An extended text (In image - String "Brahmanada" - cropped to "Brahma" only)

I managed to display the first two inputs successfully as they are only single letters. However, I want the text to be scrolled if it does not fit in the given space. (If the string is small and fits in, then do not scroll)

I searched and tried out a lot but cannot make any code work for scrolling the text! I referred to @mrRobot62 's repository as well, but no luck! Then I figured out that his contribution is merged into this repo.

It would be very helpful if someone can put even a simple example of scrolling text using this library on 32x16 chained panels for noobs like me!

Sharing below the partial output of what I'm trying to achieve.

image

#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>

#define PANEL_RES_X 32      // Number of pixels wide of each INDIVIDUAL panel module. 
#define PANEL_RES_Y 16     // Number of pixels tall of each INDIVIDUAL panel module.
#define PANEL_CHAIN 3     // Total number of panels chained one to another

//MatrixPanel_I2S_DMA dma_display;
MatrixPanel_I2S_DMA *dma_display = nullptr;

uint16_t myBLACK = dma_display->color565(0, 0, 0);
uint16_t myWHITE = dma_display->color565(255, 255, 255);
uint16_t myRED = dma_display->color565(255, 0, 0);
uint16_t myGREEN = dma_display->color565(0, 255, 0);
uint16_t myBLUE = dma_display->color565(0, 0, 255);

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
// From: https://gist.github.com/davidegironi/3144efdc6d67e5df55438cc3cba613c8
uint16_t colorWheel(uint8_t pos) {
  if(pos < 85) {
    return dma_display->color565(pos * 3, 255 - pos * 3, 0);
  } else if(pos < 170) {
    pos -= 85;
    return dma_display->color565(255 - pos * 3, 0, pos * 3);
  } else {
    pos -= 170;
    return dma_display->color565(0, pos * 3, 255 - pos * 3);
  }
}

void drawText(int colorWheelOffset)
{
  dma_display->setTextSize(2);     // size 1 == 8 pixels high
  dma_display->setTextWrap(true); // Don't wrap at end of line - will do ourselves

  // dma_display->setCursor(5, 0);    // start at top left, with 8 pixel of spacing
  uint8_t w = 0;
  const char *str = "Brahmananda Technologies";
  for (w=0; w<strlen(str); w++) {
    dma_display->setTextColor(colorWheel((w*32)+colorWheelOffset));
    dma_display->print(str[w]);
  }
}

void setup() {

  // Module configuration
  HUB75_I2S_CFG mxconfig(
    PANEL_RES_X,   // module width
    PANEL_RES_Y,   // module height
    PANEL_CHAIN    // Chain length
  );

  //mxconfig.gpio.e = 18;
  //mxconfig.clkphase = false;
  //mxconfig.driver = HUB75_I2S_CFG::FM6126A;

  // Display Setup
  dma_display = new MatrixPanel_I2S_DMA(mxconfig);
  dma_display->begin();
  dma_display->setBrightness8(90); //0-255
  dma_display->clearScreen();

  drawText(0);

  // draw a box in the right side to display the two single characters
  dma_display->drawRect(79, 0, dma_display->width(), dma_display->height(), dma_display->color444(0, 0, 0));
  delay(3000);

  dma_display->setTextSize(2);   // 1 == 8 pixels ; 2 == 16 pixels

  // Set cursor and draw first character
  dma_display->setCursor(80, 0); 
  dma_display->print("8");
  // dma_display->print(" ");
  dma_display->print("M");

}

void loop() {

}
mrcodetastic commented 1 year ago

Why is setTextWrap = true

Shouldn't it be false?

abby3010 commented 1 year ago

I was just trying out things there!

abby3010 commented 1 year ago

Is it possible to put up a simple scroll text example for a series of 32x16 chained panels?

mrcodetastic commented 1 year ago

I think your best bet would be to ask in the adafruit gfx library git account or ChatGPT. This library simply does the electrical pixel on the panel bit.

board707 commented 1 year ago

Is it possible to put up a simple scroll text example

@abby3010 , Your scroll is not "simple', because you are using a different colors for each letter. But I think it can be resolved without specific "scroll" code - by sequentially drawing the text with a shift in the starting position.

tsctrl commented 1 year ago

interesting, my 32x16 P10 panel was not working out of the box with this library. @abby3010 could you take picture of the label at the back of the panel? maybe the ic used too. wondering which P10 panel did work. if its 1/8 still require some mappings too. most of panel p10 is 1/8 or 1/4 from my findings.

looks bad asking for remapping for my panels from @mrfaptastic if actually the compatible one exists...

board707 commented 1 year ago

32x16 1/8 panels does not require specific mapping

abby3010 commented 1 year ago

Is it possible to put up a simple scroll text example

Even single color for the text is fine for me!

mrRobot62 commented 1 year ago

Hi I remember, it was a little challenge to implement my solution for my 32x16 Display. That was the reason, that I re-implemented some graphical stuff again. As example the write and scrolling text behavior.

maybe it's possible for you, to go the same way as I Implement your own functions.

You have to know, inside memory a font char is turned in 90deg cw.

board707 commented 1 year ago

You have to know, inside memory a font char is turned in 90deg cw.

In which library? AdafruitGFX fonts are not turned.

board707 commented 1 year ago

Even single color for the text is fine for me!

To scroll text, say, right - print the message, wait 30mS, clear the screen and print the message one pixel right...and so on

abby3010 commented 1 year ago

Hey everyone! I was able to make it happen! 🙌

I'll definitely try to create a pull request on putting an example for scroll text using chained panels with VirtualMatrixPanel implementation.

Thank you for all of your support! 😊✨

jfbvm commented 1 year ago

Hey everyone! I was able to make it happen! 🙌

I'll definitely try to create a pull request on putting an example for scroll text using chained panels with VirtualMatrixPanel implementation.

Thank you for all of your support! 😊✨

Hi abby3010, Could you please post here the function of scrolling text, It would be a great help!!

priya2212 commented 10 months ago

@abby3010 , It would be great if you share the changes here to make the scroll work. I am also stuck in scrolling text development.

board707 commented 10 months ago

@priya2212 What are the problems with scrolling? Can you display still text on your panels?

priya2212 commented 10 months ago

@board707 , Sorry for delay in response. Yes, I am able to display the still text with some pixels shifting. I am using this piece of code but I see extreme flickering in the display -

    FourScanPanel->flipDMABuffer();
    FourScanPanel->fillScreen(0);
    FourScanPanel->setCursor(w_text, y);
    FourScanPanel->setTextColor(FourScanPanel->color444(0, 0, 15));
    FourScanPanel->print(HELL);
    w_text--;
    if (w_text + len == 0)
    {
      w_text = 128;
    } 
mrcodetastic commented 10 months ago

Add a small delay between flipdmabuffer and clear screen.

priya2212 commented 10 months ago

Added that, doesn't make any difference. Original Post is posted here - https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA/issues/539

mrcodetastic commented 10 months ago

Create you own graphics buffer, draw to that, and once done, draw to this library by iterating through all rows and columns in the graphics buffer.

No need to use double buffering then.