ExtUI parity with SPI LCDs (#14172)

This commit is contained in:
InsanityAutomation 2019-05-30 17:24:13 -04:00 committed by Scott Lahteine
parent 07021c85c8
commit f889cc6ea6
4 changed files with 70 additions and 81 deletions

View File

@ -831,35 +831,15 @@ namespace ExtUI {
}
void pausePrint() {
#if ENABLED(SDSUPPORT)
card.pauseSDPrint();
print_job_timer.pause();
#if ENABLED(PARK_HEAD_ON_PAUSE)
enqueue_and_echo_commands_P(PSTR("M125"));
#endif
ui.set_status_P(PSTR(MSG_PRINT_PAUSED));
#endif
ui.pause_print();
}
void resumePrint() {
#if ENABLED(SDSUPPORT)
ui.set_status_P(PSTR(MSG_FILAMENT_CHANGE_RESUME_1));
#if ENABLED(PARK_HEAD_ON_PAUSE)
wait_for_heatup = wait_for_user = false;
enqueue_and_echo_commands_P(PSTR("M24"));
#else
card.startFileprint();
print_job_timer.start();
#endif
#endif
ui.resume_print();
}
void stopPrint() {
#if ENABLED(SDSUPPORT)
wait_for_heatup = wait_for_user = false;
card.flag.abort_sd_printing = true;
ui.set_status_P(PSTR(MSG_PRINT_ABORTED));
#endif
ui.stop_print();
}
FileList::FileList() { refresh(); }

View File

@ -39,10 +39,6 @@
#include "../../feature/power_loss_recovery.h"
#endif
#if ENABLED(HOST_ACTION_COMMANDS)
#include "../../feature/host_actions.h"
#endif
#if HAS_GAMES
#include "game/game.h"
#endif
@ -50,61 +46,10 @@
#define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
#define MACHINE_CAN_PAUSE (ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
#if MACHINE_CAN_PAUSE
void lcd_pause_job() {
ui.synchronize(PSTR(MSG_PAUSE_PRINT));
#if ENABLED(POWER_LOSS_RECOVERY)
if (recovery.enabled) recovery.save(true, false);
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
#endif
#if ENABLED(PARK_HEAD_ON_PAUSE)
lcd_pause_show_message(PAUSE_MESSAGE_PAUSING, PAUSE_MODE_PAUSE_PRINT); // Show message immediately to let user know about pause in progress
enqueue_and_echo_commands_P(PSTR("M25 P\nM24"));
#elif ENABLED(SDSUPPORT)
enqueue_and_echo_commands_P(PSTR("M25"));
#elif defined(ACTION_ON_PAUSE)
host_action_pause();
#endif
}
void lcd_resume() {
#if ENABLED(SDSUPPORT)
if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
#endif
#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() {
do_select_screen(PSTR(MSG_BUTTON_STOP), PSTR(MSG_BACK), lcd_abort_job, ui.goto_previous_screen, PSTR(MSG_STOP_PRINT), nullptr, PSTR("?"));
do_select_screen(PSTR(MSG_BUTTON_STOP), PSTR(MSG_BACK), ui.abort_print, ui.goto_previous_screen, PSTR(MSG_STOP_PRINT), nullptr, PSTR("?"));
}
#endif // MACHINE_CAN_STOP
#if ENABLED(PRUSA_MMU2)
@ -160,7 +105,7 @@ void menu_main() {
if (busy) {
#if MACHINE_CAN_PAUSE
MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause_job);
MENU_ITEM(function, MSG_PAUSE_PRINT, ui.pause_print);
#endif
#if MACHINE_CAN_STOP
MENU_ITEM(submenu, MSG_STOP_PRINT, menu_abort_confirm);
@ -204,7 +149,7 @@ void menu_main() {
|| card.isPaused()
#endif
);
if (paused) MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume);
if (paused) MENU_ITEM(function, MSG_RESUME_PRINT, ui.resume_print);
#endif
MENU_ITEM(submenu, MSG_MOTION, menu_motion);

View File

@ -31,6 +31,9 @@
#if ENABLED(EXTENSIBLE_UI)
#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
#endif
#if ENABLED(HOST_ACTION_COMMANDS)
#include "../feature/host_actions.h"
#endif
#endif
#if HAS_SPI_LCD
@ -1358,6 +1361,63 @@ void MarlinUI::update() {
set_status_P(msg, -1);
}
void MarlinUI::abort_print() {
#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
print_job_timer.stop();
set_status_P(PSTR(MSG_PRINT_ABORTED));
#if HAS_SPI_LCD
return_to_status();
#endif
}
void MarlinUI::pause_print() {
synchronize(PSTR(MSG_PAUSE_PRINT));
#if ENABLED(POWER_LOSS_RECOVERY)
if (recovery.enabled) recovery.save(true, false);
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
#endif
set_status_P(PSTR(MSG_PRINT_PAUSED));
#if ENABLED(PARK_HEAD_ON_PAUSE)
#if HAS_SPI_LCD
lcd_pause_show_message(PAUSE_MESSAGE_PAUSING, PAUSE_MODE_PAUSE_PRINT); // Show message immediately to let user know about pause in progress
#endif
enqueue_and_echo_commands_P(PSTR("M25 P\nM24"));
#elif ENABLED(SDSUPPORT)
enqueue_and_echo_commands_P(PSTR("M25"));
#elif defined(ACTION_ON_PAUSE)
host_action_pause();
#endif
}
void MarlinUI::resume_print() {
reset_status();
#if ENABLED(PARK_HEAD_ON_PAUSE)
wait_for_heatup = wait_for_user = false;
#endif
#if ENABLED(SDSUPPORT)
if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
#endif
#ifdef ACTION_ON_RESUME
host_action_resume();
#endif
print_job_timer.start(); // Also called by M24
}
#if HAS_PRINT_PROGRESS
uint8_t MarlinUI::get_progress() {
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)

View File

@ -286,6 +286,10 @@ public:
static char* status_and_len(uint8_t &len);
#endif
static void abort_print();
static void pause_print();
static void resume_print();
#if HAS_PRINT_PROGRESS
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
static uint8_t progress_bar_percent;