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
   #include "runout.h"
37
   #include "runout.h"
38
 #endif
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
   SERIAL_ECHOPGM("//action:");
41
   SERIAL_ECHOPGM("//action:");
42
   serialprintPGM(pstr);
42
   serialprintPGM(pstr);
43
   if (eol) SERIAL_EOL();
43
   if (eol) SERIAL_EOL();
75
 
75
 
76
   void host_action_notify(const char * const message) {
76
   void host_action_notify(const char * const message) {
77
     host_action(PSTR("notification "), false);
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
     serialprintPGM(message);
84
     serialprintPGM(message);
79
     SERIAL_EOL();
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
     host_action(PSTR("prompt_"), false);
89
     host_action(PSTR("prompt_"), false);
84
     serialprintPGM(ptype);
90
     serialprintPGM(ptype);
85
     if (eol) SERIAL_EOL();
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
     host_action_prompt(ptype, false);
95
     host_action_prompt(ptype, false);
90
     SERIAL_CHAR(' ');
96
     SERIAL_CHAR(' ');
91
     serialprintPGM(pstr);
97
     serialprintPGM(pstr);
92
     if (extra_char != '\0') SERIAL_CHAR(extra_char);
98
     if (extra_char != '\0') SERIAL_CHAR(extra_char);
93
     SERIAL_EOL();
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
     host_action_prompt_end();
102
     host_action_prompt_end();
97
     host_prompt_reason = reason;
103
     host_prompt_reason = reason;
98
     host_action_prompt_plus(PSTR("begin"), pstr, extra_char);
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
   void host_action_prompt_end() { host_action_prompt(PSTR("end")); }
107
   void host_action_prompt_end() { host_action_prompt(PSTR("end")); }
102
   void host_action_prompt_show() { host_action_prompt(PSTR("show")); }
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
     host_action_prompt_begin(reason, pstr);
110
     host_action_prompt_begin(reason, pstr);
105
     if (btn1) host_action_prompt_button(btn1);
111
     if (btn1) host_action_prompt_button(btn1);
106
     if (btn2) host_action_prompt_button(btn2);
112
     if (btn2) host_action_prompt_button(btn2);
127
       serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("ason: ", host_prompt_reason);
133
       serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("ason: ", host_prompt_reason);
128
       serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("sponse: ", response);
134
       serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("sponse: ", response);
129
     #endif
135
     #endif
130
-    const char *msg = PSTR("UNKNOWN STATE");
136
+    PGM_P msg = PSTR("UNKNOWN STATE");
131
     const PromptReason hpr = host_prompt_reason;
137
     const PromptReason hpr = host_prompt_reason;
132
     host_prompt_reason = PROMPT_NOT_DEFINED;  // Reset now ahead of logic
138
     host_prompt_reason = PROMPT_NOT_DEFINED;  // Reset now ahead of logic
133
     switch (hpr) {
139
     switch (hpr) {

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

21
  */
21
  */
22
 #pragma once
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
 #ifdef ACTION_ON_KILL
28
 #ifdef ACTION_ON_KILL
29
   void host_action_kill();
29
   void host_action_kill();
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_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
   void host_action_prompt_end();
67
   void host_action_prompt_end();
67
   void host_action_prompt_show();
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
     if (host_prompt_reason == PROMPT_NOT_DEFINED) host_prompt_do(reason, pstr, btn1, btn2);
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
     if (level < alert_level) return;
1303
     if (level < alert_level) return;
1304
     alert_level = level;
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
     // Since the message is encoded in UTF8 it must
1308
     // Since the message is encoded in UTF8 it must
1309
     // only be cut on a character boundary.
1309
     // only be cut on a character boundary.
1450
     TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
1450
     TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
1451
   }
1451
   }
1452
   void MarlinUI::set_status_P(PGM_P message, const int8_t) {
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
   void MarlinUI::status_printf_P(const uint8_t, PGM_P const message, ...) {
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
 #endif // !HAS_DISPLAY
1459
 #endif // !HAS_DISPLAY

Loading…
Cancel
Save