Esp32 on P8 RGB LED

My code that works on a P10 RGB LED to display text isn't working on P8 RGB LED. I am using a chain of 3 modules i.e. total 96 by 16 pixels. P8 panel seems to have a generic chip, and panel specs on back reads P8 2727 4S V2.0

Display on P8 is all garbled.

Pls help!

Welcome to the forum

Please post the full sketch, using code tags when you do, and confirm that you are using an Arduino ESP 32 board rather than a generic ESP32 board

I am using Espressif ESP32 Wroom 32. This is my first time on the forum, trying to figure out where can I upload the code

Paste the full sketch into a reply here, following these instructions

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

Please post your full sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

It is also helpful to post full error messages in code tags as it makes it easier to scroll through them and copy them for examination

To post the error message, click the "COPY ERROR MESSAGES" button in the IDE, paste the copied messages in a reply here, select all of it and click the < CODE > icon above the reply editor to add the code tags and then save the reply

// ================================== Bluetooth Definitions ========================================
#include <EEPROM.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

BLEServer *pServer = NULL;
BLECharacteristic *pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;


#define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"  // UART service UUID
#define CHARACTERISTIC_UUID "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"
// #define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"

#define EEPROM_SIZE 500

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

String bleString;
String lastProtocolString = " ";
bool isNewProtocol = false;
// ========================================================================================

// =============================== Display Definitions =============================================
#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 NUM_ROWS 1                      // Number of rows of chained INDIVIDUAL PANELS
#define NUM_COLS 3                      // Number of INDIVIDUAL PANELS per ROW
#define PANEL_CHAIN NUM_ROWS *NUM_COLS  // total number of panels chained one to another

// library includes
#include <Adafruit_GFX.h>
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
#include <ESP32-VirtualMatrixPanel-I2S-DMA.h>
#include "BLEInputHandler.h"

int vertical_offset = 1;

// placeholder for the matrix object
MatrixPanel_I2S_DMA *dma_display = nullptr;

// placeholder for the virtual display object
// Display number one from 1 to 68 pixels (0th to 71st)
VirtualMatrixPanel *virtualDisp1 = nullptr;

// Display number one from 1 to 96 pixels (0th to 96th)
VirtualMatrixPanel *virtualDisp2 = nullptr;

// String varialbles to hold the input protocol text
String protocolText;
String defaultFirstTimeText = "Prahari";

// BLEInputHandler
BLEInputHandler *bleInputHandler;

String scrollText;
uint16_t scrollTextColor;
uint16_t scrollTextBgColor;

char firstChar;
uint16_t firstCharTextColor;
uint16_t firstCharBgColor;

char secondChar;
uint16_t secondCharTextColor;
uint16_t secondCharBgColor;
// =================================================================================================

// ===================================== Utility Functions =========================================
class MyServerCallbacks : public BLEServerCallbacks {
  void onConnect(BLEServer *pServer) {
    deviceConnected = true;
  };

  void onDisconnect(BLEServer *pServer) {
    deviceConnected = false;
    pServer->getAdvertising()->start();
  }
};

class MyCallbacks : public BLECharacteristicCallbacks {
  void onWrite(BLECharacteristic *pCharacteristic) {
    String value = pCharacteristic->getValue().c_str();

    if (value.length() > 0) {
      Serial.println("*********");
      Serial.print("New protocol text: ");
      Serial.println(value);
      Serial.println("*********");

      // Set the new value to the lastProtocol value
      lastProtocolString = value;
      isNewProtocol = true;
    }
  }
};

void displayAllThreeDataOnScreen() {
  // First display the two letters with the text color and their respective background color
  // virtualDisp2->fillRect(virtualDisp1->width() + 1, 0, ((virtualDisp2->width() - virtualDisp1->width()) / 2) - 1, virtualDisp2->height(), bleInputHandler->getFirstSingleCharBgColor());
  // virtualDisp2->fillRect(virtualDisp1->width() + ((virtualDisp2->width() - virtualDisp1->width()) / 2) - 1, 0, (virtualDisp2->width() - virtualDisp1->width()) / 2, virtualDisp2->height(), bleInputHandler->getSecondSingleCharBgColor());
  virtualDisp2->fillRect(73, 0, 4, 16, bleInputHandler->getFirstSingleCharBgColor());
  virtualDisp2->fillRect(85, 0, 4, 16, bleInputHandler->getSecondSingleCharBgColor());

  // Display first single character
  virtualDisp2->setCursor(73, vertical_offset);
  virtualDisp2->setTextColor(bleInputHandler->getFirstSingleCharTextColor());
  virtualDisp2->print(bleInputHandler->getFirstSingleLetter());

  // Display second single character
  virtualDisp2->setCursor(84, vertical_offset);
  virtualDisp2->setTextColor(bleInputHandler->getSecondSingleCharTextColor());
  virtualDisp2->print(bleInputHandler->getSecondSingleLetter());

  // Display the scrolling text
  virtualDisp1->setTextColor(bleInputHandler->getScrollTextColor());
  scroll_text(*&virtualDisp1, vertical_offset, bleInputHandler->getScrollText(),0);
}

void _1_displaySingleScreenColor(String protocolText) {
  // Get the color data from the protocol input string
  int r = protocolText.substring(11, 14).toInt();
  int g = protocolText.substring(14, 17).toInt();
  int b = protocolText.substring(17, 20).toInt();
  Serial.println("Got the following colors ");
  Serial.printf("Red %d, Green %d, Blue %d ", r, g, b);
  Serial.println();

  // Store the Color input to somewhere
  bleInputHandler->changeSingleScreenColor(r, g, b);

  // Set the protocol command flag
  EEPROM.write(0, 1);  // This means that the last command got from the BLE was 1 - displaySingleColor
  EEPROM.commit();
  delay(100);

  while (1) {
    // Listen for active input stream from the bluetooth
    if (deviceConnected) {
      if (isNewProtocol) {
        char breakFlag = lastProtocolString.charAt(0);
        if (breakFlag == '~') {
          Serial.print("Break flag 3 ::: ");
          Serial.println(breakFlag);
          virtualDisp2->fillScreen(0);
          break;  // Break the loop
        }
      }
    }
    // Fill full screen
    // virtualDisp2->fillScreen(bleInputHandler->getSingleScreenColor());
    // Fill middle panel only
    virtualDisp2->fillRect(32, 0, 32, 16, bleInputHandler->getSingleScreenColor());
  }
}

void _2_changeScrollTextDetails(String protocolText) {

  // Get the data from the protocol input string
  int bg_r = protocolText.substring(11, 14).toInt();
  int bg_g = protocolText.substring(14, 17).toInt();
  int bg_b = protocolText.substring(17, 20).toInt();
  int txt_r = protocolText.substring(20, 23).toInt();
  int txt_g = protocolText.substring(23, 26).toInt();
  int txt_b = protocolText.substring(26, 29).toInt();

  String scrollText = protocolText.substring(29);

  bleInputHandler->changeScrollTextBGColor(bg_r, bg_g, bg_b);
  bleInputHandler->changeScrollTextColor(txt_r, txt_g, txt_b);
  bleInputHandler->changeScrollText(scrollText);

  // Set the protocol command flag
  EEPROM.write(0, 2);
  EEPROM.commit();
}


void _3_changeFirstCharDetails(String protocolText) {
  // Get the data from the protocol input string
  int bg_r = protocolText.substring(11, 14).toInt();
  int bg_g = protocolText.substring(14, 17).toInt();
  int bg_b = protocolText.substring(17, 20).toInt();
  int txt_r = protocolText.substring(20, 23).toInt();
  int txt_g = protocolText.substring(23, 26).toInt();
  int txt_b = protocolText.substring(26, 29).toInt();
  char firstSingleChar = protocolText[29];

  bleInputHandler->changeFirstSingleChar(firstSingleChar);
  bleInputHandler->changeFirstCharBGColor(bg_r, bg_g, bg_b);
  bleInputHandler->changeFirstCharTextColor(txt_r, txt_g, txt_b);

  // Set the protocol command flag
  EEPROM.write(0, 3);
  EEPROM.commit();
}

void _4_changeSecondCharDetails(String protocolText) {
  // Get the data from the protocol input string
  int bg_r = protocolText.substring(11, 14).toInt();
  int bg_g = protocolText.substring(14, 17).toInt();
  int bg_b = protocolText.substring(17, 20).toInt();
  int txt_r = protocolText.substring(20, 23).toInt();
  int txt_g = protocolText.substring(23, 26).toInt();
  int txt_b = protocolText.substring(26, 29).toInt();
  char firstSingleChar = protocolText[29];

  bleInputHandler->changeSecondSingleChar(firstSingleChar);
  bleInputHandler->changeSecondCharBGColor(bg_r, bg_g, bg_b);
  bleInputHandler->changeSecondCharTextColor(txt_r, txt_g, txt_b);

  // Set the protocol command flag
  EEPROM.write(0, 4);
  EEPROM.commit();
}

void _5_addNewUsersPhoneNumber(String protocolText) {
  Serial.print("Adding the phone number ");
  Serial.println(protocolText.substring(1, 11));

  bleInputHandler->setupNewUserWithPhone(protocolText.substring(1, 11));

  // Set the protocol command flag
  EEPROM.write(0, 8);  // Set the flag to 8 - means the phone number is there but no data is avaialble
  EEPROM.commit();

  scroll_text(*&virtualDisp2, vertical_offset, defaultFirstTimeText,5);
}

void _6_changeUsersPhoneNumber(String protocolText) {
  Serial.print("Updating the phone number to");
  Serial.println(protocolText.substring(1, 21));

  bleInputHandler->changePhoneNumber(protocolText.substring(1, 21));

  // Set the protocol command flag
  EEPROM.write(0, 6);  // Set the flag to 6
  EEPROM.commit();
}

void _7_changeFullScrollTextDetails(String protocolText) {

  // Get the data from the protocol input string
  int bg_r = protocolText.substring(11, 14).toInt();
  int bg_g = protocolText.substring(14, 17).toInt();
  int bg_b = protocolText.substring(17, 20).toInt();
  int txt_r = protocolText.substring(20, 23).toInt();
  int txt_g = protocolText.substring(23, 26).toInt();
  int txt_b = protocolText.substring(26, 29).toInt();

  String scrollText = protocolText.substring(29);
  
  bleInputHandler->changeScrollTextBGColor(bg_r, bg_g, bg_b);
  bleInputHandler->changeScrollTextColor(txt_r, txt_g, txt_b);
  bleInputHandler->changeScrollText(scrollText);
  
  // Set the protocol command flag
  EEPROM.write(0, 7);
  EEPROM.commit();

  virtualDisp2->fillRect(0, 0, virtualDisp2->width(), virtualDisp2->height(), bleInputHandler->getScrollTextBGColor());
  virtualDisp2->setTextColor(bleInputHandler->getScrollTextColor());
  scroll_text(*&virtualDisp2, vertical_offset, bleInputHandler->getScrollText(),7);
}

void _8_changeFullFixTextDetails(String protocolText) {

  // Get the data from the protocol input string
  int bg_r = protocolText.substring(11, 14).toInt();
  int bg_g = protocolText.substring(14, 17).toInt();
  int bg_b = protocolText.substring(17, 20).toInt();
  int txt_r = protocolText.substring(20, 23).toInt();
  int txt_g = protocolText.substring(23, 26).toInt();
  int txt_b = protocolText.substring(26, 29).toInt();

  String fixText = protocolText.substring(29);
  
  bleInputHandler->changeScrollTextBGColor(bg_r, bg_g, bg_b);
  bleInputHandler->changeScrollTextColor(txt_r, txt_g, txt_b);
  bleInputHandler->changeScrollText(fixText);
  
  // Set the protocol command flag
  EEPROM.write(0, 8);
  EEPROM.commit();

  //virtualDisp2->fillScreen(0);
  virtualDisp2->fillRect(0, 0, virtualDisp2->width(), virtualDisp2->height(), bleInputHandler->getScrollTextBGColor());
  virtualDisp2->setCursor(0, vertical_offset);
  virtualDisp2->setTextColor(bleInputHandler->getScrollTextColor());
  virtualDisp2->print( bleInputHandler->getScrollText());
}

void _9_changeDynamicDetails(String protocolText) {
  // Get the data from the protocol input string
  uint8_t colors[72];
  Serial.println("XXX");
  for (int i=0;i<72;i++){
    colors[i] = protocolText.substring(11+(i*3), 11+(i*3)+3).toInt();
  }
  int txt_r = protocolText.substring(227, 230).toInt();
  int txt_g = protocolText.substring(230, 233).toInt();
  int txt_b = protocolText.substring(233, 236).toInt();

  String scrollText = protocolText.substring(236);
  //bleInputHandler->changeScrollTextBGColor(bg_r, bg_g, bg_b);
  bleInputHandler->setDynamicBGColor(colors);
  bleInputHandler->changeScrollTextColor(txt_r, txt_g, txt_b);
  bleInputHandler->changeScrollText(scrollText);
  
  // Set the protocol command flag
  EEPROM.write(0, 9);
  EEPROM.commit();

  delay(500);
  scroll_text(*&virtualDisp2, vertical_offset, bleInputHandler->getScrollText(),9);
}

void _0_changeScrollSpeed(String protocolText) {
  Serial.print("CHANGING SPEED");
  Serial.println(protocolText.substring(11, 14));
  bleInputHandler->changeScrollSpeed(protocolText.substring(11, 14).toInt());
  if(EEPROM.read(0) == 2 || EEPROM.read(0) == 7 || EEPROM.read(0) == 9)
  scroll_text(*&virtualDisp2, vertical_offset, bleInputHandler->getScrollText(),EEPROM.read(0));
}

/// Scroll Text on the display function
void scroll_text(VirtualMatrixPanel *virtualDisplay, int16_t y, String inputText,int protocol) {
  int w_text = virtualDisplay->width();  // screen width
  int len = inputText.length() * 12;     // 12 is the max width of character when font size is 2
  uint8_t colors[72];

  while (1) {
    // Listen for active input stream from the bluetooth
    if (deviceConnected) {
      if (isNewProtocol) {
        char breakFlag = lastProtocolString.charAt(0);
        if (breakFlag == '~') {
          Serial.print("Break flag 2 ::: ");
          Serial.println(breakFlag);
          virtualDisplay->fillScreen(0);
          break;  // Break the loop
        }
      }
    }
    
    // display inputText
    virtualDisplay->flipDMABuffer();
    if(protocol == 9) {
      bleInputHandler->getDynamicBGColor(colors);
      for (int i=0;i<72;i++)Serial.print(colors[i]);
      //delay(500);
      for(int i=0;i<sizeof(colors)/3;i++){
        virtualDisp2->fillRect((i*4), 0, 4, 16, virtualDisp2->color565(colors[(i*3)],colors[(i*3)+1], colors[(i*3)+2]));
      }
    }else virtualDisplay->fillRect(0, 0, virtualDisplay->width(), virtualDisplay->height(), bleInputHandler->getScrollTextBGColor());
    virtualDisplay->setCursor(w_text, y);
    virtualDisplay->setTextColor(bleInputHandler->getScrollTextColor());
    virtualDisplay->print(inputText);
    w_text--;
    if (w_text + len == 0) {
      w_text = virtualDisplay->width();
    }
    delay(bleInputHandler->getScrollSpeed());
  }
}
// =================================================================================================


// ================== Handle input protocol text and decoding data function ========================
bool processProtocolInputText(String protocolText) {
  if (protocolText.length() > 0) {
    Serial.print("Protocol Text ");
    Serial.println(protocolText);

    isNewProtocol = false;

    char ptclNum = protocolText[0];
    if (EEPROM.read(0) != 0) {

      Serial.print("Last running protocol was ==> ");
      Serial.println(EEPROM.read(0));

      if (bleInputHandler->isValidUser(protocolText.substring(1, 11))) {
        switch (ptclNum) {
          case '1':  // Display single color on full-screen
            _1_displaySingleScreenColor(protocolText);
            break;
          case '2':  // Change scroll text with background and text colors
            _2_changeScrollTextDetails(protocolText);
            displayAllThreeDataOnScreen();
            break;
          case '3':  // Change first single letter with background and text colors
            _3_changeFirstCharDetails(protocolText);
            displayAllThreeDataOnScreen();
            break;
          case '4':  // Change second single letter with background and text colors
            _4_changeSecondCharDetails(protocolText);
            displayAllThreeDataOnScreen();
            break;
          case '5':  // Calling the 5th protocol while the number has been saved but no new protocol after it has been received
            // _5_addNewUsersPhoneNumber(protocolText);
            displayAllThreeDataOnScreen();
            break;
          case '6':  // Change user's phone number
            _6_changeUsersPhoneNumber(protocolText);
            displayAllThreeDataOnScreen();
            break;
          case '7':
            _7_changeFullScrollTextDetails(protocolText);
            break;
          case '8':
            _8_changeFullFixTextDetails(protocolText);
            break;
          case '9':
            _9_changeDynamicDetails(protocolText);
            break;
          case '0':
            _0_changeScrollSpeed(protocolText);
            break;
          default:
            return false;
        }
        return true;
      }
    } else {
      // Add new user's phone for the first time (Never Called again after the phone number is stored once)
      if (ptclNum == '5') {
        Serial.println("Calling the phone number adding function");
        _5_addNewUsersPhoneNumber(protocolText);
        return true;
      }
    }
    Serial.println("***** No protocol ran :(");
    Serial.println("Displaying the old state on the screen");
    displayAllThreeDataOnScreen();
  } else {
    // pServer->startAdvertising();
    scroll_text(*&virtualDisp2, vertical_offset, defaultFirstTimeText,0);
  }
  return false;
}
// =================================================================================================



void setup() {

  Serial.begin(115200);

  // initialize EEPROM with predefined size
  EEPROM.begin(EEPROM_SIZE);

  // ============================= BLE Input Data Setup =====================================
  bleInputHandler = new BLEInputHandler(virtualDisp2);
  // ========================================================================================


  // ================================ Bluetooth Setup =======================================
  BLEDevice::init("Brahma-ESP32-Test");
  BLEServer *pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());  // Adding callbacks for the server connection

  BLEService *pService = pServer->createService(SERVICE_UUID);

  // Create a BLE characteristic
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
    CHARACTERISTIC_UUID,
    BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE);

  pCharacteristic->setCallbacks(new MyCallbacks());

  pCharacteristic->setValue("Hello World");
  pService->start();


  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();

  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  pAdvertising->setMinPreferred(0x06);  // functions that help with iPhone connections issue
  pAdvertising->setMinPreferred(0x12);

  BLEDevice::startAdvertising();
  Serial.println("BLE is all set! Now you can interact through it with your phone!");
  // ========================================================================================

  // ================================== Display Setup =======================================
  HUB75_I2S_CFG mxconfig(
    PANEL_RES_X,  // module width
    PANEL_RES_Y,  // module height
    PANEL_CHAIN   // chain length
  );

  //mxconfig.driver = HUB75_I2S_CFG::FM6126A;     // in case that we use panels based on FM6126A chip, we can set it here before creating MatrixPanel_I2S_DMA object
  // OK, now we can create our matrix object
  // mxconfig.double_buff = true;
  dma_display = new MatrixPanel_I2S_DMA(mxconfig);

  // let's adjust default brightness to about 75%
  dma_display->setBrightness8(64);  // range is 0-255, 0 - 0%, 255 - 100%

  // Allocate memory and start DMA display
  if (not dma_display->begin())
    Serial.println("****** !KABOOM! I2S memory allocation failed ***********");


  // Uncomment the three lines below to test the behaviour of a brand new firmware
  // EEPROM.write(0, 15);
  // EEPROM.commit();
  // delay(500);

  // Read the EEPROM for existing string stored in case if the display is powered off
  // The first bit will be the flag(0, 1 or 2)
  // 0 means -> the firmware is new and ready for user to be authenticated
  // 8 means -> the user is authenticated but no data available to show
  // [1-7] means -> the data is available (on reboot, last data would be taken)
  // After set to [1-7] the flag would always be used for storing the flag for the last running protocol
  // Note: In this program flag == 5 and flag == 7 are never used. (We can add more conditions using these flags in future if required)
  int flag = EEPROM.read(0);
  Serial.print("Exists Flag ==> ");
  Serial.println(flag);

  if (flag == 0) {
    // This means that the EEPROM is empty
    Serial.println("The firmware is brand new and needs to be setup!");
  } else if (flag == 10) {
    Serial.println("The user number is entered but no data available yet!");
  } else if (flag != 0 && flag != 1 && flag != 2 && flag != 3 && flag != 4 && flag != 5 && flag != 6 && flag != 7 && flag != 8 && flag != 9 && flag != 10) {
    // If the flag is some other value than the possible flag values
    // that means the EEPROM is corrupted or the EEPROM is new and holds garbage values
    // Then clear the whole EEPROM at once and set the whole EEPROM address to integer 0.
    for (int i = 0; i < EEPROM_SIZE; i++) {
      EEPROM.write(i, 0);
      EEPROM.commit();
    }
    delay(500);
  } else {
    Serial.println("The user number is present and some past data is also available");
  }


  // create virtualDisp1lay object based on our newly created dma_display object
  virtualDisp1 = new VirtualMatrixPanel((*dma_display), 1, 1, 74, PANEL_RES_Y);
  virtualDisp2 = new VirtualMatrixPanel((*dma_display), NUM_ROWS, NUM_COLS, PANEL_RES_X, PANEL_RES_Y);

  virtualDisp1->fillScreen(0);
  virtualDisp1->setTextSize(2);

  virtualDisp2->fillScreen(0);
  virtualDisp2->setTextSize(2);
  // ========================================================================================
}


void loop() {

  // ================================== Bluetooth Loop =======================================
  if (deviceConnected) {
    bleString = lastProtocolString;
    bleString.remove(0, 1);  // removes the ~ for further processing
    processProtocolInputText(bleString);
  } else {
    Serial.println("Please connect to Brahma-ESP32-Test bluetooth");

    // pServer->getAdvertising()->start();  // restart advertising

    int flag = EEPROM.read(0);
    if (flag == 0 || flag == 10) {
      // If there is no past data available as well, then show default text
      scroll_text(*&virtualDisp2, vertical_offset, defaultFirstTimeText,0);
    } else {
      if (flag == 1) {
        while (1) {
          // Listen for active input stream from the bluetooth
          if (deviceConnected) {
            if (isNewProtocol) {
              char breakFlag = lastProtocolString.charAt(0);
              if (breakFlag == '~') {
                Serial.print("Break flag 1 ::: ");
                Serial.println(breakFlag);
                virtualDisp2->fillScreen(0);
                break;  // Break the loop
              }
            }
          }
          virtualDisp2->fillScreen(bleInputHandler->getSingleScreenColor());
        }
      } else {
        if(flag == 9) scroll_text(*&virtualDisp2, vertical_offset, bleInputHandler->getScrollText(),9);
        else if(flag == 8){
          virtualDisp2->fillRect(0, 0, virtualDisp2->width(), virtualDisp2->height(), bleInputHandler->getScrollTextBGColor());
          virtualDisp2->setCursor(0, vertical_offset);
          virtualDisp2->setTextColor(bleInputHandler->getScrollTextColor());
          virtualDisp2->print( bleInputHandler->getScrollText());
        }else if(flag == 7){
           virtualDisp2->fillRect(0, 0, virtualDisp2->width(), virtualDisp2->height(), bleInputHandler->getScrollTextBGColor());
          virtualDisp2->setTextColor(bleInputHandler->getScrollTextColor());
          scroll_text(*&virtualDisp2, vertical_offset, bleInputHandler->getScrollText(),7);
        }else displayAllThreeDataOnScreen();
      }
    }
  }
}

Below is the code of BLEInputHandler.h

#include <EEPROM.h>
#include <ESP32-VirtualMatrixPanel-I2S-DMA.h>

class BLEInputHandler {
private:
  VirtualMatrixPanel* virtualDisplay = nullptr;

public:
  BLEInputHandler(VirtualMatrixPanel* vdsp) {
    this->virtualDisplay = vdsp;
  }

  // PHONE NUMBER FUNCTIONS FOR EEPROM ==============================================================

  /// Adds new user with the phone number
  /// This would be needed only at the initial setup of hardware
  bool setupNewUserWithPhone(String phnNum) {
    Serial.print("EEPROM got ");
    Serial.println(phnNum);
    if (phnNum.length() == 10) {
      for (int i = 1; i < 11; i++) {
        EEPROM.write(i, phnNum[i - 1]);
        EEPROM.commit();
      }
      return true;
    }
    return false;
  }

  /// Validates the phone number for user authentication.
  /// Run this each time a request of change from BLE is received
  bool isValidUser(String phoneNum) {
    Serial.print("Autenticating the phone number ");
    Serial.println(phoneNum);
    if (phoneNum.length() == 10) {
      for (int i = 1; i < 11; i++) {
        if (EEPROM.read(i) != phoneNum[i - 1])
          return false;
      }
      return true;
    }
    return false;
  }

  /// Changes the phone number for a user
  bool changePhoneNumber(String numbers) {
    if (numbers.length() == 20) {
      char currDigit;
      // Validate the old number first
      for (int i = 1; i < 11; i++) {
        currDigit = EEPROM.read(i);
        if (currDigit != numbers[i - 1])
          return false;
      }

      // If the above loop completes, then the old phone is validated
      // Now change the phone number to new one
      for (int i = 1; i < 11; i++) {
        EEPROM.write(i, numbers[9 + i]);
        EEPROM.commit();
      }

      return true;
    }
    return false;
  }

  String getPhoneNumber() {
    char data[10 + 1];
    for (int i = 1; i < 11; i++) {
      data[i - 1] = EEPROM.read(i);
    }
    data[10] = '\0';
    return String(data);
  }

  // SINGLE SCREEN COLOR =====================================================================================
  void changeSingleScreenColor(int r, int g, int b) {
    EEPROM.write(29, r);
    EEPROM.write(30, g);
    EEPROM.write(31, b);
    EEPROM.commit();
  }

  uint16_t getSingleScreenColor() {
    int r = EEPROM.read(29);
    int g = EEPROM.read(30);
    int b = EEPROM.read(31);
    return this->virtualDisplay->color565(r, g, b);
  }

  void changeScrollSpeed(uint8_t speed){
    EEPROM.write(34, speed);
    EEPROM.commit();
  }

  uint8_t getScrollSpeed() {
    uint8_t speed = EEPROM.read(34);
    if(speed<1) speed = 50;
    return speed;
  }

  // SCROLL TEXT FUNCTIONS FOR EEPROM ==================================================================================
  /**
     * @brief Writes new scrolling text on EEPROM. The length of the scrolling text is
     * stored at the address offset 70. Function updates the length of new string to 70 address.
     * Then writes the string from the 71st address till the string's length after that.
     * All other change functions act similarly!
     * @param scrollText
     */
  void changeScrollText(String scrollText) {
    Serial.print("Got the new scroll text : ");
    Serial.println(scrollText);
    int len = scrollText.length();
    EEPROM.write(108, len);
    EEPROM.commit();
    for (int i = 0; i < len; i++) {
      EEPROM.write(108 + 1 + i, scrollText[i]);
      EEPROM.commit();
    }
  }

  /// Returns the text which is to be displayed in scrolling section
  String getScrollText() {
    int len = EEPROM.read(108);
    char data[len + 1];
    for (int i = 0; i < len; i++) {
      data[i] = EEPROM.read(108 + 1 + i);
    }
    data[len] = '\0';
    return String(data);
  }

  void getDynamicBGColor(uint8_t colors[72]) {
    for (int i = 0; i < 72; i++) {
      colors[i] = EEPROM.read(35 + i);
      Serial.println(colors[i]);
    }
    Serial.println("XXXBBB");
  }

  void setDynamicBGColor(uint8_t colors[72]) {
    for (int i = 0; i < 72; i++) {
      EEPROM.write(35 + i, colors[i]);
      EEPROM.commit();
    }
  }

  void changeScrollTextBGColor(int r, int g, int b) {
    EEPROM.write(11, r);
    EEPROM.write(12, g);
    EEPROM.write(13, b);
    EEPROM.commit();
  }

  uint16_t getScrollTextBGColor() {
    int r = EEPROM.read(11);
    int g = EEPROM.read(12);
    int b = EEPROM.read(13);
    return this->virtualDisplay->color565(r, g, b);
  }

  void changeScrollTextColor(int r, int g, int b) {
    EEPROM.write(14, r);
    EEPROM.write(15, g);
    EEPROM.write(16, b);
    EEPROM.commit();
  }

  uint16_t getScrollTextColor() {
    int r = EEPROM.read(14);
    int g = EEPROM.read(15);
    int b = EEPROM.read(16);
    return this->virtualDisplay->color565(r, g, b);
  }


  // FIRST SINGLE CHARACTER FUNCTIONS FOR EEPROM ===================================================================
  bool changeFirstSingleChar(char firstChar) {
    EEPROM.write(32, firstChar);
    EEPROM.commit();
    return true;
  }

  char getFirstSingleLetter() {
    return EEPROM.read(32);
  }

  void changeFirstCharBGColor(int r, int g, int b) {
    EEPROM.write(17, r);
    EEPROM.write(18, g);
    EEPROM.write(19, b);
    EEPROM.commit();
  }

  uint16_t getFirstSingleCharBgColor() {
    int r = EEPROM.read(17);
    int g = EEPROM.read(18);
    int b = EEPROM.read(19);
    return this->virtualDisplay->color565(r, g, b);
  }

  void changeFirstCharTextColor(int r, int g, int b) {
    EEPROM.write(20, r);
    EEPROM.write(21, g);
    EEPROM.write(22, b);
    EEPROM.commit();
  }

  uint16_t getFirstSingleCharTextColor() {
    int r = EEPROM.read(20);
    int g = EEPROM.read(21);
    int b = EEPROM.read(22);
    return this->virtualDisplay->color565(r, g, b);
  }

  // SECOND SINGLE CHARACTER FUNCTIONS FOR EEPROM ========================================================================
  bool changeSecondSingleChar(char secondChar) {
    EEPROM.write(33, secondChar);
    EEPROM.commit();
    return true;
  }

  char getSecondSingleLetter() {
    return EEPROM.read(33);
  }

  void changeSecondCharBGColor(int r, int g, int b) {
    EEPROM.write(23, r);
    EEPROM.write(24, g);
    EEPROM.write(25, b);
    EEPROM.commit();
  }

  uint16_t getSecondSingleCharBgColor() {
    int r = EEPROM.read(23);
    int g = EEPROM.read(24);
    int b = EEPROM.read(25);
    return this->virtualDisplay->color565(r, g, b);
  }

  void changeSecondCharTextColor(int r, int g, int b) {
    EEPROM.write(26, r);
    EEPROM.write(27, g);
    EEPROM.write(28, b);
    EEPROM.commit();
  }

  uint16_t getSecondSingleCharTextColor() {
    int r = EEPROM.read(26);
    int g = EEPROM.read(27);
    int b = EEPROM.read(28);
    return this->virtualDisplay->color565(r, g, b);
  }
};

Above is the working code and header file for P10 LED

Indeed the i.MX8M Plus is a beast but I guess ESP32 GPIOs directly does not perfectly drive the P8 panel. The ESP32 is 3.3 V and most HUB75/P8 panels expect 5 V logic. In such projects, ESP32's clock and data lines are not reliable enough to hit the logic and provide perfect output.
For level shifting, you should use 74HCT245 (reference ESP32 RGB LED - Share - PCBWay)

ESP32 HUB75 DMA library is also helpful to solve your issue (reference: GitHub - 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.)

The same HUB75 connector is there on P10 panel, which is working perfectly

The 4S mark is extremely important in this case.
Your panel is a so-called quarter-scan panel, meaning four lines light up simultaneously, unlike standard panels, where two lines light up at a time.
Read the library Readme for description on this topic.
Your matrix needs to be configured separately for it to work. This question isn't directly related to the Arduino forum; I think you'd be better off opening the issue on the library repo, and I'll answer it there.

Dear @oliver2003 !
This isn't the first time I've been convinced that you're replying without reading the topic that you reply. Why are you doing this? To increase the number of posts?

The author already uses in his/her code the ESP32 HUB75 DMA library, which you're recommending.

thanks! Can you pls point me to the library repo where I can post the query?

From post #11. GitHub - 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.

Done: P8 4S panel not working on code of P10 8S panel · Issue #905 · mrcodetastic/ESP32-HUB75-MatrixPanel-DMA · GitHub

@b707