From 0af7ef02019f139a221a64d811d00874c3ac36f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Fri, 11 Nov 2022 18:42:13 +0000 Subject: [PATCH] optimisation: reduce code size in showing file name being printed Change in memory: Flash: -52 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7f67c7be8..d636a0a14 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -584,25 +584,21 @@ void lcdui_print_status_line(void) { lcd_status_message_timeout.expired_cont(LCD_STATUS_INFO_TIMEOUT)) { // 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) { uint8_t gh = scrollstuff; while (((gh - scrollstuff) < LCD_WIDTH)) { + lcd_putc_at(gh - scrollstuff, 3, longFilenameOLD[gh - 1]); if (longFilenameOLD[gh] == '\0') { - lcd_set_cursor(gh - scrollstuff, 3); - lcd_print(longFilenameOLD[gh - 1]); scrollstuff = 0; - gh = scrollstuff; - break; + break; // Exit while loop } else { - lcd_set_cursor(gh - scrollstuff, 3); - lcd_print(longFilenameOLD[gh - 1]); gh++; } } scrollstuff++; } else { - lcd_printf_P(PSTR("%-20s"), longFilenameOLD); + lcd_print_pad(longFilenameOLD, LCD_WIDTH); } } else { // Otherwise check for other special events switch (custom_message_type) {