Optimize SD card reader, sorting (#15395)

This commit is contained in:
Scott Lahteine
2019-09-28 15:28:05 -05:00
committed by GitHub
parent 1834d86df5
commit 2277c6dffc
5 changed files with 295 additions and 220 deletions

View File

@ -1002,14 +1002,14 @@ namespace ExtUI {
void FileList::upDir() {
#if ENABLED(SDSUPPORT)
card.updir();
card.cdup();
num_files = 0xFFFF;
#endif
}
void FileList::changeDir(const char * const dirname) {
#if ENABLED(SDSUPPORT)
card.chdir(dirname);
card.cd(dirname);
num_files = 0xFFFF;
#endif
}

View File

@ -246,13 +246,13 @@ void process_lcd_p_command(const char* command) {
// Find the name of the file to print.
// It's needed to echo the PRINTFILE option.
// The {S:L} command should've ensured the SD card was mounted.
card.getfilename(atoi(command));
card.selectFileByIndex(atoi(command));
// There may be a difference in how V1 and V2 LCDs handle subdirectory
// prints. Investigate more. This matches the V1 motion controller actions
// but the V2 LCD switches to "print" mode on {SYS:DIR} response.
if (card.flag.filenameIsDir) {
card.chdir(card.filename);
card.cd(card.filename);
write_to_lcd_P(PSTR("{SYS:DIR}"));
}
else {
@ -309,7 +309,7 @@ void process_lcd_s_command(const char* command) {
char message_buffer[MAX_CURLY_COMMAND];
uint16_t file_count = card.get_num_Files();
for (uint16_t i = 0; i < file_count; i++) {
card.getfilename(i);
card.selectFileByIndex(i);
sprintf_P(message_buffer, card.flag.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.longest_filename());
write_to_lcd(message_buffer);
}

View File

@ -39,7 +39,7 @@
#endif
void lcd_sd_updir() {
ui.encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
ui.encoderPosition = card.cdup() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
encoderTopLine = 0;
screen_changed = true;
ui.refresh();
@ -115,7 +115,7 @@ class MenuItem_sdfile {
class MenuItem_sdfolder {
public:
static void action(CardReader &theCard) {
card.chdir(theCard.filename);
card.cd(theCard.filename);
encoderTopLine = 0;
ui.encoderPosition = 2 * (ENCODER_STEPS_PER_MENU_ITEM);
screen_changed = true;