From 6c4a0a887ad7af325f7401dce84f36146a2b27e1 Mon Sep 17 00:00:00 2001 From: Knutwurst <36196269+knutwurst@users.noreply.github.com> Date: Mon, 29 May 2023 20:48:58 +0200 Subject: [PATCH] Remove old PrintList() implementation + some cleanup --- .../extui/knutwurst/anycubic_touchscreen.cpp | 330 +----------------- .../extui/knutwurst/anycubic_touchscreen.h | 1 - 2 files changed, 4 insertions(+), 327 deletions(-) diff --git a/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp index be91a997..6ffd9e1e 100755 --- a/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp +++ b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp @@ -705,329 +705,6 @@ } - void AnycubicTouchscreenClass::PrintList() { - SENDLINE_PGM("FN "); // Filelist start - - #if ENABLED(KNUTWURST_SPECIAL_MENU) - if (MMLMenu) { - switch (filenumber) { - case 0: // Page 1 - SENDLINE_PGM(SM_MESH_START_S); - SENDLINE_PGM(SM_MESH_START_L); - SENDLINE_PGM(SM_Z_UP_01_S); - SENDLINE_PGM(SM_Z_UP_01_L); - SENDLINE_PGM(SM_Z_DN_01_S); - SENDLINE_PGM(SM_Z_DN_01_L); - SENDLINE_PGM(SM_Z_UP_002_S); - SENDLINE_PGM(SM_Z_UP_002_L); - break; - - case 4: // Page 2 - SENDLINE_PGM(SM_Z_DN_002_S); - SENDLINE_PGM(SM_Z_DN_002_L); - SENDLINE_PGM(SM_Z_UP_001_S); - SENDLINE_PGM(SM_Z_UP_001_L); - SENDLINE_PGM(SM_Z_DN_001_S); - SENDLINE_PGM(SM_Z_DN_001_L); - SENDLINE_PGM(SM_MESH_NEXT_S); - SENDLINE_PGM(SM_MESH_NEXT_L); - break; - - case 8: // Page 2 - SENDLINE_PGM(SM_SAVE_EEPROM_S); - SENDLINE_PGM(SM_SAVE_EEPROM_L); - SENDLINE_PGM(SM_BACK_S); - SENDLINE_PGM(SM_BACK_L); - break; - - default: - break; - } - } - else if (FlowMenu) { - flowRateBuffer = SM_FLOW_DISP_L; - flowRateBuffer.replace("XXX", String(currentFlowRate)); - - switch (filenumber) { - case 0: // Page 1 - SENDLINE_PGM(SM_FLOW_DISP_S); - SENDLINE(flowRateBuffer.c_str()); - SENDLINE_PGM(SM_FLOW_UP_S); - SENDLINE_PGM(SM_FLOW_UP_L); - SENDLINE_PGM(SM_FLOW_DN_S); - SENDLINE_PGM(SM_FLOW_DN_L); - SENDLINE_PGM(SM_FLOW_EXIT_S); - SENDLINE_PGM(SM_FLOW_EXIT_L); - break; - - default: - break; - } - } - else if (BLTouchMenu) { - zOffsetBuffer = SM_BLTZ_DISP_L; - - #ifdef ANYCUBIC_TFT_DEBUG - SERIAL_ECHOPGM("TFT Serial Debug: Current probe.offset.z: ", float(probe.offset.z)); - SERIAL_EOL(); - #endif - - zOffsetBuffer.replace("XXXXX", String(float(probe.offset.z))); - - switch (filenumber) { - case 0: // Page 1 - SENDLINE_PGM(SM_BLTZ_DISP_S); - SENDLINE(zOffsetBuffer.c_str()); - SENDLINE_PGM(SM_BLTZ_UP_S); - SENDLINE_PGM(SM_BLTZ_UP_L); - SENDLINE_PGM(SM_BLTZ_DN_S); - SENDLINE_PGM(SM_BLTZ_DN_L); - SENDLINE_PGM(SM_BLTOUCH_S); - SENDLINE_PGM(SM_BLTOUCH_L); - break; - - case 4: // Page 2 - SENDLINE_PGM(SM_BLTZ_EXIT_S); - SENDLINE_PGM(SM_BLTZ_EXIT_L); - break; - - default: - break; - } - } - else if (LevelMenu) { - switch (filenumber) { - case 0: // Page 1 - SENDLINE_PGM(SM_EZLVL_P1_S); - SENDLINE_PGM(SM_EZLVL_P1_L); - SENDLINE_PGM(SM_EZLVL_P2_S); - SENDLINE_PGM(SM_EZLVL_P2_L); - SENDLINE_PGM(SM_EZLVL_P3_S); - SENDLINE_PGM(SM_EZLVL_P3_L); - SENDLINE_PGM(SM_EZLVL_P4_S); - SENDLINE_PGM(SM_EZLVL_P4_L); - break; - - case 4: // Page 2 - SENDLINE_PGM(SM_EZLVL_EXIT_S); - SENDLINE_PGM(SM_EZLVL_EXIT_L); - break; - - default: - break; - } - } - else if (SpecialMenu) { - switch (filenumber) { - case 0: // Page 1 - SENDLINE_PGM(SM_FLOWMENU_S); - SENDLINE_PGM(SM_FLOWMENU_L); - SENDLINE_PGM(SM_PREHEAT_BED_S); - SENDLINE_PGM(SM_PREHEAT_BED_L); - SENDLINE_PGM(SM_PAUSE_S); - SENDLINE_PGM(SM_PAUSE_L); - SENDLINE_PGM(SM_RESUME_S); - SENDLINE_PGM(SM_RESUME_L); - break; - - #if NONE(KNUTWURST_BLTOUCH, KNUTWURST_TFT_LEVELING) - case 4: // Page 2 for Manual Mesh Bed Level - SENDLINE_PGM(SM_EZLVL_MENU_S); - SENDLINE_PGM(SM_EZLVL_MENU_L); - SENDLINE_PGM(SM_MESH_MENU_S); - SENDLINE_PGM(SM_MESH_MENU_L); - SENDLINE_PGM(SM_PID_HOTEND_S); - SENDLINE_PGM(SM_PID_HOTEND_L); - SENDLINE_PGM(SM_PID_BED_S); - SENDLINE_PGM(SM_PID_BED_L); - break; - #endif - - #if ENABLED(KNUTWURST_BLTOUCH) - case 4: // Page 2 for BLTouch - SENDLINE_PGM(SM_EZLVL_MENU_S); - SENDLINE_PGM(SM_EZLVL_MENU_L); - SENDLINE_PGM(SM_BLTZMENU_S); - SENDLINE_PGM(SM_BLTZMENU_L); - SENDLINE_PGM(SM_PID_HOTEND_S); - SENDLINE_PGM(SM_PID_HOTEND_L); - SENDLINE_PGM(SM_PID_BED_S); - SENDLINE_PGM(SM_PID_BED_L); - break; - #endif - - #if ENABLED(KNUTWURST_TFT_LEVELING) - case 4: // Page 2 for Chiron ABL - SENDLINE_PGM(SM_EZLVL_MENU_S); - SENDLINE_PGM(SM_EZLVL_MENU_L); - SENDLINE_PGM(SM_RESETLV_S); - SENDLINE_PGM(SM_RESETLV_L); - SENDLINE_PGM(SM_PID_HOTEND_S); - SENDLINE_PGM(SM_PID_HOTEND_L); - SENDLINE_PGM(SM_PID_BED_S); - SENDLINE_PGM(SM_PID_BED_L); - break; - #endif - - case 8: // Page 3 - SENDLINE_PGM(SM_LOAD_DEFAULTS_S); - SENDLINE_PGM(SM_LOAD_DEFAULTS_L); - SENDLINE_PGM(SM_SAVE_EEPROM_S); - SENDLINE_PGM(SM_SAVE_EEPROM_L); - SENDLINE_PGM(SM_DIS_FILSENS_S); - SENDLINE_PGM(SM_DIS_FILSENS_L); - SENDLINE_PGM(SM_EN_FILSENS_S); - SENDLINE_PGM(SM_EN_FILSENS_L); - break; - - case 12: // Page 3 - SENDLINE_PGM(SM_EXIT_S); - SENDLINE_PGM(SM_EXIT_L); - break; - - default: - break; - } - } - #endif // if ENABLED(KNUTWURST_SPECIAL_MENU) - - #ifdef SDSUPPORT - #if ENABLED(KNUTWURST_SPECIAL_MENU) - else if (card.isMounted()) - #else - if (card.isMounted()) - #endif - { - int count = filenumber; - int max_files; - int filesOnSDCard = card.countFilesInWorkDir(); - - if ((filesOnSDCard - filenumber) < 4) { - max_files = filesOnSDCard; - #ifdef ANYCUBIC_TFT_DEBUG - SERIAL_ECHOLN("max_files = filesOnSDCard;"); - #endif - } - else { - max_files = filenumber + 3; - #ifdef ANYCUBIC_TFT_DEBUG - SERIAL_ECHOLN("max_files = filenumber + 3;"); - #endif - } - - if (filesOnSDCard == 3) filenumber = 0; - - #ifdef ANYCUBIC_TFT_DEBUG - SERIAL_ECHOPGM("filesOnSDCard: "); - SERIAL_ECHOLN(filesOnSDCard); - SERIAL_ECHOPGM("filenumber: "); - SERIAL_ECHOLN(filenumber); - SERIAL_ECHOPGM("max_files: "); - SERIAL_ECHOLN(max_files); - SERIAL_ECHOPGM("count: "); - SERIAL_ECHOLN(count); - #endif - - for (count = filenumber; count <= max_files; count++) { - if (count == 0) { // Special Entry - if (strcmp(card.getWorkDirName(), "/") == 0) { - SENDLINE_PGM(SM_SPECIAL_MENU_S); - SENDLINE_PGM(SM_SPECIAL_MENU_L); - SERIAL_ECHO(count); - SERIAL_ECHO(": "); - SERIAL_ECHOLNPGM(SM_SPECIAL_MENU_L); - } - else { - SENDLINE_PGM(SM_DIR_UP_S); - SENDLINE_PGM(SM_DIR_UP_L); - SERIAL_ECHO(count); - SERIAL_ECHO(": "); - SERIAL_ECHOLNPGM(SM_DIR_UP_L); - } - } - else { - card.selectFileByIndex(count - 1); - - // The longname may not be filed, so we use the built-in fallback here. - char* fileName = card.longest_filename(); - int fileNameLen = strlen(fileName); - bool fileNameWasCut = false; - - // Cut off too long filenames. - // They don't fit on the screen anyway. - #if ENABLED(KNUTWURST_DGUS2_TFT) - if (fileNameLen >= MAX_PRINTABLE_FILENAME_LEN) { - fileNameWasCut = true; - fileNameLen = MAX_PRINTABLE_FILENAME_LEN; - } - #endif - - char outputString[fileNameLen]; - - // Bugfix for non-printable special characters - // which are now replaced by underscores. - for (unsigned char i = 0; i <= fileNameLen; i++) { - if (i >= fileNameLen) { - outputString[i] = ' '; - } - else { - outputString[i] = fileName[i]; - if (!isPrintable(outputString[i])) - outputString[i] = '_'; - } - } - - // I know, it's ugly, but it's faster than a string lib - if (fileNameWasCut) { - outputString[fileNameLen - 7] = '~'; - outputString[fileNameLen - 6] = '.'; - outputString[fileNameLen - 5] = 'g'; - outputString[fileNameLen - 4] = 'c'; - outputString[fileNameLen - 3] = 'o'; - outputString[fileNameLen - 2] = 'd'; - outputString[fileNameLen - 1] = 'e'; - } - - outputString[fileNameLen] = '\0'; - - if (card.flag.filenameIsDir) { - #if ENABLED(KNUTWURST_DGUS2_TFT) - SEND_PGM("/"); - SEND(card.filename); - SENDLINE_PGM(".GCO"); - SEND_PGM("/"); - SEND(outputString); - SENDLINE_PGM(".gcode"); - #else - SEND_PGM("/"); - SEND(card.filename); - SEND_PGM("/"); - SENDLINE(outputString); - #endif - SERIAL_ECHO(count); - SERIAL_ECHOPGM(": /"); - SERIAL_ECHOLN(outputString); - } else { - SENDLINE(card.filename); - SENDLINE(outputString); - SERIAL_ECHO(count); - SERIAL_ECHOPGM(": "); - SERIAL_ECHOLN(outputString); - } - } - } - } - #endif // ifdef SDSUPPORT - else { - #if ENABLED(KNUTWURST_SPECIAL_MENU_WO_SD) - SENDLINE_PGM(SM_SPECIAL_MENU_S); - SENDLINE_PGM(SM_SPECIAL_MENU_L); - #endif - } - SENDLINE_PGM("END"); // Filelist stop - } - - void AnycubicTouchscreenClass::RenderCurrentFileList() { uint16_t selectedNumber = 0; FileList currentFileList; @@ -1249,10 +926,10 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) { FileList currentFileList; uint16_t count = selectedNumber; uint16_t max_files; - uint16_t dir_files = currentFileList.count(); + uint16_t filesOnSDCard = currentFileList.count(); - if ((dir_files - selectedNumber) < 4) { - max_files = dir_files; + if ((filesOnSDCard - selectedNumber) < 4) { + max_files = filesOnSDCard; #ifdef ANYCUBIC_TFT_DEBUG SERIAL_ECHOLN("max_files = filesOnSDCard;"); #endif @@ -1263,6 +940,7 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) { #endif } + if (filesOnSDCard == 3) filenumber = 0; for (count = selectedNumber; count <= max_files; count++) { if (count == 0) { // Special Entry diff --git a/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.h b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.h index 6693bcf3..095bd37e 100755 --- a/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.h +++ b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.h @@ -312,7 +312,6 @@ static AnycubicMediaPauseState mediaPauseState; int CodeValueInt(); float CodeValue(); bool CodeSeen(char); -void PrintList(); void StartPrint(); void PausePrint(); void StopPrint();