optimise lcd_sdcard_menu with lcd_print_pad

Change in memory:
Flash: -46 bytes
SRAM: 0 bytes
This commit is contained in:
Guðni Már Gilbert 2022-11-12 20:56:32 +00:00 committed by DRracer
parent 184e19dd60
commit 4f58812478
1 changed files with 8 additions and 16 deletions

View File

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