Search code examples
arduinodisplayesp32arduino-c++arduino-esp32

Cannot change the scrolling text in MD_Parlola


I am trying to display text, got from a webserver, on a FC16_HW matrix display, using an esp32. To simpify things, I created a small demo that looks like this:

#include <WiFi.h>
#include <HTTPClient.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 5

MD_Parola Display = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
#define  BUF_SIZE  75
char one[BUF_SIZE] = {"hi"};

void setup() {
  
  Serial.begin(115200);
  Display.begin();
  Display.setIntensity(15);
  Display.displayClear();
  Display.displayScroll(one, PA_CENTER, PA_SCROLL_LEFT, 100);
}

void loop() 
{
  if(Display.displayAnimate()){
    char one[BUF_SIZE] = {"hello"};
    Display.displayReset();
  }
}

But for some reason, the text never changes to "hello" despite, setting the "one" char to it.

I tried differrent solutions for scrolling text, they all had the same problem. The if(Display.displayAnimate()) definetly works, as I check it with a Serial.println.

Any ideas?


Solution

  • Your code in loop() is:

    void loop() 
    {
      if(Display.displayAnimate()){
        char one[BUF_SIZE] = {"hello"};
        Display.displayReset();
      }
    }
    

    Just setting a variable called "one" to a string isn't going to display the string. You have to call Display.displayScroll() with the new value:

    void loop() 
    {
      if(Display.displayAnimate()){
        char one[BUF_SIZE] = {"hello"};
        Display.displayScroll(one, PA_CENTER, PA_SCROLL_LEFT, 100);
        Display.displayReset();
      }
    }
    

    I would suggest not using the same variable name as it's confusing and will hide the original variable. In fact there's no need to use a variable here at all unless you plan on modifying the string before you display it. So you could just write:

        Display.displayScroll("hello", PA_CENTER, PA_SCROLL_LEFT, 100);