From a5765e8ca3e79a5b5c01cd2a275c64a6f82c77f9 Mon Sep 17 00:00:00 2001 From: studiodyne Date: Fri, 23 Sep 2022 08:00:05 +0200 Subject: [PATCH] Maintenance park --- Marlin/src/feature/pause.cpp | 4 ++ Marlin/src/feature/pause.h | 2 + Marlin/src/gcode/feature/pause/M125.cpp | 51 +++++++++++++++++++++---- Marlin/src/lcd/menu/menu_main.cpp | 15 +++++++- 4 files changed, 63 insertions(+), 9 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 1c2ea59d4daf4..f562399d13517 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -392,6 +392,10 @@ bool unload_filament(const_float_t unload_length, const bool show_lcd/*=false*/, * Return 'true' if pause was completed, 'false' for abort */ uint8_t did_pause_print = 0; +bool maintenance_park_enabled = false; +void maintenance_park_disable(){ + maintenance_park_enabled = false; +}; bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool show_lcd/*=false*/, const_float_t unload_length/*=0*/ DXC_ARGS) { DEBUG_SECTION(pp, "pause_print", true); diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index 134b1d1b3294d..84af976c83a05 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -72,6 +72,8 @@ enum PauseMessage : char { extern fil_change_settings_t fc_settings[EXTRUDERS]; extern uint8_t did_pause_print; +extern bool maintenance_park_enabled; +extern void maintenance_park_disable(); #define DXC_PARAMS OPTARG(DUAL_X_CARRIAGE, const int8_t DXC_ext=-1) #define DXC_ARGS OPTARG(DUAL_X_CARRIAGE, const int8_t DXC_ext) diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index 9b18eda4fbaee..74e5394c4bc9a 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -31,6 +31,7 @@ #include "../../../module/motion.h" #include "../../../module/printcounter.h" #include "../../../sd/cardreader.h" +#include "../../../MarlinCore.h" // for idle, kill #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../feature/powerloss.h" @@ -57,10 +58,19 @@ * W = Override park position W (requires AXIS*_NAME 'W') * Z = Override Z raise * + * //Park + unlocked LCD ( all menus available for maintenance during printing ) + * T = Maintenance park, if a value, add beeps each 'value' seconds (requires LCD to resume) + * * With an LCD menu: * P = Always show a prompt and await a response */ + void show_m125t(bool flipflap){ + if (flipflap) ui.set_status("M125T..."); + else ui.set_status("M125T"); + } + void GcodeSuite::M125() { + if (maintenance_park_enabled) return; // Initial retract before move to filament change position const float retract = TERN0(HAS_EXTRUDERS, -ABS(parser.axisunitsval('L', E_AXIS, PAUSE_PARK_RETRACT_LENGTH))); @@ -90,17 +100,44 @@ void GcodeSuite::M125() { const bool sd_printing = TERN0(SDSUPPORT, IS_SD_PRINTING()); - ui.pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT); + //Maintenance park + if (parser.seen('T')) { + if (ENABLED(HAS_MARLINUI_MENU)){ + show_m125t(1); + maintenance_park_enabled = true; + const bool show_lcd = false; + if (pause_print(retract, park_point, show_lcd, 0)) { + millis_t start_time = millis(); + bool flipflap = 0; + uint8_t can_beep = 0; + while(maintenance_park_enabled){ + idle(); + if ( (millis() - start_time) > 1000 ) { + start_time = millis(); + if (parser.seenval('T') && can_beep == parser.linearval('T')) { BUZZ(100, 1000); can_beep = 0; } + show_m125t(flipflap); + flipflap = flipflap? 0:1; + can_beep++; + } + } + } + resume_print(0, 0, -retract, 0); + } + } + else { + ui.pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT); - // If possible, show an LCD prompt with the 'P' flag - const bool show_lcd = TERN0(HAS_MARLINUI_MENU, parser.boolval('P')); + // If possible, show an LCD prompt with the 'P' flag + const bool show_lcd = TERN0(HAS_MARLINUI_MENU, parser.boolval('P')); - if (pause_print(retract, park_point, show_lcd, 0)) { - if (ENABLED(EXTENSIBLE_UI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) || !sd_printing || show_lcd) { - wait_for_confirmation(false, 0); - resume_print(0, 0, -retract, 0); + if (pause_print(retract, park_point, show_lcd, 0)) { + if (ENABLED(EXTENSIBLE_UI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) || !sd_printing || show_lcd) { + wait_for_confirmation(false, 0); + resume_print(0, 0, -retract, 0); + } } } + } #endif // PARK_HEAD_ON_PAUSE diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 8c8c4758b73df..b7d4eb0eed2e6 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -66,6 +66,10 @@ #include "../../feature/repeat.h" #endif +#if ENABLED(PARK_HEAD_ON_PAUSE) + #include "../../feature/pause.h" +#endif + void menu_tune(); void menu_cancelobject(); void menu_motion(); @@ -313,8 +317,15 @@ void menu_main() { sdcard_menu_items(); #endif - if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) - ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print); + #if ENABLED(PARK_HEAD_ON_PAUSE) + if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) + if (maintenance_park_enabled) ACTION_ITEM(MSG_RESUME_PRINT, maintenance_park_disable); + else + ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print); + #else + if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) + ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print); + #endif #if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START) ACTION_ITEM(MSG_HOST_START_PRINT, hostui.start);