Update criteria for PAUSE/RESUME/STOP menu items (#13294)

This commit is contained in:
Scott Lahteine 2019-03-05 06:46:06 -06:00 committed by GitHub
parent 56fdcf93d1
commit 4771e372a1
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,56 +46,67 @@
#include "../../feature/host_actions.h" #include "../../feature/host_actions.h"
#endif #endif
void lcd_pause() { #define MACHINE_CAN_STOP (ENABLED(SDSUPPORT) || ENABLED(HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
#if ENABLED(POWER_LOSS_RECOVERY) #define MACHINE_CAN_PAUSE (ENABLED(SDSUPPORT) || ENABLED(HOST_PROMPT_SUPPORT) || ENABLED(PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
if (recovery.enabled) recovery.save(true, false);
#endif
#if ENABLED(HOST_PROMPT_SUPPORT) #if MACHINE_CAN_PAUSE
host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
#endif
#if ENABLED(PARK_HEAD_ON_PAUSE) void lcd_pause_job() {
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT); // Show message immediately to let user know about pause in progress #if ENABLED(POWER_LOSS_RECOVERY)
enqueue_and_echo_commands_P(PSTR("M25 P\nM24")); if (recovery.enabled) recovery.save(true, false);
#elif ENABLED(SDSUPPORT) #endif
enqueue_and_echo_commands_P(PSTR("M25"));
#elif defined(ACTION_ON_PAUSE)
host_action_pause();
#endif
planner.synchronize();
}
void lcd_resume() { #if ENABLED(HOST_PROMPT_SUPPORT)
#if ENABLED(SDSUPPORT) host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24")); #endif
#endif
#ifdef ACTION_ON_RESUME
host_action_resume();
#endif
}
void lcd_stop() { #if ENABLED(PARK_HEAD_ON_PAUSE)
#if ENABLED(SDSUPPORT) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT); // Show message immediately to let user know about pause in progress
wait_for_heatup = wait_for_user = false; enqueue_and_echo_commands_P(PSTR("M25 P\nM24"));
card.flag.abort_sd_printing = true; #elif ENABLED(SDSUPPORT)
#endif enqueue_and_echo_commands_P(PSTR("M25"));
#ifdef ACTION_ON_CANCEL #elif defined(ACTION_ON_PAUSE)
host_action_cancel(); host_action_pause();
#endif #endif
#if ENABLED(HOST_PROMPT_SUPPORT) planner.synchronize();
host_prompt_open(PROMPT_INFO, PSTR("UI Abort")); }
#endif
ui.set_status_P(PSTR(MSG_PRINT_ABORTED), -1);
ui.return_to_status();
}
void menu_abort_confirm() { void lcd_resume() {
START_MENU(); #if ENABLED(SDSUPPORT)
MENU_BACK(MSG_MAIN); if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
MENU_ITEM(function, MSG_STOP_PRINT, lcd_stop); #endif
END_MENU(); #ifdef ACTION_ON_RESUME
} host_action_resume();
#endif
}
#endif // MACHINE_CAN_PAUSE
#if MACHINE_CAN_STOP
void lcd_abort_job() {
#if ENABLED(SDSUPPORT)
wait_for_heatup = wait_for_user = false;
card.flag.abort_sd_printing = true;
#endif
#ifdef ACTION_ON_CANCEL
host_action_cancel();
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_open(PROMPT_INFO, PSTR("UI Abort"));
#endif
ui.set_status_P(PSTR(MSG_PRINT_ABORTED), -1);
ui.return_to_status();
}
void menu_abort_confirm() {
START_MENU();
MENU_BACK(MSG_MAIN);
MENU_ITEM(function, MSG_STOP_PRINT, lcd_abort_job);
END_MENU();
}
#endif // MACHINE_CAN_STOP
#if ENABLED(PRUSA_MMU2) #if ENABLED(PRUSA_MMU2)
#include "../../lcd/menu/menu_mmu2.h" #include "../../lcd/menu/menu_mmu2.h"
@ -139,8 +150,10 @@ void menu_main() {
; ;
if (busy) { if (busy) {
MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause); #if MACHINE_CAN_PAUSE
#if ENABLED(SDSUPPORT) || defined(ACTION_ON_CANCEL) MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause_job);
#endif
#if MACHINE_CAN_STOP
MENU_ITEM(submenu, MSG_STOP_PRINT, menu_abort_confirm); MENU_ITEM(submenu, MSG_STOP_PRINT, menu_abort_confirm);
#endif #endif
MENU_ITEM(submenu, MSG_TUNE, menu_tune); MENU_ITEM(submenu, MSG_TUNE, menu_tune);
@ -170,11 +183,13 @@ void menu_main() {
} }
#endif // !HAS_ENCODER_WHEEL && SDSUPPORT #endif // !HAS_ENCODER_WHEEL && SDSUPPORT
#if ENABLED(SDSUPPORT) || ENABLED(HOST_ACTION_COMMANDS) #if MACHINE_CAN_PAUSE
#if DISABLED(HOST_ACTION_COMMANDS) const bool paused = (print_job_timer.isPaused()
if (card_open && card.isPaused()) #if ENABLED(SDSUPPORT)
#endif || card.isPaused()
MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume); #endif
);
if (paused) MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume);
#endif #endif
MENU_ITEM(submenu, MSG_MOTION, menu_motion); MENU_ITEM(submenu, MSG_MOTION, menu_motion);