Browse Source

Fix host_action_notify and string types (#17953)

Desuuuu 5 years ago
parent
commit
00e7599c8c
No account linked to committer's email address

+ 13
- 7
Marlin/src/feature/host_actions.cpp View File

@@ -37,7 +37,7 @@
37 37
   #include "runout.h"
38 38
 #endif
39 39
 
40
-void host_action(const char * const pstr, const bool eol) {
40
+void host_action(PGM_P const pstr, const bool eol) {
41 41
   SERIAL_ECHOPGM("//action:");
42 42
   serialprintPGM(pstr);
43 43
   if (eol) SERIAL_EOL();
@@ -75,32 +75,38 @@ void host_action(const char * const pstr, const bool eol) {
75 75
 
76 76
   void host_action_notify(const char * const message) {
77 77
     host_action(PSTR("notification "), false);
78
+    SERIAL_ECHO(message);
79
+    SERIAL_EOL();
80
+  }
81
+
82
+  void host_action_notify_P(PGM_P const message) {
83
+    host_action(PSTR("notification "), false);
78 84
     serialprintPGM(message);
79 85
     SERIAL_EOL();
80 86
   }
81 87
 
82
-  void host_action_prompt(const char * const ptype, const bool eol=true) {
88
+  void host_action_prompt(PGM_P const ptype, const bool eol=true) {
83 89
     host_action(PSTR("prompt_"), false);
84 90
     serialprintPGM(ptype);
85 91
     if (eol) SERIAL_EOL();
86 92
   }
87 93
 
88
-  void host_action_prompt_plus(const char * const ptype, const char * const pstr, const char extra_char='\0') {
94
+  void host_action_prompt_plus(PGM_P const ptype, PGM_P const pstr, const char extra_char='\0') {
89 95
     host_action_prompt(ptype, false);
90 96
     SERIAL_CHAR(' ');
91 97
     serialprintPGM(pstr);
92 98
     if (extra_char != '\0') SERIAL_CHAR(extra_char);
93 99
     SERIAL_EOL();
94 100
   }
95
-  void host_action_prompt_begin(const PromptReason reason, const char * const pstr, const char extra_char/*='\0'*/) {
101
+  void host_action_prompt_begin(const PromptReason reason, PGM_P const pstr, const char extra_char/*='\0'*/) {
96 102
     host_action_prompt_end();
97 103
     host_prompt_reason = reason;
98 104
     host_action_prompt_plus(PSTR("begin"), pstr, extra_char);
99 105
   }
100
-  void host_action_prompt_button(const char * const pstr) { host_action_prompt_plus(PSTR("button"), pstr); }
106
+  void host_action_prompt_button(PGM_P const pstr) { host_action_prompt_plus(PSTR("button"), pstr); }
101 107
   void host_action_prompt_end() { host_action_prompt(PSTR("end")); }
102 108
   void host_action_prompt_show() { host_action_prompt(PSTR("show")); }
103
-  void host_prompt_do(const PromptReason reason, const char * const pstr, const char * const btn1/*=nullptr*/, const char * const btn2/*=nullptr*/) {
109
+  void host_prompt_do(const PromptReason reason, PGM_P const pstr, PGM_P const btn1/*=nullptr*/, PGM_P const btn2/*=nullptr*/) {
104 110
     host_action_prompt_begin(reason, pstr);
105 111
     if (btn1) host_action_prompt_button(btn1);
106 112
     if (btn2) host_action_prompt_button(btn2);
@@ -127,7 +133,7 @@ void host_action(const char * const pstr, const bool eol) {
127 133
       serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("ason: ", host_prompt_reason);
128 134
       serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("sponse: ", response);
129 135
     #endif
130
-    const char *msg = PSTR("UNKNOWN STATE");
136
+    PGM_P msg = PSTR("UNKNOWN STATE");
131 137
     const PromptReason hpr = host_prompt_reason;
132 138
     host_prompt_reason = PROMPT_NOT_DEFINED;  // Reset now ahead of logic
133 139
     switch (hpr) {

+ 7
- 6
Marlin/src/feature/host_actions.h View File

@@ -21,9 +21,9 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "../inc/MarlinConfigPre.h"
24
+#include "../inc/MarlinConfig.h"
25 25
 
26
-void host_action(const char * const pstr, const bool eol=true);
26
+void host_action(PGM_P const pstr, const bool eol=true);
27 27
 
28 28
 #ifdef ACTION_ON_KILL
29 29
   void host_action_kill();
@@ -61,12 +61,13 @@ void host_action(const char * const pstr, const bool eol=true);
61 61
 
62 62
   void host_response_handler(const uint8_t response);
63 63
   void host_action_notify(const char * const message);
64
-  void host_action_prompt_begin(const PromptReason reason, const char * const pstr, const char extra_char='\0');
65
-  void host_action_prompt_button(const char * const pstr);
64
+  void host_action_notify_P(PGM_P const message);
65
+  void host_action_prompt_begin(const PromptReason reason, PGM_P const pstr, const char extra_char='\0');
66
+  void host_action_prompt_button(PGM_P const pstr);
66 67
   void host_action_prompt_end();
67 68
   void host_action_prompt_show();
68
-  void host_prompt_do(const PromptReason reason, const char * const pstr, const char * const btn1=nullptr, const char * const btn2=nullptr);
69
-  inline void host_prompt_open(const PromptReason reason, const char * const pstr, const char * const btn1=nullptr, const char * const btn2=nullptr) {
69
+  void host_prompt_do(const PromptReason reason, PGM_P const pstr, PGM_P const btn1=nullptr, PGM_P const btn2=nullptr);
70
+  inline void host_prompt_open(const PromptReason reason, PGM_P const pstr, PGM_P const btn1=nullptr, PGM_P const btn2=nullptr) {
70 71
     if (host_prompt_reason == PROMPT_NOT_DEFINED) host_prompt_do(reason, pstr, btn1, btn2);
71 72
   }
72 73
 

+ 3
- 3
Marlin/src/lcd/ultralcd.cpp View File

@@ -1303,7 +1303,7 @@ void MarlinUI::update() {
1303 1303
     if (level < alert_level) return;
1304 1304
     alert_level = level;
1305 1305
 
1306
-    TERN_(HOST_PROMPT_SUPPORT, host_action_notify(message));
1306
+    TERN_(HOST_PROMPT_SUPPORT, host_action_notify_P(message));
1307 1307
 
1308 1308
     // Since the message is encoded in UTF8 it must
1309 1309
     // only be cut on a character boundary.
@@ -1450,10 +1450,10 @@ void MarlinUI::update() {
1450 1450
     TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
1451 1451
   }
1452 1452
   void MarlinUI::set_status_P(PGM_P message, const int8_t) {
1453
-    TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
1453
+    TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(message), UNUSED(message));
1454 1454
   }
1455 1455
   void MarlinUI::status_printf_P(const uint8_t, PGM_P const message, ...) {
1456
-    TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
1456
+    TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(message), UNUSED(message));
1457 1457
   }
1458 1458
 
1459 1459
 #endif // !HAS_DISPLAY

Loading…
Cancel
Save