Browse Source

Add Host Prompt Notification Method (#15942)

InsanityAutomation 5 years ago
parent
commit
7126a5e5a7

+ 6
- 0
Marlin/src/feature/host_actions.cpp View File

72
 
72
 
73
   PromptReason host_prompt_reason = PROMPT_NOT_DEFINED;
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
   void host_action_prompt(const char * const ptype, const bool eol=true) {
81
   void host_action_prompt(const char * const ptype, const bool eol=true) {
76
     host_action(PSTR("prompt_"), false);
82
     host_action(PSTR("prompt_"), false);
77
     serialprintPGM(ptype);
83
     serialprintPGM(ptype);

+ 1
- 0
Marlin/src/feature/host_actions.h View File

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

+ 46
- 6
Marlin/src/lcd/ultralcd.cpp View File

26
   #include "../feature/leds/leds.h"
26
   #include "../feature/leds/leds.h"
27
 #endif
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
 // All displays share the MarlinUI class
36
 // All displays share the MarlinUI class
30
 #if HAS_DISPLAY
37
 #if HAS_DISPLAY
31
   #include "../gcode/queue.h"
38
   #include "../gcode/queue.h"
32
-  #include "ultralcd.h"
33
   #include "fontutils.h"
39
   #include "fontutils.h"
34
-  MarlinUI ui;
35
   #include "../sd/cardreader.h"
40
   #include "../sd/cardreader.h"
36
   #if ENABLED(EXTENSIBLE_UI)
41
   #if ENABLED(EXTENSIBLE_UI)
37
     #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
42
     #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
38
   #endif
43
   #endif
39
-  #if ENABLED(HOST_ACTION_COMMANDS)
40
-    #include "../feature/host_actions.h"
41
-  #endif
42
 #endif
44
 #endif
43
 
45
 
44
 #if HAS_SPI_LCD
46
 #if HAS_SPI_LCD
1369
   void MarlinUI::set_status(const char * const message, const bool persist) {
1371
   void MarlinUI::set_status(const char * const message, const bool persist) {
1370
     if (alert_level) return;
1372
     if (alert_level) return;
1371
 
1373
 
1374
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1375
+      host_action_notify(message);
1376
+    #endif
1377
+
1372
     // Here we have a problem. The message is encoded in UTF8, so
1378
     // Here we have a problem. The message is encoded in UTF8, so
1373
     // arbitrarily cutting it will be a problem. We MUST be sure
1379
     // arbitrarily cutting it will be a problem. We MUST be sure
1374
     // that there is no cutting in the middle of a multibyte character!
1380
     // that there is no cutting in the middle of a multibyte character!
1408
     if (level < alert_level) return;
1414
     if (level < alert_level) return;
1409
     alert_level = level;
1415
     alert_level = level;
1410
 
1416
 
1417
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1418
+      host_action_notify(message);
1419
+    #endif
1420
+
1411
     // Since the message is encoded in UTF8 it must
1421
     // Since the message is encoded in UTF8 it must
1412
     // only be cut on a character boundary.
1422
     // only be cut on a character boundary.
1413
 
1423
 
1568
 
1578
 
1569
   #endif
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 View File

406
 
406
 
407
   #else // No LCD
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
     static inline void init() {}
414
     static inline void init() {}
410
     static inline void update() {}
415
     static inline void update() {}
411
     static inline void refresh() {}
416
     static inline void refresh() {}
412
     static inline void return_to_status() {}
417
     static inline void return_to_status() {}
413
     static inline void set_alert_status_P(PGM_P const) {}
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
     static inline void reset_status() {}
419
     static inline void reset_status() {}
418
     static inline void reset_alert_level() {}
420
     static inline void reset_alert_level() {}
419
     static constexpr bool has_status() { return false; }
421
     static constexpr bool has_status() { return false; }

Loading…
Cancel
Save