🎨 Refactor Host Actions as singleton

This commit is contained in:
Scott Lahteine
2021-10-15 00:24:08 -05:00
committed by Scott Lahteine
parent 1ead7ce681
commit f80bcdcc5c
26 changed files with 208 additions and 150 deletions

View File

@ -344,7 +344,7 @@ void GcodeSuite::M43() {
#if HAS_RESUME_CONTINUE
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("M43 Wait Called"), FPSTR(CONTINUE_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("M43 Wait Called"), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("M43 Wait Called")));
#endif

View File

@ -26,7 +26,7 @@
* M111: Set the debug level
*/
void GcodeSuite::M111() {
if (parser.seen('S')) marlin_debug_flags = parser.byteval('S');
if (parser.seenval('S')) marlin_debug_flags = parser.value_byte();
static PGMSTR(str_debug_1, STR_DEBUG_ECHO);
static PGMSTR(str_debug_2, STR_DEBUG_INFO);

View File

@ -238,9 +238,9 @@ void GcodeSuite::dwell(millis_t time) {
#if ENABLED(G29_RETRY_AND_RECOVER)
void GcodeSuite::event_probe_recover() {
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, F("G29 Retrying"), FPSTR(DISMISS_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_INFO, F("G29 Retrying"), FPSTR(DISMISS_STR)));
#ifdef ACTION_ON_G29_RECOVER
host_action(F(ACTION_ON_G29_RECOVER));
hostui.g29_recover();
#endif
#ifdef G29_RECOVER_COMMANDS
process_subcommands_now(F(G29_RECOVER_COMMANDS));
@ -253,14 +253,14 @@ void GcodeSuite::dwell(millis_t time) {
void GcodeSuite::event_probe_failure() {
#ifdef ACTION_ON_G29_FAILURE
host_action(F(ACTION_ON_G29_FAILURE));
hostui.g29_failure();
#endif
#ifdef G29_FAILURE_COMMANDS
process_subcommands_now(F(G29_FAILURE_COMMANDS));
#endif
#if ENABLED(G29_HALT_ON_FAILURE)
#ifdef ACTION_ON_CANCEL
host_action_cancel();
hostui.cancel();
#endif
kill(GET_TEXT_F(MSG_LCD_PROBING_FAILED));
#endif
@ -283,7 +283,7 @@ void GcodeSuite::dwell(millis_t time) {
}
}
TERN_(HOST_PROMPT_SUPPORT, host_action_prompt_end());
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_end());
#ifdef G29_SUCCESS_COMMANDS
process_subcommands_now(F(G29_SUCCESS_COMMANDS));

View File

@ -33,7 +33,7 @@
*/
void GcodeSuite::M876() {
if (parser.seenval('S')) host_response_handler((uint8_t)parser.value_int());
if (parser.seenval('S')) hostui.handle_response((uint8_t)parser.value_int());
}

View File

@ -84,7 +84,7 @@ void GcodeSuite::M0_M1() {
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms));

View File

@ -97,7 +97,7 @@ void GcodeSuite::M1001() {
if (long_print) {
printerEventLEDs.onPrintCompleted();
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE)));
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30))));
printerEventLEDs.onResumeAfterWait();
}

View File

@ -77,9 +77,9 @@ void GcodeSuite::M24() {
#if ENABLED(HOST_ACTION_COMMANDS)
#ifdef ACTION_ON_RESUME
host_action_resume();
hostui.resume();
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, F("Resuming SD"), FPSTR(DISMISS_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Resuming SD"), FPSTR(DISMISS_STR)));
#endif
ui.reset_status();
@ -116,9 +116,9 @@ void GcodeSuite::M25() {
IF_DISABLED(DWIN_CREALITY_LCD, ui.reset_status());
#if ENABLED(HOST_ACTION_COMMANDS)
TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, F("Pause SD"), F("Resume")));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_PAUSE_RESUME, F("Pause SD"), F("Resume")));
#ifdef ACTION_ON_PAUSE
host_action_pause();
hostui.pause();
#endif
#endif

View File

@ -49,7 +49,7 @@ void GcodeSuite::M75() {
*/
void GcodeSuite::M76() {
print_job_timer.pause();
TERN_(HOST_PAUSE_M76, host_action_pause());
TERN_(HOST_PAUSE_M76, hostui.pause());
}
/**