-
Notifications
You must be signed in to change notification settings - Fork 30
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
Display scroll an empty char if the requested char is out-of-range. #168
Conversation
Currently it was scrolling a NULL pointer: lancaster-university/codal-microbit-v2#423 This matches the V1 and MakeCode sim behaviour.
Looks good, although do we want a blank char on an unknown glyph, or something more explicit, like a filled block, question mark, or other symbol? Edit: or have a "badchar" constant we can use for any string conversions or stuff like serial IO |
Yeah, I had the same thought and proposed the question in: Empty space right now matches V1, anything we'd need to consider as a "breaking" change (nor quite, but you know what I mean) and impact to things like the MakeCode simulator. We can continue that conversation over lancaster-university/codal-microbit-v2#425. |
@martinwork also suggested we could apply this patch inside |
I was thinking about this, but one downside is that the |
Ah, well spotted @microbit-carlos . That's out then! This looks like a similar problem Could we add, say BitmapFont::getNonNull()? |
Having a 'safe' proxy for this situation makes sense to me. I suggest a Personally I prefer the |
... having just written that, it now occurs to me that we could just extend the |
Thanks John, I think both options would work, but: I was looking into implementing this as a default parameter, using the null char as the default, so that it can return a NULL pointer by default (as discussed in our standup). This way we could pass a character without casting or implicit casting. const uint8_t* BitmapFont::get(char c, char defaultChar = '\0'); But this doesn't help if we wanted to change it in the future to be able to return an "error glyph" (lancaster-university/codal-microbit-v2#425). To be able to support that we'd need to end up using an int as the type (so -1 for NULL, -2 for the error glyph, etc and we end up with more and more if statements inside const uint8_t* BitmapFont::get(char c, int defaultChar = -1); And to be fair, this does not save us anything, as we still need to update all relevant calls to add/change the extra argument (from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed in a call, good to go 🚀
Currently it was scrolling a NULL pointer:
This matches the V1 and MakeCode sim behaviour.