MD_Parola Using static and scrolling text - scrolling next not displaying

I am now stuck. I would like to have "static" and "scrolling" text working throughout my code.

Have looked at many example code and docs online, but now just have brain fade

I cant see what I am not understanding, I know its user error but out out ideas and other ways how to test it.

The code cycles through and the static text shows ok but no scrolling text. Thought I was going to crack it today after a few days trying.

// using esp8266 D1 mini

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

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4

//#define CLK_PIN   14    // or SCK
//#define DATA_PIN  13    // or MOSI
#define CS_PIN    15    // or SS

// Create a new instance of the MD_Parola class with hardware SPI connection
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

int onlyonce = 1;

// Messages in strings
uint8_t  curString = 0;
const char *msg[] =
{
  "First scrolling message",
  "Second scrolling message",
  "Third scrolling message"
};

// Pause time
const uint16_t PAUSE_TIME = 1000; // in milliseconds

void setup() {
  Serial.begin(115200);
  P.begin();                      // Intialize the object
  P.setIntensity(1);              // Set the intensity (brightness) of the display (0-15)
  //P.displayClear();               // Clear the display
  P.displayScroll(msg[curString], PA_LEFT, PA_SCROLL_LEFT, 100);  // Show scroll Text

}

void loop() {
  Serial.println(onlyonce);

  if (onlyonce == 1) {
    P.setTextAlignment(PA_LEFT);
    P.print("Start");
    delay(1000);
  }

  onlyonce = 2;
  Serial.println(onlyonce);

  // just print some test
  P.setTextAlignment(PA_LEFT);
  P.print("Matrix");
  delay(1000);


  // put some other code here


  // just STATIC print some text
  P.setTextAlignment(PA_LEFT);
  P.print("Working");
  delay(1000);


  // put some other code here


  //  // how do i put scrolling text here????????????????
  if (P.displayAnimate()){
  P.displayScroll(msg[1], PA_LEFT, PA_SCROLL_LEFT, 100);
  P.displayReset();
  }

  //  if (P.displayAnimate()) {
  //
  //    //Serial.println(String(0));
  //    //Serial.println(msg[0]);
  //
  //    switch (0)        // just for testing force it to message zero
  //    {
  //      case 0:
  //        P.displayScroll(msg[0], PA_LEFT, PA_SCROLL_LEFT, 100);
  //        delay(2000);
  //        break;
  //
  //      case 1:
  //        P.displayScroll(msg[1], PA_LEFT, PA_SCROLL_LEFT, 100);
  //        delay(2000);
  //        break;
  //
  //      case 2:
  //        P.displayScroll(msg[2], PA_LEFT, PA_SCROLL_LEFT, 100);
  //        delay(2000);
  //        break;
  //
  //      default:
  //        // if nothing else matches, do the default
  //        Serial.println("nothing");
  //        // default is optional
  //        break;

  //        P.displayReset();
  //    }

  // PUT SOME OTHER CODE HERE


  // JUST STATIC PRINT SOMETHING TO MATRIX  - this does not work

  P.setTextAlignment(PA_LEFT);
  P.print("END");
  delay(1000);



}

Every instance of your 'static' text is resetting the display.

The P.displayAnimate() is what scrolls the scrolling text that you set up in setup() and then killed with the P.print().

Hi Marco

Ok took out the P.print and replace with P.displayTextl(......) but that was not the solution, does not display it in the correct order and the timing is off

I looked back at your HelloWorld example as it can scroll the text and added another copy of the P.displatText which it does not like, just me not understanding how the code works. It would scroll like two of three Hello and then a couple of Again, then may be hello followed by again. I assume a timing a memory issue by what I am asking it to try and do.

So you can have multiple P.print in the loop, but i assume you can only have one part that make scrolling text either P.displayText or P.displayScroll commands?

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

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4

#define CLK_PIN 14   // or SCK
#define DATA_PIN 13  // or MOSI
#define CS_PIN 15    // or SS

MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);  // Software spi

int onlyonce = 1;

uint8_t scrollSpeed = 70;  // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 1000;  // in milliseconds

#define BUF_SIZE 30
char curMessage[BUF_SIZE] = { "" };

void setup(void) {
  Serial.begin(115200);
  P.begin();
  P.setIntensity(1);
  P.displayClear();  // Clear the display
  P.displayReset();
  P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
}

void loop(void) {

// print to the matrix once once

  Serial.println(onlyonce);
  if (onlyonce == 1) {
    P.setTextAlignment(PA_LEFT);
    P.print("Start ");
    delay(1000);
  }

  onlyonce = 2;
  Serial.println(onlyonce);

  // Say at line 300 I need to print to the matrix

  if (P.displayAnimate())
    P.displayText("300", PA_CENTER, 80, 1000, PA_NO_EFFECT, PA_NO_EFFECT);
  
 // And at line 400 i need to print something

  if (P.displayAnimate())
    P.displayText("we are at line 400", PA_LEFT, 80, 1000, PA_NO_EFFECT, PA_NO_EFFECT);
  
  //while (!P.displayAnimate());

// At line 500 we need to scroll some text

  if (P.displayAnimate())
  //P.displayClear();
    P.displayText("Loading..... Please Wait.  Data is loading", PA_CENTER, 80, 1000, PA_SCROLL_LEFT, PA_SCROLL_LEFT);


//  At the end of the loop I need to print something

  if (P.displayAnimate())
    P.displayText("END", PA_CENTER, 80, 1000, PA_NO_EFFECT, PA_NO_EFFECT);

  //while (!P.displayAnimate());
}

It is really not clear to me what you are trying to do with this code. Can you explain the purpose/outcome you are trying to achieve so that I can suggest the appropriate structure.

You need to understand that P.displayAnimate() executes ONE step of the animation if the time to do the step has passed. Once ALL the steps are done it will return true status and you can proceed with the next animation. What you have coded will produce random results at best. The methds are all documented in the library documentation (docs folder of the library) and there are a series of articles on my blog (search "Parola A to A") covering various topics also.

Hi Marco

Sorry about this.

I did some more reading over the weekend but the penny still has not dropped

I was just trying to print to the matrix as the code runs through its loop. Both Static and scrolling

In my example all other code has been removed. I will edit to add some comments. but like

  1. At start put some text on the matrix and do this once once.

  2. Say we get to line 300 in the code, put on the matrix "300"

3, At line number 400 print "400"

  1. At line number 500 Scroll on the matrix "Loading..... please wait"

  2. At the end of the loop print "End" and start again

I have seen a few switch case examples which i can follow the logic and understand how that works. But that is like a block of code that once its done the animation is reset P.displayReset() and the loop starts over.

I am trying to print to the matrix many time throughout the code.

I know that the code must be read line by line and not to use "goto" to jump backwards possible back into a switch case to send something to the matrix then goto again to go back

Hope i you understand what i am trying to do.

Seems to me you are using this like a debug output, so .print() is really your only option. all the other animations require that .dispalyAnimate() is called many times to complete the animation. To do that inline with your code you need something like

P.displayText("Loading..... Please Wait.  Data is loading", PA_CENTER, 80, 1000, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
while (!P.displayAnimate()) { /* do animation empty loop */ };

but this will cause a stop in the code at that point while the animation is happening.

Your construct of checking first:

  if (P.displayAnimate())
    P.displayText("we are at line 400", PA_LEFT, 80, 1000, PA_NO_EFFECT, PA_NO_EFFECT);

is wrong and will not do what you are expecting it to do. PS_NO_EFFECT should result in no message being displayed and the check before will basically fail every time as there was no previous animation.

Not sure if you understand that loop() should be running many thousands/hundreds of times every second. If you try and .print a lot of data you will probably not see much of it as it will be overwritten by the next print().

Maybe should use Serial.print() staments through your code to tell you what is happening & where the code it. This may help you with understanding the flow and consequences.

Thanks Marco.

Sorry I may have confused you by putting in line numbers.

No was not trying to use for dedug, i get that. I think i still need to get my head around what i want to do and how yours Libs can help me.

I am going to close this topic for now as working on a clock matrix now, but will revisit when i understand more.

So anybody reading this sorry its not a true solution, but check but later.

Hi marco_c
I am following this post and andy-italies problem seems basicly the same that I have and generally match a common way to use the matrix displays. I will describe in a few words my project and skip uploading my code because I am still fooling around with test statements and they look exactly the same than the ones from andy-italy. I want to program a musicbox with a list of titles and some bottons to select one title and output the title text from the list scrolling on the display while it is playing on the DFP player. That requires that the Parola-output and effects change every time when there is a conditional branch in the sketch. I still can´t find some example on the web which shows how to use Parola funktions inside a complete and structured sketch. I understand so far that using one effect requires to wait until it is finished before continuing with the program. Can you please discribe how to loop a Parola effect in order to finish it and then continue until a new effect is desired. It would be great to find a solution for this simple thing. Thank´s in advance

Parola_Display-Test-demo.ino (3.1 KB)

Not at all. The effect will run 'in the background' as long as you keep calling displayAnimate(). When displayAnimate() returns true it means that the animation has completed and you can reload another if you want to. This is the way ALL the examples supplied with the library work - when the animation is completed it resets for the new animation.

As for examples doing more than one thing at a time if you look at the Scrolling example it reads from the serial port and builds the new message while the current message is being displayed. In principle this is no different from playing the music while the message is displaying.

FYI the library is also fully documented - look in the docs folder for the library.

Can you please discribe how to loop a Parola effect in order to finish it and then continue until a new effect is desired

Load the effect however you want to
while (!displayAnimate()) ; // do nothing in a busy loop waiting for the effect to complete

Hi marco,
thanks for this feedback. With the while(!displayAnimate()) loop I got it work, so it definitly it
does not work in the background like for example the DFP-player when it plays a track.
What I did was programming a funktion void animate() and call it every time after selecting an effect and setting the text to display. Additionally I added a second condition detecting a press button in order to break the while-loop. That works perfect now.

MusicBox-V1.1.ino (4.9 KB)

sorry, I don´t know if my uploaded sketch appears in the post, first time I do it
In my project I am using 3 individual displays and so 3 separate objects in the code which are P1, P2, and P3. Only P3 uses scroll effects.

Hi marco,
thank you for your kind response in order to help me.
I can tell you that I solved my problem, it was an really stupid mistake caused by myself. Everything I did was just fooling around until I found out that I had the #Wire library loaded and enabled and used the same pins reserved for SDA and SCL on the processor. Seems that this messed up the communication with the display.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.