Browse Source

optimisation: reduce code size in showing file name being printed

Change in memory:
Flash: -52 bytes
SRAM: 0 bytes
Guðni Már Gilbert 1 year ago
parent
commit
0af7ef0201
1 changed files with 4 additions and 8 deletions
  1. 4 8
      Firmware/ultralcd.cpp

+ 4 - 8
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) {