Scrolling text is stuttering on 128 width

Hello !

I’ve made a custom PanelMap for a 128x32 panel that’s actually composed out of two 64x32 panels.

MODE_MAP_TESTING works perfectly.

I’ve made a simple scroll text method:

//------------------------- scroll_text()
void scroll_text(String text, uint16_t color, uint8_t ypos) {
  uint16_t text_length = text.length();
  matrix->clear();
  matrix->setTextWrap(false);
  matrix->setRotation(0);
  matrix->setFont(&FreeSans9pt7b);
  matrix->setTextColor(color);
  for(int xpos = mw; xpos > - (mw + text_length*9); xpos--) {
    matrix->clear();
    matrix->setCursor(xpos,ypos);
    matrix->print(text);
    yield();
    matrix->show();
    delay(20);
  }
}

The problem I am seeing is that the scroll text stutters. It’s not fluid.
I am currently not using a power source and I’m also not using Logic Level Converters. I’ve set the brightness pretty low.

I’ve tried both
const uint8_t kRefreshDepth = 24;
and
const uint8_t kRefreshDepth = 48;
but the result is the same.

Increasing const uint8_t kDmaBufferRows = 2; to 3 or 4 amplifies the stutter effect.

Here is a video: https://youtu.be/fEN2VoNIZJA
The panels are reversed because I don’t have a long ribbon to connect them.

What do you think the cause is ?
Thank you !

loop() won’t get called at the same rate all the time. The ESP32 is doing things in the background especially if you’re using WiFi. SmartMatrix Library is doing things in the background. delay(20) will delay at least 20 ms, but could delay more if interrupted.

It’s better to keep track of millis(). AnimatedGIFs does this, and it’s a common technique in Arduino I’m sure you can find an article if searching Google.