Fix special menu not shown, when SD card is not inserted (Fix for #463)

This commit is contained in:
Knutwurst
2023-05-28 17:13:20 +02:00
parent 22dedaeb81
commit ae82913d1f
2 changed files with 49 additions and 51 deletions

View File

@@ -44,7 +44,7 @@
#define CUSTOM_BUILD_VERSION "1.5.0-b5" #define CUSTOM_BUILD_VERSION "1.5.0-b5"
#ifndef STRING_DISTRIBUTION_DATE #ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2023-05-24" #define STRING_DISTRIBUTION_DATE "2023-05-27"
#endif #endif
/** /**

View File

@@ -313,7 +313,7 @@
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#if ENABLED(FILAMENT_RUNOUT_SENSOR) #if ENABLED(FILAMENT_RUNOUT_SENSOR)
if (READ(FIL_RUNOUT_PIN)) { if (READ(FIL_RUNOUT_PIN)) {
#if ENABLED(ANYCUBIC_LCD_DEBUG) #if ENABLED(ANYCUBIC_TFT_DEBUG)
SERIAL_ECHOLNPGM("TFT Serial Debug: Resume Print with filament sensor still tripped... "); SERIAL_ECHOLNPGM("TFT Serial Debug: Resume Print with filament sensor still tripped... ");
#endif #endif
@@ -360,7 +360,7 @@
void AnycubicTouchscreenClass::HandleSpecialMenu() { void AnycubicTouchscreenClass::HandleSpecialMenu() {
#if ENABLED(KNUTWURST_SPECIAL_MENU) #if ENABLED(KNUTWURST_SPECIAL_MENU)
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOPGM("DEBUG: Special Menu Selection: ", currentTouchscreenSelection); SERIAL_ECHOPGM("TFT Serial Debug: Special Menu Selection: ", currentTouchscreenSelection);
SERIAL_EOL(); SERIAL_EOL();
#endif #endif
if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_SPECIAL_MENU_L)) != NULL) if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_SPECIAL_MENU_L)) != NULL)
@@ -766,7 +766,7 @@
zOffsetBuffer = SM_BLTZ_DISP_L; zOffsetBuffer = SM_BLTZ_DISP_L;
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOPGM("DEBUG: Current probe.offset.z: ", float(probe.offset.z)); SERIAL_ECHOPGM("TFT Serial Debug: Current probe.offset.z: ", float(probe.offset.z));
SERIAL_EOL(); SERIAL_EOL();
#endif #endif
@@ -1093,7 +1093,7 @@
} }
void AnycubicTouchscreenClass::UserConfirmRequired(const char * const msg) { void AnycubicTouchscreenClass::UserConfirmRequired(const char * const msg) {
#if ENABLED(ANYCUBIC_LCD_DEBUG) #if ENABLED(ANYCUBIC_TFT_DEBUG)
SERIAL_ECHOLNPGM("TFT Serial Debug: OnUserConfirmRequired triggered... ", msg); SERIAL_ECHOLNPGM("TFT Serial Debug: OnUserConfirmRequired triggered... ", msg);
#endif #endif
@@ -1301,27 +1301,29 @@
case 13: // A13 SELECTION FILE case 13: // A13 SELECTION FILE
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (isMediaInserted()) { {
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);
currentFileOrDirectory[0] = 0; #ifdef ANYCUBIC_TFT_DEBUG
SENDLINE_DBG_PGM("J21", "TFT Serial Debug: Clear file selection... J21 "); // J21 Not File Selected SERIAL_ECHOPGM("TFT Serial Debug: currentTouchscreenSelection: ", currentTouchscreenSelection);
SENDLINE_PGM(""); SERIAL_EOL();
#endif
} }
else if (TFTstrchr_pointer[4] == '<') { else if (TFTstrchr_pointer[4] == '<') {
strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 4); strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 4);
SpecialMenu = true; #ifdef ANYCUBIC_TFT_DEBUG
currentFileOrDirectory[0] = 0; SERIAL_ECHOPGM("J21", "TFT Serial Debug: Clear file selection... J21 ");
SENDLINE_DBG_PGM("J21", "TFT Serial Debug: Clear file selection... J21 "); // J21 Not File Selected SERIAL_EOL();
SENDLINE_PGM(""); #endif
} }
else { else {
currentTouchscreenSelection[0] = 0; if (SpecialMenu == false)
currentTouchscreenSelection[0] = 0;
if (starpos) *(starpos - 1) = '\0'; if (starpos != NULL) *(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
} }
} }
@@ -1510,55 +1512,51 @@
break; break;
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: currentTouchscreenSelection: ", currentTouchscreenSelection);
SERIAL_EOL(); SERIAL_EOL();
#endif #endif
if (isMediaInserted()) {
if (strlen(currentTouchscreenSelection) > 0) { if (strlen(currentTouchscreenSelection) > 0) {
FileList currentFileList; FileList currentFileList;
if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_S)) != NULL) if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_S)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_L)) != NULL) || (strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_L)) != NULL)
) { ) {
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Directory UP (cd ..)");
#endif
currentFileList.upDir();
}
else {
if (currentTouchscreenSelection[0] == '<') {
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Directory UP (cd ..)"); SERIAL_ECHOLNPGM("TFT Serial Debug: Enter Special Menu");
#endif #endif
currentFileList.upDir(); HandleSpecialMenu();
} }
else { else {
if (currentTouchscreenSelection[0] == '<') { #ifdef ANYCUBIC_TFT_DEBUG
#ifdef ANYCUBIC_TFT_DEBUG SERIAL_ECHOLNPGM("TFT Serial Debug: Not a menu. Must be a directory!");
SERIAL_ECHOLNPGM("TFT Serial Debug: Enter Special Menu"); #endif
#endif
HandleSpecialMenu();
}
else {
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Not a menu. Must be a directory!");
#endif
#if ENABLED(KNUTWURST_DGUS2_TFT) #if ENABLED(KNUTWURST_DGUS2_TFT)
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); card.cd(currentFileOrDirectory);
#else #else
currentFileList.changeDir(currentTouchscreenSelection); currentFileList.changeDir(currentTouchscreenSelection);
#endif #endif
}
} }
} }
} }
if (SpecialMenu == false) if (SpecialMenu == false)
currentTouchscreenSelection[0] = 0; currentTouchscreenSelection[0] = 0;
}
#endif // ifdef SDSUPPORT #endif // ifdef SDSUPPORT
break; break;
#ifdef SERVO_ENDSTOPS
case 27: // A27 servos angles adjust
break;
#endif
case 28: // A28 filament test case 28: // A28 filament test
{ {
@@ -1950,7 +1948,7 @@
if (ELAPSED(ms, nextStopCheck)) { if (ELAPSED(ms, nextStopCheck)) {
nextStopCheck = ms + 1000UL; nextStopCheck = ms + 1000UL;
if (mediaPrintingState == AMPRINTSTATE_STOP_REQUESTED) { if (mediaPrintingState == AMPRINTSTATE_STOP_REQUESTED) {
#if ENABLED(ANYCUBIC_LCD_DEBUG) #if ENABLED(ANYCUBIC_TFT_DEBUG)
SERIAL_ECHOLNPGM("TFT Serial Debug: Finished stopping print, releasing motors ..."); SERIAL_ECHOLNPGM("TFT Serial Debug: Finished stopping print, releasing motors ...");
#endif #endif
mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;