Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non-blocking animation and string scrolling to 4-digit display #24

Merged
merged 7 commits into from
Sep 19, 2022

Conversation

hackerceo
Copy link
Contributor

This PR adds non-blocking animation and scrolling to the TM1637TinyDisplay library.

Setup your scrolling message using display.scrollString() function.
Setup your animation using display.startAnimation() function.

Both scrollString() and startAnimations() take a boolean as a first parameter to determine if the animation sequence or string to scroll are defined as PROGMEM variables.

In your main loop you must call the display.Animate() function for it to work. The function returns TRUE while an animation is playing or a message is scrolling. The Animate() function is optimized to only run when a new frame should be displayed. The Animate() function runs using millis() function and start timestamps to determine which frame to be displayed. If some long running code gets executed between Animate() calls then it will drop the missed frames and display the frame which is at thee appropriate time for the animation.

@jasonacox
Copy link
Owner

jasonacox commented Sep 18, 2022

Brilliant!!! I love this @hackerceo - I can't wait to add this to my projects!

One minor change suggestion for API consistency: Can we change the parameters for scrollString() and startAnimation() slightly to better align to the rest of the functions by putting the content payload first and put bool usePROGMEM = false at the end with a default to false? I would even suggest adding a scrollString_P() and startAnimation_P() that are alias functions that call their main functions with usePROGMEM = true.

Seems like that would help with consistency, but I could be convinced otherwise. What do you think?

  void startAnimation(const uint8_t (*data)[4], unsigned int frames = 0, unsigned int ms = 10, bool usePROGMEM = false );
  void scrollString(const char s[], unsigned int ms = DEFAULT_SCROLL_DELAY, bool usePROGMEM = false);

@hackerceo
Copy link
Contributor Author

The previous suggestions have been added into this PR. This is now ready to be merged into your branch. I think you still need to add the new functions into the sketch used by your automatic build testing.

@jasonacox jasonacox merged commit 8a18e18 into jasonacox:master Sep 19, 2022
@jasonacox
Copy link
Owner

Merge completed. 🚀 I'll bundle this as v1.7.0 and add a TODO to port to 6-digit displays as well.

Thanks for this great enhancement @hackerceo !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants