diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index f40478b768731003e0afe201a2e63288fc519d4f..30ec8bfb1d50228c96364b86d4cf6341fc77369d 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -72,6 +72,12 @@ void host_action(const char * const pstr, const bool eol) { PromptReason host_prompt_reason = PROMPT_NOT_DEFINED; + void host_action_notify(const char * const message) { + host_action(PSTR("notification "), false); + serialprintPGM(message); + SERIAL_EOL(); + } + void host_action_prompt(const char * const ptype, const bool eol=true) { host_action(PSTR("prompt_"), false); serialprintPGM(ptype); diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index b742d0f081b28a17066cd4bae83364cd1d1f39ca..57af59eb2e4ec49039ac38b9fa3a7e89373b78c0 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -60,6 +60,7 @@ void host_action(const char * const pstr, const bool eol=true); extern PromptReason host_prompt_reason; void host_response_handler(const uint8_t response); + void host_action_notify(const char * const message); void host_action_prompt_begin(const char * const pstr, const bool eol=true); void host_action_prompt_button(const char * const pstr); void host_action_prompt_end(); diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 3b69807b755510d4344b7722021c9ea36202a76e..c2e00fcce6950b8fa8faa47c837a555360e66e80 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -26,19 +26,21 @@ #include "../feature/leds/leds.h" #endif +#if ENABLED(HOST_ACTION_COMMANDS) + #include "../feature/host_actions.h" +#endif + +#include "ultralcd.h" +MarlinUI ui; + // All displays share the MarlinUI class #if HAS_DISPLAY #include "../gcode/queue.h" - #include "ultralcd.h" #include "fontutils.h" - MarlinUI ui; #include "../sd/cardreader.h" #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 @@ -1369,6 +1371,10 @@ void MarlinUI::update() { void MarlinUI::set_status(const char * const message, const bool persist) { if (alert_level) return; + #if ENABLED(HOST_PROMPT_SUPPORT) + host_action_notify(message); + #endif + // Here we have a problem. The message is encoded in UTF8, so // arbitrarily cutting it will be a problem. We MUST be sure // that there is no cutting in the middle of a multibyte character! @@ -1408,6 +1414,10 @@ void MarlinUI::update() { if (level < alert_level) return; alert_level = level; + #if ENABLED(HOST_PROMPT_SUPPORT) + host_action_notify(message); + #endif + // Since the message is encoded in UTF8 it must // only be cut on a character boundary. @@ -1568,4 +1578,34 @@ void MarlinUI::update() { #endif -#endif // HAS_DISPLAY +#else // !HAS_DISPLAY + + // + // Send the status line as a host notification + // + + void MarlinUI::set_status(const char * const message, const bool) { + #if ENABLED(HOST_PROMPT_SUPPORT) + host_action_notify(message); + #else + UNUSED(message); + #endif + } + + void MarlinUI::set_status_P(PGM_P message, const int8_t) { + #if ENABLED(HOST_PROMPT_SUPPORT) + host_action_notify(message); + #else + UNUSED(message); + #endif + } + + void MarlinUI::status_printf_P(const uint8_t, PGM_P const message, ...) { + #if ENABLED(HOST_PROMPT_SUPPORT) + host_action_notify(message); + #else + UNUSED(message); + #endif + } + +#endif // !HAS_DISPLAY diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 47d5a87ab7674bda69764e66ed3ede0066e51463..7fc3a5f731a40045d3c7163e7f1e49dc49e78da1 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -406,14 +406,16 @@ public: #else // No LCD + // Send status to host as a notification + void set_status(const char* message, const bool=false); + void set_status_P(PGM_P message, const int8_t=0); + void status_printf_P(const uint8_t, PGM_P message, ...); + static inline void init() {} static inline void update() {} static inline void refresh() {} static inline void return_to_status() {} static inline void set_alert_status_P(PGM_P const) {} - static inline void set_status(const char* const, const bool=false) {} - static inline void set_status_P(PGM_P const, const int8_t=0) {} - static inline void status_printf_P(const uint8_t, PGM_P const, ...) {} static inline void reset_status() {} static inline void reset_alert_level() {} static constexpr bool has_status() { return false; }