From 1df0ee59d2bc6301442a051caefb109a102279e9 Mon Sep 17 00:00:00 2001 From: Knutwurst <36196269+knutwurst@users.noreply.github.com> Date: Mon, 29 May 2023 20:34:08 +0200 Subject: [PATCH] Set correct filament sensor pins for chiron in correspondig header and enable new file list implementation. --- Marlin/Configuration_adv.h | 12 +-- .../extui/knutwurst/anycubic_touchscreen.cpp | 88 ++++++++++++++++--- Marlin/src/pins/ramps/pins_TRIGORILLA_14.h | 6 ++ .../src/pins/ramps/pins_TRIGORILLA_CHIRON.h | 2 +- 4 files changed, 91 insertions(+), 17 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 745beafb..67bd8e22 100755 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2678,11 +2678,11 @@ // For direct drive, the full length of the nozzle. #else #define PAUSE_PARK_RETRACT_FEEDRATE 40 // (mm/s) Initial retract feedrate. - #define PAUSE_PARK_RETRACT_LENGTH 4 // (mm) Initial retract. + #define PAUSE_PARK_RETRACT_LENGTH 1 // (mm) Initial retract. // This short retract is done immediately, before parking the nozzle. - #define FILAMENT_CHANGE_UNLOAD_FEEDRATE 30 // (mm/s) Unload filament feedrate. This can be pretty fast. - #define FILAMENT_CHANGE_UNLOAD_ACCEL 25 // (mm/s^2) Lower acceleration may allow a faster feedrate. - #define FILAMENT_CHANGE_UNLOAD_LENGTH 25 // (mm) The length of filament for a complete unload. + #define FILAMENT_CHANGE_UNLOAD_FEEDRATE 0 // (mm/s) Unload filament feedrate. This can be pretty fast. + #define FILAMENT_CHANGE_UNLOAD_ACCEL 30 // (mm/s^2) Lower acceleration may allow a faster feedrate. + #define FILAMENT_CHANGE_UNLOAD_LENGTH 0 // (mm) The length of filament for a complete unload. // For Bowden, the full length of the tube and nozzle. // For direct drive, the full length of the nozzle. // Set to 0 for manual unloading. @@ -2690,8 +2690,8 @@ #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0 // (mm) Slow length, to allow time to insert material. // 0 to disable start loading and skip to fast load only #define FILAMENT_CHANGE_FAST_LOAD_FEEDRATE 30 // (mm/s) Load filament feedrate. This can be pretty fast. - #define FILAMENT_CHANGE_FAST_LOAD_ACCEL 25 // (mm/s^2) Lower acceleration may allow a faster feedrate. - #define FILAMENT_CHANGE_FAST_LOAD_LENGTH 10 // (mm) Load length of filament, from extruder gear to nozzle. + #define FILAMENT_CHANGE_FAST_LOAD_ACCEL 10 // (mm/s^2) Lower acceleration may allow a faster feedrate. + #define FILAMENT_CHANGE_FAST_LOAD_LENGTH 5 // (mm) Load length of filament, from extruder gear to nozzle. // For Bowden, the full length of the tube and nozzle. // For direct drive, the full length of the nozzle. #endif diff --git a/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp index e328da8e..492759e4 100755 --- a/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp +++ b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp @@ -1043,13 +1043,15 @@ void AnycubicTouchscreenClass::RenderCurrentFileList() { SENDLINE_PGM(SM_SPECIAL_MENU_L); } else { - if (CodeSeen('S')) + if (CodeSeen('S')) { selectedNumber = CodeValue(); + } - if (SpecialMenu) + if (SpecialMenu) { RenderSpecialMenu(selectedNumber); - else if (selectedNumber <= currentFileList.count()) + } else if (selectedNumber <= currentFileList.count()) { RenderCurrentFolder(selectedNumber); + } } SENDLINE_PGM("END"); // Filelist stop } @@ -1278,24 +1280,90 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) { SERIAL_ECHOLNPGM(SM_DIR_UP_L); #endif } - } - else { + } else { currentFileList.seek(count - 1, false); #if ENABLED(ANYCUBIC_LCD_DEBUG) SERIAL_ECHOLN(currentFileList.filename()); #endif + /* if (currentFileList.isDir()) { SEND_PGM("/"); SENDLINE(currentFileList.shortFilename()); SEND_PGM("/"); SENDLINE(currentFileList.filename()); - - } - else { + } else { SENDLINE(currentFileList.shortFilename()); SENDLINE(currentFileList.filename()); } + */ + + // The longname may not be filed, so we use the built-in fallback here. + const char* fileName = currentFileList.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 (currentFileList.isDir()) { + #if ENABLED(KNUTWURST_DGUS2_TFT) + SEND_PGM("/"); + SEND(currentFileList.shortFilename()); + SENDLINE_PGM(".GCO"); + SEND_PGM("/"); + SEND(outputString); + SENDLINE_PGM(".gcode"); + #else + SEND_PGM("/"); + SEND(currentFileList.shortFilename()); + SEND_PGM("/"); + SENDLINE(outputString); + #endif + SERIAL_ECHO(count); + SERIAL_ECHOPGM(": /"); + SERIAL_ECHOLN(outputString); + } else { + SENDLINE(currentFileList.shortFilename()); + SENDLINE(outputString); + SERIAL_ECHO(count); + SERIAL_ECHOPGM(": "); + SERIAL_ECHOLN(outputString); + } } } } @@ -1546,8 +1614,8 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) { #endif { if (CodeSeen('S')) filenumber = CodeValue(); - PrintList(); - //RenderCurrentFileList(); + //PrintList(); + RenderCurrentFileList(); } #endif break; diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index e74dfe41..9bd09926 100755 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -86,6 +86,12 @@ #define OUTAGECON_PIN 58 #endif + #if ANY(KNUTWURST_CHIRON, KNUTWURST_4MAXP2) + #define FIL_RUNOUT_PIN 33 + #else + #define FIL_RUNOUT_PIN 19 + #endif + #if ENABLED(TRIGORILLA_MAPPING_CHIRON) #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 33 diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_CHIRON.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_CHIRON.h index 843614cd..95826579 100755 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_CHIRON.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_CHIRON.h @@ -64,7 +64,7 @@ #define TG_FAN1_PIN 7 // Anycubic Kossel: Unused #define TG_FAN2_PIN 44 // Anycubic Kossel: Hotend fan #define CONTROLLER_FAN_PIN TG_FAN1_PIN -#define FIL_RUNOUT_PIN 19 +#define FIL_RUNOUT_PIN 33 #define BEEPER_PIN 31 #define SDSS 53 #define LED_PIN 13