MajicDesigns / MD_Parola

Library for modular scrolling LED matrix text displays
GNU Lesser General Public License v2.1
428 stars 135 forks source link

Scrolling text one time #111

Closed kirner closed 1 year ago

kirner commented 1 year ago

IMPORTANT

Before submitting this issue [Y] Have you tried using the latest version of the library? [Y] Have you checked this has not already been submitted and/or resolved? [Y ] If you are requesting help a better choice may be the Arduino forum

Subject of the issue

I'd like to scroll a text just one time.

Your Environment

Library Version:3.6.2 Arduino IDE version:2.0.3 **Host OS and Version:Windows 10

From what I understand, when using a scroll effect, each call to the loop advances the animation. I was wondering if there is a way to know when the animation is complete so that I can execute other instructions. Essentially, my message is a welcome message, and I certainly don't want to continue executing it indefinitely! I thought about inserting the code related to the animation in an IF statement, but it's not clear to me if it's possible to know when to change the state to false.

----CODE-------

bool animationState = true;

void loop(){
  if(animationState){
  textEffect_t  effect = PA_SCROLL_LEFT;
    P.setTextBuffer("Jamm Bell");
      If(P.displayAnimate()) { 
        P.setSpeedInOut(50,25);
        P.setTextEffect(effect, effect);
        P.displayReset();
      }
  }
//How I know when animation is completed?
//animationState = false;
}

Thx in advance.

MajicDesigns commented 1 year ago

The displayAnimate() method returns 'true' when the animation is completed. The calling program should monitor the return value for 'true' in order to either reset the zone animation or supply another string for display. A 'true' return value means that one or more zones have completed their animation.

You are in fact already monitoring this in the code you show and all you are doing is restarting the animation.

FYI the library is documented. You can find the documentation at https://majicdesigns.github.io/MD_Parola/ or in the docs/html folder in the library folder.