Explorar el Código

Add Host Prompt Notification Method (#15942)

InsanityAutomation hace 5 años
padre
commit
7126a5e5a7

+ 6
- 0
Marlin/src/feature/host_actions.cpp Ver fichero

@@ -72,6 +72,12 @@ void host_action(const char * const pstr, const bool eol) {
72 72
 
73 73
   PromptReason host_prompt_reason = PROMPT_NOT_DEFINED;
74 74
 
75
+  void host_action_notify(const char * const message) {
76
+    host_action(PSTR("notification "), false);
77
+    serialprintPGM(message);
78
+    SERIAL_EOL();
79
+  }
80
+
75 81
   void host_action_prompt(const char * const ptype, const bool eol=true) {
76 82
     host_action(PSTR("prompt_"), false);
77 83
     serialprintPGM(ptype);

+ 1
- 0
Marlin/src/feature/host_actions.h Ver fichero

@@ -60,6 +60,7 @@ void host_action(const char * const pstr, const bool eol=true);
60 60
   extern PromptReason host_prompt_reason;
61 61
 
62 62
   void host_response_handler(const uint8_t response);
63
+  void host_action_notify(const char * const message);
63 64
   void host_action_prompt_begin(const char * const pstr, const bool eol=true);
64 65
   void host_action_prompt_button(const char * const pstr);
65 66
   void host_action_prompt_end();

+ 46
- 6
Marlin/src/lcd/ultralcd.cpp Ver fichero

@@ -26,19 +26,21 @@
26 26
   #include "../feature/leds/leds.h"
27 27
 #endif
28 28
 
29
+#if ENABLED(HOST_ACTION_COMMANDS)
30
+  #include "../feature/host_actions.h"
31
+#endif
32
+
33
+#include "ultralcd.h"
34
+MarlinUI ui;
35
+
29 36
 // All displays share the MarlinUI class
30 37
 #if HAS_DISPLAY
31 38
   #include "../gcode/queue.h"
32
-  #include "ultralcd.h"
33 39
   #include "fontutils.h"
34
-  MarlinUI ui;
35 40
   #include "../sd/cardreader.h"
36 41
   #if ENABLED(EXTENSIBLE_UI)
37 42
     #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
38 43
   #endif
39
-  #if ENABLED(HOST_ACTION_COMMANDS)
40
-    #include "../feature/host_actions.h"
41
-  #endif
42 44
 #endif
43 45
 
44 46
 #if HAS_SPI_LCD
@@ -1369,6 +1371,10 @@ void MarlinUI::update() {
1369 1371
   void MarlinUI::set_status(const char * const message, const bool persist) {
1370 1372
     if (alert_level) return;
1371 1373
 
1374
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1375
+      host_action_notify(message);
1376
+    #endif
1377
+
1372 1378
     // Here we have a problem. The message is encoded in UTF8, so
1373 1379
     // arbitrarily cutting it will be a problem. We MUST be sure
1374 1380
     // that there is no cutting in the middle of a multibyte character!
@@ -1408,6 +1414,10 @@ void MarlinUI::update() {
1408 1414
     if (level < alert_level) return;
1409 1415
     alert_level = level;
1410 1416
 
1417
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1418
+      host_action_notify(message);
1419
+    #endif
1420
+
1411 1421
     // Since the message is encoded in UTF8 it must
1412 1422
     // only be cut on a character boundary.
1413 1423
 
@@ -1568,4 +1578,34 @@ void MarlinUI::update() {
1568 1578
 
1569 1579
   #endif
1570 1580
 
1571
-#endif // HAS_DISPLAY
1581
+#else // !HAS_DISPLAY
1582
+
1583
+  //
1584
+  // Send the status line as a host notification
1585
+  //
1586
+
1587
+  void MarlinUI::set_status(const char * const message, const bool) {
1588
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1589
+      host_action_notify(message);
1590
+    #else
1591
+      UNUSED(message);
1592
+    #endif
1593
+  }
1594
+
1595
+  void MarlinUI::set_status_P(PGM_P message, const int8_t) {
1596
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1597
+      host_action_notify(message);
1598
+    #else
1599
+      UNUSED(message);
1600
+    #endif
1601
+  }
1602
+
1603
+  void MarlinUI::status_printf_P(const uint8_t, PGM_P const message, ...) {
1604
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1605
+      host_action_notify(message);
1606
+    #else
1607
+      UNUSED(message);
1608
+    #endif
1609
+  }
1610
+
1611
+#endif // !HAS_DISPLAY

+ 5
- 3
Marlin/src/lcd/ultralcd.h Ver fichero

@@ -406,14 +406,16 @@ public:
406 406
 
407 407
   #else // No LCD
408 408
 
409
+    // Send status to host as a notification
410
+    void set_status(const char* message, const bool=false);
411
+    void set_status_P(PGM_P message, const int8_t=0);
412
+    void status_printf_P(const uint8_t, PGM_P message, ...);
413
+
409 414
     static inline void init() {}
410 415
     static inline void update() {}
411 416
     static inline void refresh() {}
412 417
     static inline void return_to_status() {}
413 418
     static inline void set_alert_status_P(PGM_P const) {}
414
-    static inline void set_status(const char* const, const bool=false) {}
415
-    static inline void set_status_P(PGM_P const, const int8_t=0) {}
416
-    static inline void status_printf_P(const uint8_t, PGM_P const, ...) {}
417 419
     static inline void reset_status() {}
418 420
     static inline void reset_alert_level() {}
419 421
     static constexpr bool has_status() { return false; }

Loading…
Cancelar
Guardar