Fix that you could not get out of a selected directory. Refactor Touchscreen file handling.

This commit is contained in:
Knutwurst
2023-05-29 11:20:22 +02:00
parent 69efa3376a
commit 952e0db31e
2 changed files with 25 additions and 26 deletions

View File

@@ -34,7 +34,7 @@
#include "../../../module/settings.h" #include "../../../module/settings.h"
#include "../../../module/stepper.h" #include "../../../module/stepper.h"
//#define ANYCUBIC_TFT_DEBUG #define ANYCUBIC_TFT_DEBUG
#ifdef ANYCUBIC_TOUCHSCREEN #ifdef ANYCUBIC_TOUCHSCREEN
#include "./anycubic_touchscreen.h" #include "./anycubic_touchscreen.h"
@@ -1305,25 +1305,23 @@
starpos = (strchr(TFTstrchr_pointer + 4, '*')); starpos = (strchr(TFTstrchr_pointer + 4, '*'));
if (TFTstrchr_pointer[4] == '/') { if (TFTstrchr_pointer[4] == '/') {
strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 5); strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 5);
#ifdef ANYCUBIC_TFT_DEBUG currentFileOrDirectory[0] = 0;
SERIAL_ECHOPGM("TFT Serial Debug: currentTouchscreenSelection: ", currentTouchscreenSelection); SENDLINE_DBG_PGM("J21", "TFT Serial Debug: Clear file selection... J21 "); // J21 Not File Selected
SERIAL_EOL(); SENDLINE_PGM("");
#endif
} }
else if (TFTstrchr_pointer[4] == '<') { else if (TFTstrchr_pointer[4] == '<') {
strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 4); strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 4);
#ifdef ANYCUBIC_TFT_DEBUG SpecialMenu = true;
SERIAL_ECHOPGM("J21", "TFT Serial Debug: Clear file selection... J21 "); currentFileOrDirectory[0] = 0;
SERIAL_EOL(); SENDLINE_DBG_PGM("J21", "TFT Serial Debug: Clear file selection... J21 "); // J21 Not File Selected
#endif SENDLINE_PGM("");
} }
else { else {
if (SpecialMenu == false) currentTouchscreenSelection[0] = 0;
currentTouchscreenSelection[0] = 0;
if (starpos != NULL) *(starpos - 1) = '\0'; if (starpos) *(starpos - 1) = '\0';
strcpy(currentFileOrDirectory, TFTstrchr_pointer + 4);
strcpy(currentFileOrDirectory, TFTstrchr_pointer + 4);
SENDLINE_DBG_PGM_VAL("J20", "TFT Serial Debug: File Selected... J20 ", currentFileOrDirectory); // J20 File Selected SENDLINE_DBG_PGM_VAL("J20", "TFT Serial Debug: File Selected... J20 ", currentFileOrDirectory); // J20 File Selected
} }
} }
@@ -1514,15 +1512,16 @@
case 26: // A26 refresh SD case 26: // A26 refresh SD
{ {
#ifdef SDSUPPORT #ifdef SDSUPPORT
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOPGM("TFT Serial Debug: currentTouchscreenSelection: ", currentTouchscreenSelection); SERIAL_ECHOPGM("TFT Serial Debug: RefreshSD(): currentTouchscreenSelection: ", currentTouchscreenSelection);
SERIAL_EOL(); SERIAL_EOL();
#endif SERIAL_ECHOPGM("TFT Serial Debug: RefreshSD(): currentFileOrDirectory: ", currentFileOrDirectory);
SERIAL_EOL();
#endif
if (strlen(currentTouchscreenSelection) > 0) {
FileList currentFileList; FileList currentFileList;
if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_S)) != NULL) if ((strcasestr_P(currentFileOrDirectory, PSTR(SM_DIR_UP_S)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_L)) != NULL) || (strcasestr_P(currentFileOrDirectory, PSTR(SM_DIR_UP_L)) != NULL)
) { ) {
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Directory UP (cd ..)"); SERIAL_ECHOLNPGM("TFT Serial Debug: Directory UP (cd ..)");
@@ -1545,16 +1544,16 @@
strcpy(currentFileOrDirectory, currentTouchscreenSelection); strcpy(currentFileOrDirectory, currentTouchscreenSelection);
int currentFileLen = strlen(currentFileOrDirectory); int currentFileLen = strlen(currentFileOrDirectory);
currentFileOrDirectory[currentFileLen - 4] = '\0'; currentFileOrDirectory[currentFileLen - 4] = '\0';
card.cd(currentFileOrDirectory); currentFileList.changeDir(currentFileOrDirectory);
#else #else
currentFileList.changeDir(currentTouchscreenSelection); currentFileList.changeDir(currentFileOrDirectory);
#endif #endif
} }
} }
} }
if (SpecialMenu == false) if (SpecialMenu == false)
currentTouchscreenSelection[0] = 0; currentTouchscreenSelection[0] = 0;
}
#endif // ifdef SDSUPPORT #endif // ifdef SDSUPPORT
break; break;

View File

@@ -332,8 +332,8 @@ void ResumePrint();
void ReheatNozzle(); void ReheatNozzle();
void ParkAfterStop(); void ParkAfterStop();
char currentTouchscreenSelection[30]; char currentTouchscreenSelection[64];
char currentFileOrDirectory[30]; char currentFileOrDirectory[64];
String flowRateBuffer; String flowRateBuffer;
String zOffsetBuffer; String zOffsetBuffer;
uint16_t MyFileNrCnt = 0; uint16_t MyFileNrCnt = 0;