-
Notifications
You must be signed in to change notification settings - Fork 880
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
Update Screen.cpp - Sleeping screen with owner.short_name #4109
Conversation
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.
Looks good on my devices 👍
src/graphics/Screen.cpp
Outdated
// Create a new string that is the concatenation of idText and " sleeping." | ||
size_t idTextLen = strlen(idText); | ||
char displayStr[idTextLen + 12]; // Allocate enough space for the new string | ||
strcpy(displayStr, idText); // Copy idText to the new string |
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.
Perhaps more consolidated to write in this way with a single expression?
sprintf(displayStr, "%s sleeping.", owner.short_name);
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.
Also, no need to declare idText this way. You can just reference owner.short_name
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.
Absolutely guys. I'm not a C++ programmer and just tried that the code works. I also don't like the strlen check on a maybe unassigned var. So if you guys know it better - pls change.
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.
Thought about something like
if (!idText || strlen(idText) == 0) {
for the check of idText ?
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.
Actually, is it possible to get into a situation where short name is has zero length? It might not be an issue? Now I think about it though, I'm not sure what would happen with emoji short names. I should check if this is a problem with the existing E-Ink screensaver code too.
Update: okay yeah, emoji short names cause weird stuff here, but the same issue shows up with existing code too. I'll see if there's any convenient way to handle it.
Just an update: the new if (haveGlyphs(owner.short_name)) {
// use the short name
}
else {
// don't use the short name
} A bit of house keeping: can we also move the haveGlyphs definition inside |
Added owner.short_name to "Sleeping" screen message. Didn't check variable.
Another try :)
Next try :)
Last try :/
Really last try :=
Proposals implemented incl. check of haveGlyphs
snprintf - Safety related
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.
idText used for common style with the following drawScreensaverOverlay.
snprintf for mem safety and 30 chars gives enough space for later changes of text
Waited with this. If OK for you guys, I would add the short_name and HEX ID at the boot screen e.g. EU_868:ad24:!A1B2C3 - so every device can immediately be identified at startup and the unique ID is visible - and then we need this haveGlyphs also when using the other devices. |
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.
If OK for you guys, I would add the short_name and HEX ID at the boot screen e.g. EU_868:ad24:!A1B2C3
No strong opinion on this one!
and then we need this haveGlyphs also when using the other devices.
It's possible, although I'm not sure about the idea. We're hiding the missing characters here for cosmetic purposes, but in some other situations, it might be important that we continue to identify them with ¿
.
I still think this is a great idea. Keen to see it included! |
Added owner.short_name to "Sleeping" screen message. Didn't check variable availablility - not C++ experienced. :/
Pls recheck.
Thank you for sending in a pull request, here's some tips to get started!
(Please delete all these tips and replace with your text)
to say "hey, I think this idea X should be implemented and I'm starting work on it. My general plan is Y, any feedback
is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc...
because it automatically follows our indentation rules and its auto reformatting will not cause spurious changes to lines.