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

Should the display be cleared when trying to print an invalid character? #424

Open
microbit-carlos opened this issue Apr 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@microbit-carlos
Copy link
Collaborator

microbit-carlos commented Apr 5, 2024

For example uBit.display.print("Hi O갎o") displays the O character 4 times in a row ( is 0xEA 0xB0 0x8E in UTF-8, which I can confirm is what I see compiled in the code). It does not blink, it's just permanently shown for 4x the animation time.

This is because when a character is "printed" on the display, it uses the image buffer in the display instance to render the character using Image::print(), which exits early if the character is out-of-range and doesn't change the image:
codal-core/source/types/Image.cpp#L578

So, when printing "Hi O갎o", it shows O for 4 iterations.

The change would be simple, in AnimatedDisplay::updatePrintText() we could check the return value from Image::print() and clear the display if the return is DEVICE_INVALID_PARAMETER:
codal-core/source/drivers/AnimatedDisplay.cpp#L182

This would align a bit more with what uBit.display.scroll() currently does, but it would be considered a change in behaviour (V1 and V2 do the same now), so maybe we might not want to change this.

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

No branches or pull requests

1 participant