Преглед изворни кода

optimise lcd_sdcard_menu with lcd_print_pad

Change in memory:
Flash: -46 bytes
SRAM: 0 bytes
Guðni Már Gilbert пре 2 година
родитељ
комит
4f58812478
1 измењених фајлова са 8 додато и 16 уклоњено
  1. 8 16
      Firmware/ultralcd.cpp

+ 8 - 16
Firmware/ultralcd.cpp

@@ -6141,28 +6141,20 @@ void lcd_sdcard_menu()
 				_md->offset = 0; //redraw once again from the beginning.
 			if (_md->lcd_scrollTimer.expired(300) || rewindFlag)
 			{
-				uint8_t i = LCD_WIDTH - ((_md->isDir)?2:1);
+				uint8_t len = LCD_WIDTH - ((_md->isDir)? 2 : 1);
 				lcd_set_cursor(0, _md->row);
 				lcd_print('>');
 				if (_md->isDir)
 					lcd_print(LCD_STR_FOLDER[0]);
-				for (; i != 0; i--)
-				{
-					const char* c = (_md->scrollPointer + _md->offset + ((LCD_WIDTH - ((_md->isDir)?2:1)) - i));
-					lcd_print(c[0]);
-					if (c[1])
-						_md->lcd_scrollTimer.start();
-					else
-					{
-						_md->lcd_scrollTimer.stop();
-						break; //stop at the end of the string
-					}
-				}
-				if (i != 0) //adds spaces if string is incomplete or at the end (instead of null).
+
+				if( lcd_print_pad(&_md->scrollPointer[_md->offset], len) )
 				{
-					lcd_space(i);
+					_md->lcd_scrollTimer.start();
+					_md->offset++;
+				} else {
+					// stop at the end of the string
+					_md->lcd_scrollTimer.stop();
 				}
-				_md->offset++;
 			}
 			if (rewindFlag) //go back to sd_menu.
 			{