-
Notifications
You must be signed in to change notification settings - Fork 23
Fix scroll trail clearing bugs #51
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
Open
per1234
wants to merge
2
commits into
arduino-libraries:master
Choose a base branch
from
per1234:fix-scroll-clearing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nd up directions The `endText` function has the capability to scroll the printed text. In order to ensure artifacts are not left behind on the display while scrolling, the library must clear the pixels at the previous location of the text after each frame of the scrolling animation. Previously, the code to handle this clearing incorrectly calculated the clearing coordinates for the leftwards (`SCROLL_LEFT`) and upwards (`SCROLL_UP`) scroll directions, having two separate problems: * The offset was subtracted rather than added. * An offset of 1 was used, which did not consider the width/height of the text. This bug might not be immediately apparent to the user because many character bitmaps do not populate any pixels on the rightmost column or bottom row of the grid, and thus those characters provide incidental self scroll trail clearing. However, this is not the case for all characters and those would cause a trail of artifacts to be left behind on the display when scrolled. The clearing coordinates calculation code is hereby corrected. NOTE: The coordinates calculation will still be incorrect for multi-line strings. However, this is not a regression because it was also incorrect before this change. The scroll trail clearing code has never had any provisions for handling multi-line strings so addition of such support is out of scope for this commit. In addition, the text scrolling code (not the scroll trail clearing code) has never correctly handled horizontal scrolling of multi-line strings, so until that is fixed it is only the lack of correct scroll trail clearing for vertical scrolling that is impactful to users.
The `endText` function has the capability to scroll the printed text. In order to ensure artifacts are not left behind on the display while scrolling, the library must clear the pixels at the previous location of the text after each frame of the scrolling animation. Previously, the code to handle this clearing for vertical scrolling only cleared a single character's width. This meant that scroll trail clearing was only done for the first character in the string. This bug might not be immediately apparent to the user because many character bitmaps do not populate any pixels on the top or bottom row of the grid, and thus those characters provide incidental self scroll trail clearing. However, this is not the case for all characters and those would cause a trail of artifacts to be left behind on the display when scrolled. The vertical scroll trail clearing code is hereby corrected to cover the full width of the string. Previously the `ArduinoGraphics::bitmap` function was used by the clearing code. That approach was reasonable for clearing the scroll trail of a single character, but due to the function's eight pixel width limitation, it is not suitable to use with strings. In this application where a line of arbitrary length, but only one pixel thick is needed, the `ArduinoGraphics::line` function is the suitable tool. So the code is ported to using `ArduinoGraphics::line`. NOTE: The calculations of the length of the clearing line will still be incorrect for multi-line strings. However, this is not a regression because it was also incorrect before this change. The scroll trail clearing code has never had any provisions for handling multi-line strings so adding such support is out of scope for this commit. In addition, the text scrolling code (not the scroll trail clearing code) has never correctly handled horizontal scrolling of multi-line strings, so until that is fixed it is only the lack of correct scroll trail clearing for vertical scrolling that is impactful to users.
Memory usage change @ 83d6df0
Click for full report table
Click for full report CSV
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
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.
The
endText
function has the capability to scroll the printed text. In order to ensure artifacts are not left behind on the display while scrolling, the library must clear the pixels at the previous location of the text after each frame of the scrolling animation (#36).Multiple bugs were found in the code that performs scroll trail clearing, which could cause a trail of artifacts to be left behind on the display when text was scrolled under certain conditions (#50). These bugs may not be immediately apparent to users because pixels are not populated at the edges of some character bitmaps, and thus such characters provide incidental self scroll trail clearing.
The following fixes are proposed by this pull request:
Correct text scroll trail clearing coordinates calculation for left and up directions
Previously, the code to handle this clearing incorrectly calculated the clearing coordinates for the leftwards (
SCROLL_LEFT
) and upwards (SCROLL_UP
) scroll directions, having two separate problems:Clear trail for full string width when scrolling text vertically
Previously, the code to handle this clearing for vertical scrolling only cleared a single character's width. This meant that scroll trail clearing was only done for the first character in the string.
Previously the
ArduinoGraphics::bitmap
function was used by the clearing code. That approach was reasonable for clearing the scroll trail of a single character, but due to the function's eight pixel width limitation, it is not suitable to use with strings. In this application where a line of arbitrary length, but only one pixel thick is needed, theArduinoGraphics::line
function is the suitable tool. So the code is ported to usingArduinoGraphics::line
.NOTE: The calculations of the length of the clearing line will still be incorrect for multi-line strings. However, this is not a regression because it was also incorrect before this change. The scroll trail clearing code has never had any provisions for handling multi-line strings so adding such support is out of scope for this commit. In addition, the text scrolling code (not the scroll trail clearing code) has never correctly handled horizontal scrolling of multi-line strings, so until that is fixed it is only the lack of correct scroll trail clearing for vertical scrolling that is impactful to users.
Outstanding defects
Multi-line strings
As was the case before the changes proposed by this PR, scroll trail clearing is not done correctly for multi-line strings. Since this is not a regression, and since the required changes to handle multi-line strings are not trivial, fixing this is considered out of scope for this PR.
The text scrolling code (not the scroll trail clearing code) has never correctly handled horizontal scrolling of multi-line strings, so until that is fixed it is only the lack of correct scroll trail clearing for vertical scrolling that is impactful to users.
Incorrect coordinates
Since it only considers the basic string length, the scroll trail clearing coordinates are incorrect for the leftwards (
SCROLL_LEFT
) and upwards (SCROLL_UP
) scroll directions with multi-line strings.Incorrect clearing line length
The clearing line length calculation for vertical scrolling is based on the basic string length and so will result in an overly long length for multi-line strings.
The clearing line length calculation for horizontal scrolling assumes the text will only be one character high so will result in a too short length for multi-line strings.
Incomplete scrolling
The calculation for the distance of leftward and upward scrolling is off by one, which results in the text bitmap not being scrolled completely off the display.
This is a defect in the text scrolling code, not in scroll trail clearing. However, it results in what might appear to be an artifact during testing of this proposal, so I thought it worth mentioning here.
A fix has been proposed in #52.
Fixes #50