Animating my MX7219 4 digit module using MD_Parola / MD_MAX72xx lib

Hi everyone, I need some help in animating my MX7219 4 digit module. What I want to do is to make alternating animating text and static text. i tried all the test code and couldn't make the animation to work. Once in the start of the module, the animation works for one time and subsequent call to displayAnimate() had no effect at all - the screen is just blank during .Animation. the static text is ok and shows for 5esc. to test this just made a minimal code sketch with 5sec animation and 5 sec Static display as below:


#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 13
#define DATA_PIN 11
#define CS_PIN 3
//user defines/var
bool animate = 1;
unsigned long currentMillis = millis();
unsigned long previousMillis = millis();

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

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

// Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE 75
char curMessage[BUF_SIZE] = {""};
char newMessage[BUF_SIZE] = {"Hello! Enter new message?"};
bool newMessageAvailable = true;


void setup()
{
    Serial.begin(38400);
    P.begin();
    P.displayText(newMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
    P.setIntensity(0);
}

void loop()
{
    currentMillis = millis();
    if (currentMillis - previousMillis > 5000)
    {
        previousMillis = currentMillis;
        animate = !animate;
        P.displayReset();
    }
    if (animate)
    {        
        if (P.displayAnimate())
        {
                P.displayReset();
        }
    }
    else
    {
        P.print("static");
    }    
}

when I comment out the statement "P.print("static");" the animation is working. tried displayReset(); before and after static display of text but no luck. tried removing "P.displayReset();" inside if() loop still no luck.
any help is appreciated

Split from an existing topic

PLEASE DO NOT HIJACK / NECRO POST !

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.

It will help you get the best out of the forum in the future.

Made to work using while loop instead of if()
here is the code inside void loop():

void loop()
{
    currentMillis = millis();
    if (currentMillis - previousMillis > 5000)
    {
        previousMillis = currentMillis;
        animate = !animate;
        P.displayReset();
    }
    if (animate)
    {
        P.displayText(newMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);    
        P.displayAnimate();
        while (!P.displayAnimate());
    }
    else
    {
        P.print("static");
    }    
}

Welcome to the forum.
I see that you already found a solution.

Do you know that the Wokwi simulator has a example for MD_Parola scrolling text ? https://wokwi.com/arduino/libraries/MD_Parola/Parola_Scrolling

I put your sketch in Wokwi as well:

You can make changes to my Wokwi project and test it, but you need to log in at Wokwi to be able to store your own project. Then you can select "Save a copy" and continue with my project.

A baud rate of 9600 is very slow and is something from the 1980s, but you don't have to be careful, you may use 115200.

When you make a typing error or give the wrong advice on this forum, then it is possible to edit a post and correct that. But don't change it too much, because it could break the flow of the discussion.

I sometimes do this:
Oranges are blue orange
[EDIT] Changed "blue" to "orange" for the color of oranges.

I see you have solved the problem, but just to be clear about:

causes the 'static' string to be displayed every time through loop() when animate is false (a few hundred times a second). This may cause the display to flicker (at low brightness) or be less bright than you expect (at high brightness).

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