Unify status scrolling further
This commit is contained in:
@@ -627,43 +627,27 @@ void ST7920_Lite_Status_Screen::draw_status_message() {
|
||||
if (slen <= LCD_WIDTH) {
|
||||
// String fits the LCD, so just print it
|
||||
write_str(str);
|
||||
for (; slen < LCD_WIDTH; ++slen) write_byte(' ');
|
||||
while (slen < LCD_WIDTH) { write_byte(' '); ++slen; }
|
||||
}
|
||||
else {
|
||||
// String is larger than the available space in screen.
|
||||
|
||||
// Get a pointer to the next valid UTF8 character
|
||||
const char *stat = str + ui.status_scroll_offset;
|
||||
|
||||
// Get the string remaining length
|
||||
const uint8_t rlen = utf8_strlen(stat);
|
||||
|
||||
// If we have enough characters to display
|
||||
if (rlen >= LCD_WIDTH) {
|
||||
// The remaining string fills the screen - Print it
|
||||
write_str(stat, LCD_WIDTH);
|
||||
}
|
||||
else {
|
||||
// The remaining string does not completely fill the screen
|
||||
write_str(stat); // The string leaves space
|
||||
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
|
||||
// and the string remaining length
|
||||
uint8_t rlen;
|
||||
const char *stat = ui.status_and_len(rlen);
|
||||
write_str(stat, LCD_WIDTH);
|
||||
|
||||
// If the remaining string doesn't completely fill the screen
|
||||
if (rlen < LCD_WIDTH) {
|
||||
write_byte('.'); // Always at 1+ spaces left, draw a dot
|
||||
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
|
||||
if (--chars) { // Draw a second dot if there's space
|
||||
write_byte('.');
|
||||
if (--chars)
|
||||
write_str(str, chars); // Print a second copy of the message
|
||||
if (--chars) write_str(str, chars); // Print a second copy of the message
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust by complete UTF8 characters
|
||||
if (ui.status_scroll_offset < slen) {
|
||||
ui.status_scroll_offset++;
|
||||
while (!START_OF_UTF8_CHAR(str[ui.status_scroll_offset]))
|
||||
ui.status_scroll_offset++;
|
||||
}
|
||||
else
|
||||
ui.status_scroll_offset = 0;
|
||||
ui.advance_status_scroll();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user