Add support for scrolling text asynchronously #312
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I implemented support for generating animation (sequence) from text input. This can be later used for scrolling text asynchronously instead of doing it using
endText
which blocks execution untill text scroll is done on display.The new proposed API contains TEXT_ANIMATION_DEFINE macro (in new file TextAnimation.h) which (staticaly) declare buffer for specified number of frames. The API for sequences requires static number of frames, but this new API can dynamicaly adjust length of sequence depending on text length up to limit specified in second TEXT_ANIMATION_DEFINE parameter. For example:
declare buffers for up to 100 frames which is 20 characters using font 5x7 or 25 characters using font 4x6.
Then you can render text in exactly the same way as before. For example:
and then you call
endTextAnimation
instead ofendText
.endTextAnimation
renders text to the passed buffer (anim defined above) and do not show anything on display immidiately. Now you have animation rendered in the buffer, but because animation length is dynamic, you can't useloadSequence
because it assumes that sequence spans over whole buffer. Instead there is newloadTextAnimationSequence
which loads buffer and animation length correctly. Finally, once you loaded you can play it asynchronously (matrix.play();
), or play it endlesly (matrix.play(true);
).Proposed change contains new example TextWithArduinoGraphicsAsynchronous showing the proposed new API.
// Note that current main branch do not compile with ArduinoGraphics as described in #282 but I did not fix it here for making this change unique to this feature.