Skip to content

Commit

Permalink
Maintenance park
Browse files Browse the repository at this point in the history
  • Loading branch information
studiodyne committed Sep 23, 2022
1 parent 8f4fb42 commit a5765e8
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/feature/pause.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
51 changes: 44 additions & 7 deletions Marlin/src/gcode/feature/pause/M125.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -57,10 +58,19 @@
* W<pos> = Override park position W (requires AXIS*_NAME 'W')
* Z<linear> = Override Z raise
*
* //Park + unlocked LCD ( all menus available for maintenance during printing )
* T<linear> = Maintenance park, if a value, add beeps each 'value' seconds (requires LCD to resume)
*
* With an LCD menu:
* P<bool> = 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)));

Expand Down Expand Up @@ -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
15 changes: 13 additions & 2 deletions Marlin/src/lcd/menu/menu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a5765e8

Please sign in to comment.