|
@ -24,10 +24,10 @@ |
|
|
|
|
|
|
|
|
#if ENABLED(HOST_ACTION_COMMANDS) |
|
|
#if ENABLED(HOST_ACTION_COMMANDS) |
|
|
|
|
|
|
|
|
#include "host_actions.h" |
|
|
|
|
|
|
|
|
|
|
|
//#define DEBUG_HOST_ACTIONS
|
|
|
//#define DEBUG_HOST_ACTIONS
|
|
|
|
|
|
|
|
|
|
|
|
#include "host_actions.h" |
|
|
|
|
|
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE) |
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE) |
|
|
#include "pause.h" |
|
|
#include "pause.h" |
|
|
#include "../gcode/queue.h" |
|
|
#include "../gcode/queue.h" |
|
@ -37,7 +37,12 @@ |
|
|
#include "runout.h" |
|
|
#include "runout.h" |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
void host_action(FSTR_P const fstr, const bool eol) { |
|
|
HostUI hostui; |
|
|
|
|
|
|
|
|
|
|
|
flag_t HostUI::flag; |
|
|
|
|
|
|
|
|
|
|
|
void HostUI::action(FSTR_P const fstr, const bool eol) { |
|
|
|
|
|
if (!flag.bits) return; |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
SERIAL_ECHOPGM("//action:"); |
|
|
SERIAL_ECHOPGM("//action:"); |
|
|
SERIAL_ECHOF(fstr); |
|
|
SERIAL_ECHOF(fstr); |
|
@ -45,29 +50,40 @@ void host_action(FSTR_P const fstr, const bool eol) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifdef ACTION_ON_KILL |
|
|
#ifdef ACTION_ON_KILL |
|
|
void host_action_kill() { host_action(F(ACTION_ON_KILL)); } |
|
|
void HostUI::kill() { action(F(ACTION_ON_KILL)); } |
|
|
#endif |
|
|
#endif |
|
|
#ifdef ACTION_ON_PAUSE |
|
|
#ifdef ACTION_ON_PAUSE |
|
|
void host_action_pause(const bool eol/*=true*/) { host_action(F(ACTION_ON_PAUSE), eol); } |
|
|
void HostUI::pause(const bool eol/*=true*/) { action(F(ACTION_ON_PAUSE), eol); } |
|
|
#endif |
|
|
#endif |
|
|
#ifdef ACTION_ON_PAUSED |
|
|
#ifdef ACTION_ON_PAUSED |
|
|
void host_action_paused(const bool eol/*=true*/) { host_action(F(ACTION_ON_PAUSED), eol); } |
|
|
void HostUI::paused(const bool eol/*=true*/) { action(F(ACTION_ON_PAUSED), eol); } |
|
|
#endif |
|
|
#endif |
|
|
#ifdef ACTION_ON_RESUME |
|
|
#ifdef ACTION_ON_RESUME |
|
|
void host_action_resume() { host_action(F(ACTION_ON_RESUME)); } |
|
|
void HostUI::resume() { action(F(ACTION_ON_RESUME)); } |
|
|
#endif |
|
|
#endif |
|
|
#ifdef ACTION_ON_RESUMED |
|
|
#ifdef ACTION_ON_RESUMED |
|
|
void host_action_resumed() { host_action(F(ACTION_ON_RESUMED)); } |
|
|
void HostUI::resumed() { action(F(ACTION_ON_RESUMED)); } |
|
|
#endif |
|
|
#endif |
|
|
#ifdef ACTION_ON_CANCEL |
|
|
#ifdef ACTION_ON_CANCEL |
|
|
void host_action_cancel() { host_action(F(ACTION_ON_CANCEL)); } |
|
|
void HostUI::cancel() { action(F(ACTION_ON_CANCEL)); } |
|
|
#endif |
|
|
#endif |
|
|
#ifdef ACTION_ON_START |
|
|
#ifdef ACTION_ON_START |
|
|
void host_action_start() { host_action(F(ACTION_ON_START)); } |
|
|
void HostUI::start() { action(F(ACTION_ON_START)); } |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(G29_RETRY_AND_RECOVER) |
|
|
|
|
|
#ifdef ACTION_ON_G29_RECOVER |
|
|
|
|
|
void HostUI::g29_recover() { action(F(ACTION_ON_G29_RECOVER)); } |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifdef ACTION_ON_G29_FAILURE |
|
|
|
|
|
void HostUI::g29_failure() { action(F(ACTION_ON_G29_FAILURE)); } |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT) |
|
|
#if ENABLED(HOST_PROMPT_SUPPORT) |
|
|
|
|
|
|
|
|
|
|
|
PromptReason HostUI::host_prompt_reason = PROMPT_NOT_DEFINED; |
|
|
|
|
|
|
|
|
PGMSTR(CONTINUE_STR, "Continue"); |
|
|
PGMSTR(CONTINUE_STR, "Continue"); |
|
|
PGMSTR(DISMISS_STR, "Dismiss"); |
|
|
PGMSTR(DISMISS_STR, "Dismiss"); |
|
|
|
|
|
|
|
@ -75,64 +91,69 @@ void host_action(FSTR_P const fstr, const bool eol) { |
|
|
extern bool wait_for_user; |
|
|
extern bool wait_for_user; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
PromptReason host_prompt_reason = PROMPT_NOT_DEFINED; |
|
|
void HostUI::notify(const char * const cstr) { |
|
|
|
|
|
if (!flag.bits) return; |
|
|
void host_action_notify(const char * const cstr) { |
|
|
|
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
host_action(F("notification "), false); |
|
|
action(F("notification "), false); |
|
|
SERIAL_ECHOLN(cstr); |
|
|
SERIAL_ECHOLN(cstr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void host_action_notify(FSTR_P const fstr) { |
|
|
void HostUI::notify_P(PGM_P const pstr) { |
|
|
|
|
|
if (!flag.bits) return; |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
host_action(F("notification "), false); |
|
|
action(F("notification "), false); |
|
|
SERIAL_ECHOLNF(fstr); |
|
|
SERIAL_ECHOLNPGM_P(pstr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void host_action_prompt(FSTR_P const ptype, const bool eol=true) { |
|
|
void HostUI::prompt(FSTR_P const ptype, const bool eol/*=true*/) { |
|
|
|
|
|
if (!flag.bits) return; |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
host_action(F("prompt_"), false); |
|
|
action(F("prompt_"), false); |
|
|
SERIAL_ECHOF(ptype); |
|
|
SERIAL_ECHOF(ptype); |
|
|
if (eol) SERIAL_EOL(); |
|
|
if (eol) SERIAL_EOL(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void host_action_prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0') { |
|
|
void HostUI::prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char/*='\0'*/) { |
|
|
host_action_prompt(ptype, false); |
|
|
if (!flag.bits) return; |
|
|
|
|
|
prompt(ptype, false); |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
PORT_REDIRECT(SerialMask::All); |
|
|
SERIAL_CHAR(' '); |
|
|
SERIAL_CHAR(' '); |
|
|
SERIAL_ECHOF(fstr); |
|
|
SERIAL_ECHOF(fstr); |
|
|
if (extra_char != '\0') SERIAL_CHAR(extra_char); |
|
|
if (extra_char != '\0') SERIAL_CHAR(extra_char); |
|
|
SERIAL_EOL(); |
|
|
SERIAL_EOL(); |
|
|
} |
|
|
} |
|
|
void host_action_prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) { |
|
|
void HostUI::prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) { |
|
|
host_action_prompt_end(); |
|
|
if (!flag.bits) return; |
|
|
|
|
|
prompt_end(); |
|
|
host_prompt_reason = reason; |
|
|
host_prompt_reason = reason; |
|
|
host_action_prompt_plus(F("begin"), fstr, extra_char); |
|
|
prompt_plus(F("begin"), fstr, extra_char); |
|
|
} |
|
|
} |
|
|
void host_action_prompt_button(FSTR_P const fstr) { host_action_prompt_plus(F("button"), fstr); } |
|
|
void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); } |
|
|
void host_action_prompt_end() { host_action_prompt(F("end")); } |
|
|
void HostUI::prompt_end() { prompt(F("end")); } |
|
|
void host_action_prompt_show() { host_action_prompt(F("show")); } |
|
|
void HostUI::prompt_show() { prompt(F("show")); } |
|
|
|
|
|
|
|
|
void _host_prompt_show(FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { |
|
|
void HostUI::_prompt_show(FSTR_P const btn1, FSTR_P const btn2) { |
|
|
if (btn1) host_action_prompt_button(btn1); |
|
|
if (btn1) prompt_button(btn1); |
|
|
if (btn2) host_action_prompt_button(btn2); |
|
|
if (btn2) prompt_button(btn2); |
|
|
host_action_prompt_show(); |
|
|
prompt_show(); |
|
|
} |
|
|
} |
|
|
void host_prompt_do(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { |
|
|
void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { |
|
|
host_action_prompt_begin(reason, fstr); |
|
|
prompt_begin(reason, fstr); |
|
|
_host_prompt_show(btn1, btn2); |
|
|
_prompt_show(btn1, btn2); |
|
|
} |
|
|
} |
|
|
void host_prompt_do(const PromptReason reason, FSTR_P const fstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { |
|
|
void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { |
|
|
host_action_prompt_begin(reason, fstr, extra_char); |
|
|
prompt_begin(reason, fstr, extra_char); |
|
|
_host_prompt_show(btn1, btn2); |
|
|
_prompt_show(btn1, btn2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void filament_load_host_prompt() { |
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE) |
|
|
|
|
|
void HostUI::filament_load_prompt() { |
|
|
const bool disable_to_continue = TERN0(HAS_FILAMENT_SENSOR, runout.filament_ran_out); |
|
|
const bool disable_to_continue = TERN0(HAS_FILAMENT_SENSOR, runout.filament_ran_out); |
|
|
host_prompt_do(PROMPT_FILAMENT_RUNOUT, F("Paused"), F("PurgeMore"), |
|
|
prompt_do(PROMPT_FILAMENT_RUNOUT, F("Paused"), F("PurgeMore"), |
|
|
disable_to_continue ? F("DisableRunout") : FPSTR(CONTINUE_STR) |
|
|
disable_to_continue ? F("DisableRunout") : FPSTR(CONTINUE_STR) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
//
|
|
|
//
|
|
|
// Handle responses from the host, such as:
|
|
|
// Handle responses from the host, such as:
|
|
@ -141,7 +162,7 @@ void host_action(FSTR_P const fstr, const bool eol) { |
|
|
// - Resume Print response
|
|
|
// - Resume Print response
|
|
|
// - Dismissal of info
|
|
|
// - Dismissal of info
|
|
|
//
|
|
|
//
|
|
|
void host_response_handler(const uint8_t response) { |
|
|
void HostUI::handle_response(const uint8_t response) { |
|
|
const PromptReason hpr = host_prompt_reason; |
|
|
const PromptReason hpr = host_prompt_reason; |
|
|
host_prompt_reason = PROMPT_NOT_DEFINED; // Reset now ahead of logic
|
|
|
host_prompt_reason = PROMPT_NOT_DEFINED; // Reset now ahead of logic
|
|
|
switch (hpr) { |
|
|
switch (hpr) { |
|
|