optimisation: reduce code size in showing file name being printed

Change in memory:
Flash: -52 bytes
SRAM: 0 bytes
This commit is contained in:
Guðni Már Gilbert 2022-11-11 18:42:13 +00:00 committed by DRracer
parent a2bbc4f585
commit 0af7ef0201
1 changed files with 4 additions and 8 deletions

View File

@ -584,25 +584,21 @@ void lcdui_print_status_line(void) {
lcd_status_message_timeout.expired_cont(LCD_STATUS_INFO_TIMEOUT)) lcd_status_message_timeout.expired_cont(LCD_STATUS_INFO_TIMEOUT))
{ {
// If printing from SD, show what we are printing // If printing from SD, show what we are printing
const char* longFilenameOLD = (card.longFilename[0] ? card.longFilename : card.filename); const char* longFilenameOLD = (card.longFilename[0] ? card.longFilename : card.filename);
if(strlen(longFilenameOLD) > LCD_WIDTH) { if(strlen(longFilenameOLD) > LCD_WIDTH) {
uint8_t gh = scrollstuff; uint8_t gh = scrollstuff;
while (((gh - scrollstuff) < LCD_WIDTH)) { while (((gh - scrollstuff) < LCD_WIDTH)) {
lcd_putc_at(gh - scrollstuff, 3, longFilenameOLD[gh - 1]);
if (longFilenameOLD[gh] == '\0') { if (longFilenameOLD[gh] == '\0') {
lcd_set_cursor(gh - scrollstuff, 3);
lcd_print(longFilenameOLD[gh - 1]);
scrollstuff = 0; scrollstuff = 0;
gh = scrollstuff; break; // Exit while loop
break;
} else { } else {
lcd_set_cursor(gh - scrollstuff, 3);
lcd_print(longFilenameOLD[gh - 1]);
gh++; gh++;
} }
} }
scrollstuff++; scrollstuff++;
} else { } else {
lcd_printf_P(PSTR("%-20s"), longFilenameOLD); lcd_print_pad(longFilenameOLD, LCD_WIDTH);
} }
} else { // Otherwise check for other special events } else { // Otherwise check for other special events
switch (custom_message_type) { switch (custom_message_type) {