Parola A to Z – Managing Animation

azparola_animationAs the main function of the Parola library is to enable text animations, it is important to understand how these are set up and managed to completion from user code.

From a user perspective, Parola animation consist of 3 parts – setting up, running and resetting the animation. The process is not complex and is illustrated in the numerous library examples. This article breaks these down and explains how the Parola class methods apply in each phase.

Setting Up

Setting up is most commonly done with the convenience functions displayScroll()displayText() and displayZoneText() because they are … convenient. The first two are shortcuts for single zone displays and maintain backward compatibility with code from earlier versions of the library. Both end up calling displayZoneText(), which is a wrapper for the the code

setTextBuffer(z, pText);
setTextAlignment(z, align);
setSpeed(z, speed);
setPause(z, pause);
setTextEffect(z, effectIn, effectOut);

which is what is needed to set up an animation!

The library needs to know:

  • a pointer to the text string to be displayed,
  • the text alignment in the display,
  • how fast to run the animation,
  • how long to pause the animation between the in and out text effect, and
  • what text effect(s) are selected for the animation.

The final call is to displayReset() to reset the zone to the starting state. Note that the display is not cleared in this sequence – that is the responsibility of the user code. In most cases the exit text effect will leave the display clear, ready for the next animation sequence.

So to set up an animation, without using the convenience methods mentioned, a similar setup sequence is needed in user code. At a minimum the library needs to know the message to be displayed, leaving the remaining parameters at their default values.

Running the Animation

The key to running a smooth animation is to call displayAnimate() as often as possible. This method will check the timer during each invocation and animate all the configured zones when their time is due. The method returns the boolean value true when at least one zone has completed its animation sequence (see this previous blog for how this is determined).

For single zone systems the return code is sufficient to tell that the display is ready to be reset for further animation. For multi-zone systems the user code needs to check each zone in turn, using getZoneStatus(), to determine which zones(s) have completed.

Animations can be suspended using the displaySuspend() method, which overrides the displayAnimate() call. The suspended display will continue to show the text ‘frozen’ in place until animation is resumed or reset.

Animation Reset

An animation is usually reset when it has finished. This can happen by invoking one of the convenience methods above. However, if only one parameter changes, usually the text to be displayed, an individual method can be called just for the changed parameter. In this case the previously set animation parameters are now the current default values. Once all changes are made, a displayReset() enables the animation to restart the next time displayAnimate() is invoked.

So there we have it. The libraries provide a simple way to manage a lot of under-the-hood complexity using a few straightforward class methods.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s