Bläddra i källkod

🎨 Apply F() to serial macros

Scott Lahteine 3 år sedan
förälder
incheckning
520b97083e

+ 4
- 4
Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp Visa fil

@@ -90,15 +90,15 @@ bool PersistentStore::access_finish() {
90 90
 // to see errors that are happening in read_data / write_data
91 91
 static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
92 92
   #if ENABLED(DEBUG_SD_EEPROM_EMULATION)
93
-    PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
93
+    FSTR_P const rw_str = write ? F("write") : F("read");
94 94
     SERIAL_CHAR(' ');
95
-    SERIAL_ECHOPGM_P(rw_str);
95
+    SERIAL_ECHOF(rw_str);
96 96
     SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)");
97 97
     if (total) {
98 98
       SERIAL_ECHOPGM(" f_");
99
-      SERIAL_ECHOPGM_P(rw_str);
99
+      SERIAL_ECHOF(rw_str);
100 100
       SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
101
-      SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
101
+      SERIAL_ECHOLNF(write ? F("written=") : F("read="), total);
102 102
     }
103 103
     else
104 104
       SERIAL_ECHOLNPGM(" f_lseek()=", s);

+ 7
- 1
Marlin/src/core/debug_out.h Visa fil

@@ -36,6 +36,8 @@
36 36
 #undef DEBUG_ECHOLN
37 37
 #undef DEBUG_ECHOPGM
38 38
 #undef DEBUG_ECHOLNPGM
39
+#undef DEBUG_ECHOF
40
+#undef DEBUG_ECHOLNF
39 41
 #undef DEBUG_ECHOPGM_P
40 42
 #undef DEBUG_ECHOLNPGM_P
41 43
 #undef DEBUG_ECHOPAIR_F
@@ -54,7 +56,7 @@
54 56
 #if DEBUG_OUT
55 57
 
56 58
   #include "debug_section.h"
57
-  #define DEBUG_SECTION(N,S,D)    SectionLog N(PSTR(S),D)
59
+  #define DEBUG_SECTION(N,S,D)    SectionLog N(F(S),D)
58 60
 
59 61
   #define DEBUG_ECHO_START        SERIAL_ECHO_START
60 62
   #define DEBUG_ERROR_START       SERIAL_ERROR_START
@@ -65,6 +67,8 @@
65 67
   #define DEBUG_ECHOLN            SERIAL_ECHOLN
66 68
   #define DEBUG_ECHOPGM           SERIAL_ECHOPGM
67 69
   #define DEBUG_ECHOLNPGM         SERIAL_ECHOLNPGM
70
+  #define DEBUG_ECHOF             SERIAL_ECHOF
71
+  #define DEBUG_ECHOLNF           SERIAL_ECHOLNF
68 72
   #define DEBUG_ECHOPGM           SERIAL_ECHOPGM
69 73
   #define DEBUG_ECHOPGM_P         SERIAL_ECHOPGM_P
70 74
   #define DEBUG_ECHOPAIR_F        SERIAL_ECHOPAIR_F
@@ -94,6 +98,8 @@
94 98
   #define DEBUG_ECHOLN(...)         NOOP
95 99
   #define DEBUG_ECHOPGM(...)        NOOP
96 100
   #define DEBUG_ECHOLNPGM(...)      NOOP
101
+  #define DEBUG_ECHOF(...)          NOOP
102
+  #define DEBUG_ECHOLNF(...)        NOOP
97 103
   #define DEBUG_ECHOPGM_P(...)      NOOP
98 104
   #define DEBUG_ECHOLNPGM_P(...)    NOOP
99 105
   #define DEBUG_ECHOPAIR_F(...)     NOOP

+ 8
- 8
Marlin/src/core/debug_section.h Visa fil

@@ -26,22 +26,22 @@
26 26
 
27 27
 class SectionLog {
28 28
 public:
29
-  SectionLog(PGM_P const msg=nullptr, bool inbug=true) {
30
-    the_msg = msg;
31
-    if ((debug = inbug)) echo_msg(PSTR(">>>"));
29
+  SectionLog(FSTR_P const fmsg=nullptr, bool inbug=true) {
30
+    the_msg = fmsg;
31
+    if ((debug = inbug)) echo_msg(F(">>>"));
32 32
   }
33 33
 
34
-  ~SectionLog() { if (debug) echo_msg(PSTR("<<<")); }
34
+  ~SectionLog() { if (debug) echo_msg(F("<<<")); }
35 35
 
36 36
 private:
37
-  PGM_P the_msg;
37
+  FSTR_P the_msg;
38 38
   bool debug;
39 39
 
40
-  void echo_msg(PGM_P const pre) {
41
-    SERIAL_ECHOPGM_P(pre);
40
+  void echo_msg(FSTR_P const fpre) {
41
+    SERIAL_ECHOF(fpre);
42 42
     if (the_msg) {
43 43
       SERIAL_CHAR(' ');
44
-      SERIAL_ECHOPGM_P(the_msg);
44
+      SERIAL_ECHOF(the_msg);
45 45
     }
46 46
     SERIAL_CHAR(' ');
47 47
     print_pos(current_position);

+ 12
- 12
Marlin/src/core/serial.cpp Visa fil

@@ -69,23 +69,23 @@ PGMSTR(SP_I_LBL, " " AXIS4_STR ":"); PGMSTR(SP_J_LBL, " " AXIS5_STR ":"); PGMSTR
69 69
 
70 70
 #endif
71 71
 
72
-void serialprintPGM(PGM_P str) {
72
+void serial_print_P(PGM_P str) {
73 73
   while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c);
74 74
 }
75 75
 
76
-void serial_echo_start()  { static PGMSTR(echomagic, "echo:"); serialprintPGM(echomagic); }
77
-void serial_error_start() { static PGMSTR(errormagic, "Error:"); serialprintPGM(errormagic); }
76
+void serial_echo_start()  { static PGMSTR(echomagic, "echo:"); serial_print_P(echomagic); }
77
+void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P(errormagic); }
78 78
 
79 79
 void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
80 80
 
81
-void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post/*=nullptr*/) {
82
-  if (pre) serialprintPGM(pre);
83
-  serialprintPGM(onoff ? on : off);
84
-  if (post) serialprintPGM(post);
81
+void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) {
82
+  if (pre) serial_print(pre);
83
+  serial_print(onoff ? on : off);
84
+  if (post) serial_print(post);
85 85
 }
86
-void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(STR_ON) : PSTR(STR_OFF)); }
86
+void serialprint_onoff(const bool onoff) { serial_print(onoff ? F(STR_ON) : F(STR_OFF)); }
87 87
 void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
88
-void serialprint_truefalse(const bool tf) { serialprintPGM(tf ? PSTR("true") : PSTR("false")); }
88
+void serialprint_truefalse(const bool tf) { serial_print(tf ? F("true") : F("false")); }
89 89
 
90 90
 void print_bin(uint16_t val) {
91 91
   for (uint8_t i = 16; i--;) {
@@ -94,10 +94,10 @@ void print_bin(uint16_t val) {
94 94
   }
95 95
 }
96 96
 
97
-void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) {
98
-  if (prefix) serialprintPGM(prefix);
97
+void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) {
98
+  if (prefix) serial_print(prefix);
99 99
   SERIAL_ECHOPGM_P(
100 100
     LIST_N(DOUBLE(LINEAR_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k)
101 101
   );
102
-  if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
102
+  if (suffix) serial_print(suffix); else SERIAL_EOL();
103 103
 }

+ 82
- 44
Marlin/src/core/serial.h Visa fil

@@ -167,13 +167,10 @@ inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); }
167 167
 #define AS_CHAR(C) serial_char_t(C)
168 168
 #define AS_DIGIT(C) AS_CHAR('0' + (C))
169 169
 
170
-// SERIAL_ECHO_F prints a floating point value with optional precision
171
-inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
172
-
173 170
 template <typename T>
174 171
 void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); }
175 172
 
176
-// SERIAL_PRINT works like SERIAL_ECHO but allow to specify the encoding base of the number printed
173
+// SERIAL_PRINT works like SERIAL_ECHO but also takes the numeric base
177 174
 template <typename T, typename U>
178 175
 void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); }
179 176
 
@@ -184,8 +181,20 @@ void SERIAL_PRINTLN(T x, PrintBase y) { SERIAL_IMPL.println(x, y); }
184 181
 inline void SERIAL_FLUSH()    { SERIAL_IMPL.flush(); }
185 182
 inline void SERIAL_FLUSHTX()  { SERIAL_IMPL.flushTX(); }
186 183
 
187
-// Print a single PROGMEM string to serial
188
-void serialprintPGM(PGM_P str);
184
+// Serial echo and error prefixes
185
+#define SERIAL_ECHO_START()           serial_echo_start()
186
+#define SERIAL_ERROR_START()          serial_error_start()
187
+
188
+// Serial end-of-line
189
+#define SERIAL_EOL()                  SERIAL_CHAR('\n')
190
+
191
+// Print a single PROGMEM, PGM_P, or PSTR() string.
192
+void serial_print_P(PGM_P str);
193
+inline void serial_println_P(PGM_P str) { serial_print_P(str); SERIAL_EOL(); }
194
+
195
+// Print a single FSTR_P, F(), or FPSTR() string.
196
+inline void serial_print(FSTR_P const fstr) { serial_print_P(FTOP(fstr)); }
197
+inline void serial_println(FSTR_P const fstr) { serial_println_P(FTOP(fstr)); }
189 198
 
190 199
 //
191 200
 // SERIAL_ECHOPGM... macros are used to output string-value pairs.
@@ -195,8 +204,8 @@ void serialprintPGM(PGM_P str);
195 204
 #define __SEP_N(N,V...)           _SEP_##N(V)
196 205
 #define _SEP_N(N,V...)            __SEP_N(N,V)
197 206
 #define _SEP_N_REF()              _SEP_N
198
-#define _SEP_1(s)                 serialprintPGM(PSTR(s));
199
-#define _SEP_2(s,v)               serial_echopair_PGM(PSTR(s),v);
207
+#define _SEP_1(s)                 serial_print(F(s));
208
+#define _SEP_2(s,v)               serial_echopair(F(s),v);
200 209
 #define _SEP_3(s,v,V...)          _SEP_2(s,v); DEFER2(_SEP_N_REF)()(TWO_ARGS(V),V);
201 210
 #define SERIAL_ECHOPGM(V...)      do{ EVAL(_SEP_N(TWO_ARGS(V),V)); }while(0)
202 211
 
@@ -204,8 +213,8 @@ void serialprintPGM(PGM_P str);
204 213
 #define __SELP_N(N,V...)          _SELP_##N(V)
205 214
 #define _SELP_N(N,V...)           __SELP_N(N,V)
206 215
 #define _SELP_N_REF()             _SELP_N
207
-#define _SELP_1(s)                serialprintPGM(PSTR(s "\n"));
208
-#define _SELP_2(s,v)              serial_echopair_PGM(PSTR(s),v); SERIAL_EOL();
216
+#define _SELP_1(s)                serial_print(F(s "\n"));
217
+#define _SELP_2(s,v)              serial_echolnpair(F(s),v);
209 218
 #define _SELP_3(s,v,V...)         _SEP_2(s,v); DEFER2(_SELP_N_REF)()(TWO_ARGS(V),V);
210 219
 #define SERIAL_ECHOLNPGM(V...)    do{ EVAL(_SELP_N(TWO_ARGS(V),V)); }while(0)
211 220
 
@@ -213,8 +222,8 @@ void serialprintPGM(PGM_P str);
213 222
 #define __SEP_N_P(N,V...)         _SEP_##N##_P(V)
214 223
 #define _SEP_N_P(N,V...)          __SEP_N_P(N,V)
215 224
 #define _SEP_N_P_REF()            _SEP_N_P
216
-#define _SEP_1_P(p)               serialprintPGM(p);
217
-#define _SEP_2_P(p,v)             serial_echopair_PGM(p,v);
225
+#define _SEP_1_P(p)               serial_print_P(p);
226
+#define _SEP_2_P(p,v)             serial_echopair_P(p,v);
218 227
 #define _SEP_3_P(p,v,V...)        _SEP_2_P(p,v); DEFER2(_SEP_N_P_REF)()(TWO_ARGS(V),V);
219 228
 #define SERIAL_ECHOPGM_P(V...)    do{ EVAL(_SEP_N_P(TWO_ARGS(V),V)); }while(0)
220 229
 
@@ -222,11 +231,29 @@ void serialprintPGM(PGM_P str);
222 231
 #define __SELP_N_P(N,V...)        _SELP_##N##_P(V)
223 232
 #define _SELP_N_P(N,V...)         __SELP_N_P(N,V)
224 233
 #define _SELP_N_P_REF()           _SELP_N_P
225
-#define _SELP_1_P(p)              { serialprintPGM(p); SERIAL_EOL(); }
226
-#define _SELP_2_P(p,v)            { serial_echopair_PGM(p,v); SERIAL_EOL(); }
234
+#define _SELP_1_P(p)              serial_println_P(p)
235
+#define _SELP_2_P(p,v)            serial_echolnpair_P(p,v)
227 236
 #define _SELP_3_P(p,v,V...)       { _SEP_2_P(p,v); DEFER2(_SELP_N_P_REF)()(TWO_ARGS(V),V); }
228 237
 #define SERIAL_ECHOLNPGM_P(V...)  do{ EVAL(_SELP_N_P(TWO_ARGS(V),V)); }while(0)
229 238
 
239
+// Print up to 20 pairs of values. Odd elements must be FSTR_P, F(), or FPSTR().
240
+#define __SEP_N_F(N,V...)         _SEP_##N##_F(V)
241
+#define _SEP_N_F(N,V...)          __SEP_N_F(N,V)
242
+#define _SEP_N_F_REF()            _SEP_N_F
243
+#define _SEP_1_F(p)               serial_print(p);
244
+#define _SEP_2_F(p,v)             serial_echopair(p,v);
245
+#define _SEP_3_F(p,v,V...)        _SEP_2_F(p,v); DEFER2(_SEP_N_F_REF)()(TWO_ARGS(V),V);
246
+#define SERIAL_ECHOF(V...)        do{ EVAL(_SEP_N_F(TWO_ARGS(V),V)); }while(0)
247
+
248
+// Print up to 20 pairs of values followed by newline. Odd elements must be FSTR_P, F(), or FPSTR().
249
+#define __SELP_N_F(N,V...)        _SELP_##N##_F(V)
250
+#define _SELP_N_F(N,V...)         __SELP_N_F(N,V)
251
+#define _SELP_N_F_REF()           _SELP_N_F
252
+#define _SELP_1_F(p)              serial_println(p)
253
+#define _SELP_2_F(p,v)            serial_echolnpair(p,v)
254
+#define _SELP_3_F(p,v,V...)       { _SEP_2_F(p,v); DEFER2(_SELP_N_F_REF)()(TWO_ARGS(V),V); }
255
+#define SERIAL_ECHOLNF(V...)      do{ EVAL(_SELP_N_F(TWO_ARGS(V),V)); }while(0)
256
+
230 257
 #ifdef AllowDifferentTypeInList
231 258
 
232 259
   inline void SERIAL_ECHOLIST_IMPL() {}
@@ -236,47 +263,49 @@ void serialprintPGM(PGM_P str);
236 263
   template <typename T, typename ... Args>
237 264
   void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) {
238 265
     SERIAL_IMPL.print(t);
239
-    serialprintPGM(PSTR(", "));
266
+    serial_print(F(", "));
240 267
     SERIAL_ECHOLIST_IMPL(args...);
241 268
   }
242 269
 
243 270
   template <typename ... Args>
244
-  void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) {
245
-    SERIAL_IMPL.print(str);
271
+  void SERIAL_ECHOLIST(FSTR_P const str, Args && ... args) {
272
+    SERIAL_IMPL.print(FTOP(str));
246 273
     SERIAL_ECHOLIST_IMPL(args...);
247 274
   }
248 275
 
249 276
 #else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead)
250 277
 
251 278
   template <typename ... Args>
252
-  void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) {
253
-    serialprintPGM(str);
279
+  void SERIAL_ECHOLIST(FSTR_P const fstr, Args && ... args) {
280
+    serial_print(fstr);
254 281
     typename Private::first_type_of<Args...>::type values[] = { args... };
255 282
     constexpr size_t argsSize = sizeof...(args);
256 283
     for (size_t i = 0; i < argsSize; i++) {
257
-      if (i) serialprintPGM(PSTR(", "));
284
+      if (i) serial_print(F(", "));
258 285
       SERIAL_IMPL.print(values[i]);
259 286
     }
260 287
   }
261 288
 
262 289
 #endif
263 290
 
264
-#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serialprintPGM(P); SERIAL_ECHO_F(V); }while(0)
265
-#define SERIAL_ECHOLNPAIR_F_P(V...) do{ SERIAL_ECHOPAIR_F_P(V); SERIAL_EOL(); }while(0)
291
+// SERIAL_ECHO_F prints a floating point value with optional precision
292
+inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
293
+
294
+#define SERIAL_ECHOPAIR_F_P(P,V...)   do{ serial_print_P(P); SERIAL_ECHO_F(V); }while(0)
295
+#define SERIAL_ECHOLNPAIR_F_P(P,V...) do{ SERIAL_ECHOPAIR_F_P(P,V); SERIAL_EOL(); }while(0)
266 296
 
267
-#define SERIAL_ECHOPAIR_F(S,V...)   SERIAL_ECHOPAIR_F_P(PSTR(S),V)
268
-#define SERIAL_ECHOLNPAIR_F(V...)   do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0)
297
+#define SERIAL_ECHOPAIR_F_F(S,V...)   do{ serial_print(S); SERIAL_ECHO_F(V); }while(0)
298
+#define SERIAL_ECHOLNPAIR_F_F(S,V...) do{ SERIAL_ECHOPAIR_F_F(S,V); SERIAL_EOL(); }while(0)
269 299
 
270
-#define SERIAL_ECHO_START()         serial_echo_start()
271
-#define SERIAL_ERROR_START()        serial_error_start()
272
-#define SERIAL_EOL()                SERIAL_CHAR('\n')
300
+#define SERIAL_ECHOPAIR_F(S,V...)     SERIAL_ECHOPAIR_F_F(F(S),V)
301
+#define SERIAL_ECHOLNPAIR_F(V...)     do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0)
273 302
 
274
-#define SERIAL_ECHO_MSG(V...)       do{ SERIAL_ECHO_START();  SERIAL_ECHOLNPGM(V); }while(0)
275
-#define SERIAL_ERROR_MSG(V...)      do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0)
303
+#define SERIAL_ECHO_MSG(V...)         do{ SERIAL_ECHO_START();  SERIAL_ECHOLNPGM(V); }while(0)
304
+#define SERIAL_ERROR_MSG(V...)        do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0)
276 305
 
277
-#define SERIAL_ECHO_SP(C)           serial_spaces(C)
306
+#define SERIAL_ECHO_SP(C)             serial_spaces(C)
278 307
 
279
-#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, PSTR(PRE), PSTR(ON), PSTR(OFF), PSTR(POST))
308
+#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, F(PRE), F(ON), F(OFF), F(POST))
280 309
 
281 310
 #if SERIAL_FLOAT_PRECISION
282 311
   #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION)
@@ -287,33 +316,42 @@ void serialprintPGM(PGM_P str);
287 316
 //
288 317
 // Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
289 318
 //
290
-inline void serial_echopair_PGM(PGM_P const s_P, serial_char_t v) { serialprintPGM(s_P); SERIAL_CHAR(v.c); }
291
-
292
-inline void serial_echopair_PGM(PGM_P const s_P, float v)         { serialprintPGM(s_P); SERIAL_DECIMAL(v); }
293
-inline void serial_echopair_PGM(PGM_P const s_P, double v)        { serialprintPGM(s_P); SERIAL_DECIMAL(v); }
294
-inline void serial_echopair_PGM(PGM_P const s_P, const char *v)   { serialprintPGM(s_P); SERIAL_ECHO(v); }
319
+inline void serial_echopair_P(PGM_P const pstr, serial_char_t v) { serial_print_P(pstr); SERIAL_CHAR(v.c); }
320
+inline void serial_echopair_P(PGM_P const pstr, float v)         { serial_print_P(pstr); SERIAL_DECIMAL(v); }
321
+inline void serial_echopair_P(PGM_P const pstr, double v)        { serial_print_P(pstr); SERIAL_DECIMAL(v); }
322
+//inline void serial_echopair_P(PGM_P const pstr, const char *v)   { serial_print_P(pstr); SERIAL_ECHO(v); }
323
+inline void serial_echopair_P(PGM_P const pstr, FSTR_P v)        { serial_print_P(pstr); SERIAL_ECHOF(v); }
295 324
 
296 325
 // Default implementation for types without a specialization. Handles integers.
297 326
 template <typename T>
298
-void serial_echopair_PGM(PGM_P const s_P, T v)   { serialprintPGM(s_P); SERIAL_ECHO(v); }
327
+inline void serial_echopair_P(PGM_P const pstr, T v) { serial_print_P(pstr); SERIAL_ECHO(v); }
328
+
329
+// Add a newline.
330
+template <typename T>
331
+inline void serial_echolnpair_P(PGM_P const pstr, T v) { serial_echopair_P(pstr, v); SERIAL_EOL(); }
332
+
333
+// Catch-all for __FlashStringHelper *
334
+template <typename T>
335
+inline void serial_echopair(FSTR_P const fstr, T v) { serial_echopair_P(FTOP(fstr), v); }
299 336
 
300
-inline void serial_echopair_PGM(PGM_P const s_P, bool v)    { serial_echopair_PGM(s_P, (int)v); }
301
-inline void serial_echopair_PGM(PGM_P const s_P, void *v)   { serial_echopair_PGM(s_P, (uintptr_t)v); }
337
+// Add a newline to the serial output
338
+template <typename T>
339
+inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP(fstr), v); }
302 340
 
303 341
 void serial_echo_start();
304 342
 void serial_error_start();
305
-void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post=nullptr);
343
+void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr);
306 344
 void serialprint_onoff(const bool onoff);
307 345
 void serialprintln_onoff(const bool onoff);
308 346
 void serialprint_truefalse(const bool tf);
309 347
 void serial_spaces(uint8_t count);
310 348
 
311 349
 void print_bin(const uint16_t val);
312
-void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix=nullptr, PGM_P const suffix=nullptr);
350
+void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr);
313 351
 
314
-inline void print_pos(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) {
352
+inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) {
315 353
   print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix);
316 354
 }
317 355
 
318
-#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, PSTR("  " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0)
319
-#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, PSTR(PREFIX), nullptr); }while(0)
356
+#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F("  " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0)
357
+#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, F(PREFIX)); }while(0)

+ 3
- 3
Marlin/src/core/utility.cpp Visa fil

@@ -92,9 +92,9 @@ void safe_delay(millis_t ms) {
92 92
           SERIAL_ECHOPGM(" (Aligned With");
93 93
 
94 94
         if (probe.offset_xy.y > 0)
95
-          SERIAL_ECHOPGM_P(ENABLED(IS_SCARA) ? PSTR("-Distal") : PSTR("-Back"));
95
+          SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back")));
96 96
         else if (probe.offset_xy.y < 0)
97
-          SERIAL_ECHOPGM_P(ENABLED(IS_SCARA) ? PSTR("-Proximal") : PSTR("-Front"));
97
+          SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front")));
98 98
         else if (probe.offset_xy.x != 0)
99 99
           SERIAL_ECHOPGM("-Center");
100 100
 
@@ -102,7 +102,7 @@ void safe_delay(millis_t ms) {
102 102
 
103 103
       #endif
104 104
 
105
-      SERIAL_ECHOPGM_P(probe.offset.z < 0 ? PSTR("Below") : probe.offset.z > 0 ? PSTR("Above") : PSTR("Same Z as"));
105
+      SERIAL_ECHOF(probe.offset.z < 0 ? F("Below") : probe.offset.z > 0 ? F("Above") : F("Same Z as"));
106 106
       SERIAL_ECHOLNPGM(" Nozzle)");
107 107
 
108 108
     #endif

+ 3
- 5
Marlin/src/feature/bedlevel/ubl/ubl.cpp Visa fil

@@ -180,10 +180,8 @@ void unified_bed_leveling::display_map(const uint8_t map_type) {
180 180
     SERIAL_EOL();
181 181
     serial_echo_column_labels(eachsp - 2);
182 182
   }
183
-  else {
184
-    SERIAL_ECHOPGM(" for ");
185
-    SERIAL_ECHOPGM_P(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
186
-  }
183
+  else
184
+    SERIAL_ECHOPGM(" for ", csv ? F("CSV:\n") : F("LCD:\n"));
187 185
 
188 186
   // Add XY probe offset from extruder because probe.probe_at_point() subtracts them when
189 187
   // moving to the XY position to be measured. This ensures better agreement between
@@ -213,7 +211,7 @@ void unified_bed_leveling::display_map(const uint8_t map_type) {
213 211
         // TODO: Display on Graphical LCD
214 212
       }
215 213
       else if (isnan(f))
216
-        SERIAL_ECHOPGM_P(human ? PSTR("  .   ") : PSTR("NAN"));
214
+        SERIAL_ECHOF(human ? F("  .   ") : F("NAN"));
217 215
       else if (human || csv) {
218 216
         if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' ');  // Display sign also for positive numbers (' ' for 0)
219 217
         SERIAL_ECHO_F(f, 3);                                    // Positive: 5 digits, Negative: 6 digits

+ 1
- 1
Marlin/src/feature/encoder_i2c.cpp Visa fil

@@ -232,7 +232,7 @@ bool I2CPositionEncoder::passes_test(const bool report) {
232 232
   if (report) {
233 233
     if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. ");
234 234
     SERIAL_CHAR(axis_codes[encoderAxis]);
235
-    serial_ternary(H == I2CPE_MAG_SIG_BAD, PSTR(" axis "), PSTR("magnetic strip "), PSTR("encoder "));
235
+    serial_ternary(H == I2CPE_MAG_SIG_BAD, F(" axis "), F("magnetic strip "), F("encoder "));
236 236
     switch (H) {
237 237
       case I2CPE_MAG_SIG_GOOD:
238 238
       case I2CPE_MAG_SIG_MID:

+ 2
- 3
Marlin/src/feature/meatpack.cpp Visa fil

@@ -169,10 +169,9 @@ void MeatPack::handle_command(const MeatPack_Command c) {
169 169
 void MeatPack::report_state() {
170 170
   // NOTE: if any configuration vars are added below, the outgoing sync text for host plugin
171 171
   // should not contain the "PV' substring, as this is used to indicate protocol version
172
-  SERIAL_ECHOPGM("[MP] ");
173
-  SERIAL_ECHOPGM(MeatPack_ProtocolVersion " ");
172
+  SERIAL_ECHOPGM("[MP] " MeatPack_ProtocolVersion " ");
174 173
   serialprint_onoff(TEST(state, MPConfig_Bit_Active));
175
-  SERIAL_ECHOPGM_P(TEST(state, MPConfig_Bit_NoSpaces) ? PSTR(" NSP\n") : PSTR(" ESP\n"));
174
+  SERIAL_ECHOF(TEST(state, MPConfig_Bit_NoSpaces) ? F(" NSP\n") : F(" ESP\n"));
176 175
 }
177 176
 
178 177
 /**

+ 1
- 1
Marlin/src/feature/pause.cpp Visa fil

@@ -486,7 +486,7 @@ void show_continue_prompt(const bool is_reload) {
486 486
 
487 487
   ui.pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING);
488 488
   SERIAL_ECHO_START();
489
-  SERIAL_ECHOPGM_P(is_reload ? PSTR(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n"));
489
+  SERIAL_ECHOF(is_reload ? F(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : F(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n"));
490 490
 }
491 491
 
492 492
 void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep_count/*=0*/ DXC_ARGS) {

+ 3
- 3
Marlin/src/feature/probe_temp_comp.cpp Visa fil

@@ -69,11 +69,11 @@ void ProbeTempComp::print_offsets() {
69 69
   LOOP_L_N(s, TSI_COUNT) {
70 70
     celsius_t temp = cali_info[s].start_temp;
71 71
     for (int16_t i = -1; i < cali_info[s].measurements; ++i) {
72
-      SERIAL_ECHOPGM_P(s == TSI_BED ? PSTR("Bed") :
72
+      SERIAL_ECHOF(s == TSI_BED ? F("Bed") :
73 73
         #if ENABLED(USE_TEMP_EXT_COMPENSATION)
74
-          s == TSI_EXT ? PSTR("Extruder") :
74
+          s == TSI_EXT ? F("Extruder") :
75 75
         #endif
76
-        PSTR("Probe")
76
+        F("Probe")
77 77
       );
78 78
       SERIAL_ECHOLNPGM(
79 79
         " temp: ", temp,

+ 2
- 2
Marlin/src/feature/runout.h Visa fil

@@ -317,7 +317,7 @@ class FilamentSensorBase {
317 317
             static uint8_t was_out; // = 0
318 318
             if (out != TEST(was_out, s)) {
319 319
               TBI(was_out, s);
320
-              SERIAL_ECHOLNPGM_P(PSTR("Filament Sensor "), '0' + s, out ? PSTR(" OUT") : PSTR(" IN"));
320
+              SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN"));
321 321
             }
322 322
           #endif
323 323
         }
@@ -352,7 +352,7 @@ class FilamentSensorBase {
352 352
           if (ELAPSED(ms, t)) {
353 353
             t = millis() + 1000UL;
354 354
             LOOP_L_N(i, NUM_RUNOUT_SENSORS)
355
-              SERIAL_ECHOPGM_P(i ? PSTR(", ") : PSTR("Remaining mm: "), runout_mm_countdown[i]);
355
+              SERIAL_ECHOF(i ? F(", ") : F("Remaining mm: "), runout_mm_countdown[i]);
356 356
             SERIAL_EOL();
357 357
           }
358 358
         #endif

+ 7
- 8
Marlin/src/feature/tmc_util.cpp Visa fil

@@ -561,7 +561,7 @@
561 561
   };
562 562
 
563 563
   template<class TMC>
564
-  static void print_vsense(TMC &st) { SERIAL_ECHOPGM_P(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); }
564
+  static void print_vsense(TMC &st) { SERIAL_ECHOF(st.vsense() ? F("1=.18") : F("0=.325")); }
565 565
 
566 566
   #if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130)
567 567
     static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
@@ -732,7 +732,7 @@
732 732
           SERIAL_ECHO(st.cs());
733 733
           SERIAL_ECHOPGM("/31");
734 734
           break;
735
-        case TMC_VSENSE: SERIAL_ECHOPGM_P(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break;
735
+        case TMC_VSENSE: SERIAL_ECHOF(st.vsense() ? F("1=.165") : F("0=.310")); break;
736 736
         case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
737 737
         //case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
738 738
         //case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
@@ -1256,15 +1256,14 @@ static bool test_connection(TMC &st) {
1256 1256
 
1257 1257
   if (test_result > 0) SERIAL_ECHOPGM("Error: All ");
1258 1258
 
1259
-  const char *stat;
1259
+  FSTR_P stat;
1260 1260
   switch (test_result) {
1261 1261
     default:
1262
-    case 0: stat = PSTR("OK"); break;
1263
-    case 1: stat = PSTR("HIGH"); break;
1264
-    case 2: stat = PSTR("LOW"); break;
1262
+    case 0: stat = F("OK"); break;
1263
+    case 1: stat = F("HIGH"); break;
1264
+    case 2: stat = F("LOW"); break;
1265 1265
   }
1266
-  SERIAL_ECHOPGM_P(stat);
1267
-  SERIAL_EOL();
1266
+  SERIAL_ECHOLNF(stat);
1268 1267
 
1269 1268
   return test_result;
1270 1269
 }

+ 1
- 1
Marlin/src/gcode/bedlevel/G35.cpp Visa fil

@@ -116,7 +116,7 @@ void GcodeSuite::G35() {
116 116
 
117 117
     if (DEBUGGING(LEVELING)) {
118 118
       DEBUG_ECHOPGM("Probing point ", i + 1, " (");
119
-      DEBUG_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
119
+      DEBUG_ECHOF(FPSTR(pgm_read_ptr(&tramming_point_name[i])));
120 120
       DEBUG_CHAR(')');
121 121
       DEBUG_ECHOLNPGM_P(SP_X_STR, tramming_points[i].x, SP_Y_STR, tramming_points[i].y, SP_Z_STR, z_probed_height);
122 122
     }

+ 4
- 4
Marlin/src/gcode/bedlevel/M420.cpp Visa fil

@@ -246,12 +246,12 @@ void GcodeSuite::M420_report(const bool forReplay/*=true*/) {
246 246
   report_heading_etc(forReplay, PSTR(
247 247
     TERN(MESH_BED_LEVELING, "Mesh Bed Leveling", TERN(AUTO_BED_LEVELING_UBL, "Unified Bed Leveling", "Auto Bed Leveling"))
248 248
   ));
249
-  SERIAL_ECHOPGM_P(
250
-    PSTR("  M420 S"), planner.leveling_active
249
+  SERIAL_ECHOF(
250
+    F("  M420 S"), planner.leveling_active
251 251
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
252
-      , SP_Z_STR, LINEAR_UNIT(planner.z_fade_height)
252
+      , FPSTR(SP_Z_STR), LINEAR_UNIT(planner.z_fade_height)
253 253
     #endif
254
-    , PSTR(" ; Leveling ")
254
+    , F(" ; Leveling ")
255 255
   );
256 256
   serialprintln_onoff(planner.leveling_active);
257 257
 }

+ 2
- 2
Marlin/src/gcode/config/M217.cpp Visa fil

@@ -138,8 +138,8 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) {
138 138
   #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
139 139
     SERIAL_ECHOPGM(" S", LINEAR_UNIT(toolchange_settings.swap_length));
140 140
     SERIAL_ECHOPGM_P(SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume),
141
-                      SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime),
142
-                      SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed));
141
+                     SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime),
142
+                     SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed));
143 143
     SERIAL_ECHOPGM(" R", LINEAR_UNIT(toolchange_settings.retract_speed),
144 144
                    " U", LINEAR_UNIT(toolchange_settings.unretract_speed),
145 145
                    " F", toolchange_settings.fan_speed,

+ 1
- 1
Marlin/src/gcode/config/M302.cpp Visa fil

@@ -55,7 +55,7 @@ void GcodeSuite::M302() {
55 55
     // Report current state
56 56
     SERIAL_ECHO_START();
57 57
     SERIAL_ECHOPGM("Cold extrudes are ");
58
-    SERIAL_ECHOPGM_P(thermalManager.allow_cold_extrude ? PSTR("en") : PSTR("dis"));
58
+    SERIAL_ECHOF(thermalManager.allow_cold_extrude ? F("en") : F("dis"));
59 59
     SERIAL_ECHOLNPGM("abled (min temp ", thermalManager.extrude_min_temp, "C)");
60 60
   }
61 61
 }

+ 2
- 2
Marlin/src/gcode/control/M211.cpp Visa fil

@@ -47,8 +47,8 @@ void GcodeSuite::M211_report(const bool forReplay/*=true*/) {
47 47
   report_echo_start(forReplay);
48 48
   const xyz_pos_t l_soft_min = soft_endstop.min.asLogical(),
49 49
                   l_soft_max = soft_endstop.max.asLogical();
50
-  print_pos(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" "));
51
-  print_pos(l_soft_max, PSTR(STR_SOFT_MAX));
50
+  print_pos(l_soft_min, F(STR_SOFT_MIN), F(" "));
51
+  print_pos(l_soft_max, F(STR_SOFT_MAX));
52 52
 }
53 53
 
54 54
 #endif // HAS_SOFTWARE_ENDSTOPS

+ 1
- 1
Marlin/src/gcode/control/M80_M81.cpp Visa fil

@@ -48,7 +48,7 @@
48 48
 
49 49
     // S: Report the current power supply state and exit
50 50
     if (parser.seen('S')) {
51
-      SERIAL_ECHOPGM_P(powerManager.psu_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
51
+      SERIAL_ECHOF(powerManager.psu_on ? F("PS:1\n") : F("PS:0\n"));
52 52
       return;
53 53
     }
54 54
 

+ 3
- 3
Marlin/src/gcode/feature/L6470/M122.cpp Visa fil

@@ -47,10 +47,10 @@ inline void L6470_say_status(const L64XX_axis_t axis) {
47 47
     }
48 48
   #endif
49 49
   SERIAL_ECHOPGM("\n...OUTPUT: ");
50
-  SERIAL_ECHOPGM_P(sh.STATUS_AXIS & STATUS_HIZ ? PSTR("OFF") : PSTR("ON "));
50
+  SERIAL_ECHOF(sh.STATUS_AXIS & STATUS_HIZ ? F("OFF") : F("ON "));
51 51
   SERIAL_ECHOPGM("   BUSY: "); echo_yes_no((sh.STATUS_AXIS & STATUS_BUSY) == 0);
52 52
   SERIAL_ECHOPGM("   DIR: ");
53
-  SERIAL_ECHOPGM_P((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? PSTR("FORWARD") : PSTR("REVERSE"));
53
+  SERIAL_ECHOF((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? F("FORWARD") : F("REVERSE"));
54 54
   if (sh.STATUS_AXIS_LAYOUT == L6480_STATUS_LAYOUT) {
55 55
     SERIAL_ECHOPGM("   Last Command: ");
56 56
     if (sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD) SERIAL_ECHOPGM("VALID");
@@ -67,7 +67,7 @@ inline void L6470_say_status(const L64XX_axis_t axis) {
67 67
     SERIAL_ECHOPGM("   Last Command: ");
68 68
     if (!(sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD)) SERIAL_ECHOPGM("IN");
69 69
     SERIAL_ECHOPGM("VALID    ");
70
-    SERIAL_ECHOPGM_P(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ?  PSTR("COMPLETED    ") : PSTR("Not PERFORMED"));
70
+    SERIAL_ECHOF(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ?  F("COMPLETED    ") : F("Not PERFORMED"));
71 71
     SERIAL_ECHOPGM("\n...THERMAL: ", !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_SD) ? "SHUTDOWN       " : !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_WRN) ? "WARNING        " : "OK             ");
72 72
   }
73 73
   SERIAL_ECHOPGM("   OVERCURRENT:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_OCD) == 0);

+ 1
- 1
Marlin/src/gcode/feature/L6470/M906.cpp Visa fil

@@ -107,7 +107,7 @@ void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) {
107 107
       SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps,
108 108
                       "   ADC_OUT: ", L6470_ADC_out);
109 109
       SERIAL_ECHOPGM("   Vs_compensation: ");
110
-      SERIAL_ECHOPGM_P((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_EN_VSCOMP) ? PSTR("ENABLED ") : PSTR("DISABLED"));
110
+      SERIAL_ECHOF((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_EN_VSCOMP) ? F("ENABLED ") : F("DISABLED"));
111 111
       SERIAL_ECHOLNPGM("   Compensation coefficient: ~", comp_coef * 0.01f);
112 112
 
113 113
       SERIAL_ECHOPGM("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD),

+ 2
- 2
Marlin/src/gcode/feature/powerloss/M413.cpp Visa fil

@@ -51,8 +51,8 @@ void GcodeSuite::M413() {
51 51
     #if PIN_EXISTS(POWER_LOSS)
52 52
       if (parser.seen_test('O')) recovery._outage();
53 53
     #endif
54
-    if (parser.seen_test('E')) SERIAL_ECHOPGM_P(recovery.exists() ? PSTR("PLR Exists\n") : PSTR("No PLR\n"));
55
-    if (parser.seen_test('V')) SERIAL_ECHOPGM_P(recovery.valid() ? PSTR("Valid\n") : PSTR("Invalid\n"));
54
+    if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n"));
55
+    if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n"));
56 56
   #endif
57 57
 }
58 58
 

+ 1
- 1
Marlin/src/gcode/feature/trinamic/M569.cpp Visa fil

@@ -32,7 +32,7 @@ template<typename TMC>
32 32
 void tmc_say_stealth_status(TMC &st) {
33 33
   st.printLabel();
34 34
   SERIAL_ECHOPGM(" driver mode:\t");
35
-  SERIAL_ECHOLNPGM_P(st.get_stealthChop() ? PSTR("stealthChop") : PSTR("spreadCycle"));
35
+  SERIAL_ECHOLNF(st.get_stealthChop() ? F("stealthChop") : F("spreadCycle"));
36 36
 }
37 37
 template<typename TMC>
38 38
 void tmc_set_stealthChop(TMC &st, const bool enable) {

+ 4
- 4
Marlin/src/gcode/geometry/G17-G19.cpp Visa fil

@@ -29,10 +29,10 @@
29 29
 inline void report_workspace_plane() {
30 30
   SERIAL_ECHO_START();
31 31
   SERIAL_ECHOPGM("Workspace Plane ");
32
-  SERIAL_ECHOPGM_P(
33
-      gcode.workspace_plane == GcodeSuite::PLANE_YZ ? PSTR("YZ\n")
34
-    : gcode.workspace_plane == GcodeSuite::PLANE_ZX ? PSTR("ZX\n")
35
-                                                    : PSTR("XY\n")
32
+  SERIAL_ECHOF(
33
+      gcode.workspace_plane == GcodeSuite::PLANE_YZ ? F("YZ\n")
34
+    : gcode.workspace_plane == GcodeSuite::PLANE_ZX ? F("ZX\n")
35
+                                                    : F("XY\n")
36 36
   );
37 37
 }
38 38
 

+ 2
- 2
Marlin/src/gcode/parser.h Visa fil

@@ -351,8 +351,8 @@ public:
351 351
     static inline char temp_units_code() {
352 352
       return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C';
353 353
     }
354
-    static inline PGM_P temp_units_name() {
355
-      return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
354
+    static inline FSTR_P temp_units_name() {
355
+      return input_temp_units == TEMPUNIT_K ? F("Kelvin") : input_temp_units == TEMPUNIT_F ? F("Fahrenheit") : F("Celsius");
356 356
     }
357 357
 
358 358
     #if HAS_LCD_MENU && DISABLED(DISABLE_M503)

+ 1
- 1
Marlin/src/gcode/units/M149.cpp Visa fil

@@ -39,7 +39,7 @@ void GcodeSuite::M149() {
39 39
 void GcodeSuite::M149_report(const bool forReplay/*=true*/) {
40 40
   report_heading_etc(forReplay, PSTR(STR_TEMPERATURE_UNITS));
41 41
   SERIAL_ECHOPGM("  M149 ", AS_CHAR(parser.temp_units_code()), " ; Units in ");
42
-  SERIAL_ECHOLNPGM_P(parser.temp_units_name());
42
+  SERIAL_ECHOLNF(parser.temp_units_name());
43 43
 }
44 44
 
45 45
 #endif // TEMPERATURE_UNITS_SUPPORT

+ 5
- 5
Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp Visa fil

@@ -306,7 +306,7 @@ void ChironTFT::PowerLossRecovery()  {
306 306
   printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover.
307 307
   last_error = AC_error_powerloss;
308 308
   PlayTune(BEEPER_PIN, SOS, 1);
309
-  SERIAL_ECHOLNPGM_P(AC_msg_powerloss_recovery);
309
+  SERIAL_ECHOLNF(AC_msg_powerloss_recovery);
310 310
 }
311 311
 
312 312
 void ChironTFT::PrintComplete() {
@@ -488,7 +488,7 @@ void ChironTFT::ProcessPanelRequest() {
488 488
         if (tpos != -1) {
489 489
           if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') {
490 490
             panel_type = AC_panel_standard;
491
-            SERIAL_ECHOLNPGM_P(AC_msg_old_panel_detected);
491
+            SERIAL_ECHOLNF(AC_msg_old_panel_detected);
492 492
           }
493 493
         }
494 494
         else {
@@ -496,7 +496,7 @@ void ChironTFT::ProcessPanelRequest() {
496 496
           if (tpos != -1) {
497 497
             if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') {
498 498
               panel_type = AC_panel_new;
499
-              SERIAL_ECHOLNPGM_P(AC_msg_new_panel_detected);
499
+              SERIAL_ECHOLNF(AC_msg_new_panel_detected);
500 500
             }
501 501
           }
502 502
         }
@@ -825,7 +825,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
825 825
         if (!isPrinting()) {
826 826
           injectCommands_P(PSTR("M501\nM420 S1"));
827 827
           selectedmeshpoint.x = selectedmeshpoint.y = 99;
828
-          SERIAL_ECHOLNPGM_P(AC_msg_mesh_changes_abandoned);
828
+          SERIAL_ECHOLNF(AC_msg_mesh_changes_abandoned);
829 829
         }
830 830
       }
831 831
 
@@ -833,7 +833,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
833 833
         if (!isPrinting()) {
834 834
           setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made
835 835
           injectCommands_P(PSTR("M500"));
836
-          SERIAL_ECHOLNPGM_P(AC_msg_mesh_changes_saved);
836
+          SERIAL_ECHOLNF(AC_msg_mesh_changes_saved);
837 837
           selectedmeshpoint.x = selectedmeshpoint.y = 99;
838 838
         }
839 839
       }

+ 19
- 19
Marlin/src/module/temperature.cpp Visa fil

@@ -755,10 +755,10 @@ volatile bool Temperature::raw_temps_ready = false;
755 755
         SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED);
756 756
 
757 757
         #if EITHER(PIDTEMPBED, PIDTEMPCHAMBER)
758
-          PGM_P const estring = GHV(PSTR("chamber"), PSTR("bed"), NUL_STR);
759
-          say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp);
760
-          say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki);
761
-          say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd);
758
+          FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR));
759
+          say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp);
760
+          say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki);
761
+          say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd);
762 762
         #else
763 763
           say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp);
764 764
           say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki);
@@ -1737,21 +1737,21 @@ void Temperature::manage_heater() {
1737 1737
     SERIAL_ECHOPAIR_F_P(SP_B_STR, t.beta, 1);
1738 1738
     SERIAL_ECHOPAIR_F_P(SP_C_STR, t.sh_c_coeff, 9);
1739 1739
     SERIAL_ECHOPGM(" ; ");
1740
-    SERIAL_ECHOPGM_P(
1741
-      TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :)
1742
-      TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :)
1743
-      TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :)
1744
-      TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :)
1745
-      TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :)
1746
-      TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :)
1747
-      TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :)
1748
-      TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :)
1749
-      TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? PSTR("BED") :)
1750
-      TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :)
1751
-      TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? PSTR("COOLER") :)
1752
-      TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :)
1753
-      TERN_(TEMP_SENSOR_BOARD_IS_CUSTOM, t_index == CTI_BOARD ? PSTR("BOARD") :)
1754
-      TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? PSTR("REDUNDANT") :)
1740
+    SERIAL_ECHOF(
1741
+      TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? F("HOTEND 0") :)
1742
+      TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? F("HOTEND 1") :)
1743
+      TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? F("HOTEND 2") :)
1744
+      TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? F("HOTEND 3") :)
1745
+      TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? F("HOTEND 4") :)
1746
+      TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? F("HOTEND 5") :)
1747
+      TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? F("HOTEND 6") :)
1748
+      TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? F("HOTEND 7") :)
1749
+      TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? F("BED") :)
1750
+      TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? F("CHAMBER") :)
1751
+      TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? F("COOLER") :)
1752
+      TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? F("PROBE") :)
1753
+      TERN_(TEMP_SENSOR_BOARD_IS_CUSTOM, t_index == CTI_BOARD ? F("BOARD") :)
1754
+      TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? F("REDUNDANT") :)
1755 1755
       nullptr
1756 1756
     );
1757 1757
     SERIAL_EOL();

+ 2
- 2
Marlin/src/sd/cardreader.cpp Visa fil

@@ -614,7 +614,7 @@ void announceOpen(const uint8_t doing, const char * const path) {
614 614
     PORT_REDIRECT(SerialMask::All);
615 615
     SERIAL_ECHO_START();
616 616
     SERIAL_ECHOPGM("Now ");
617
-    SERIAL_ECHOPGM_P(doing == 1 ? PSTR("doing") : PSTR("fresh"));
617
+    SERIAL_ECHOF(doing == 1 ? F("doing") : F("fresh"));
618 618
     SERIAL_ECHOLNPGM(" file: ", path);
619 619
   }
620 620
 }
@@ -1325,7 +1325,7 @@ void CardReader::fileHasFinished() {
1325 1325
       removeFile(recovery.filename);
1326 1326
       #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
1327 1327
         SERIAL_ECHOPGM("Power-loss file delete");
1328
-        SERIAL_ECHOPGM_P(jobRecoverFileExists() ? PSTR(" failed.\n") : PSTR("d.\n"));
1328
+        SERIAL_ECHOF(jobRecoverFileExists() ? F(" failed.\n") : F("d.\n"));
1329 1329
       #endif
1330 1330
     }
1331 1331
   }

+ 1
- 1
docs/Serial.md Visa fil

@@ -62,7 +62,7 @@ The following macros are defined (in `serial.h`) to output data to the serial po
62 62
 | `SERIAL_ECHOLNPGM` | Same as `SERIAL_ECHOPGM` | Do `SERIAL_ECHOPGM`, adding a newline | `SERIAL_ECHOPGM("Alice", 56);` | `alice56` |
63 63
 | `SERIAL_ECHOPGM_P` | Like `SERIAL_ECHOPGM` but takes PGM strings | Print a series of PGM strings and values alternately | `SERIAL_ECHOPGM_P(GET_TEXT(MSG_HELLO), 123);` | `Hello123` |
64 64
 | `SERIAL_ECHOLNPGM_P` | Same as `SERIAL_ECHOPGM_P` | Do `SERIAL_ECHOPGM_P`, adding a newline | `SERIAL_ECHOLNPGM_P(PSTR("Alice"), 78);` | `alice78\n` |
65
-| `SERIAL_ECHOLIST` | String literal, values | Print a string literal and a list of values | `SERIAL_ECHOLIST("Key ", 1, 2, 3);` | `Key 1, 2, 3` |
65
+| `SERIAL_ECHOLIST` | String literal, values | Print a string literal and a list of values | `SERIAL_ECHOLIST(F("Key "), 1, 2, 3);` | `Key 1, 2, 3` |
66 66
 | `SERIAL_ECHO_START` | None | Prefix an echo line | `SERIAL_ECHO_START();` | `echo:` |
67 67
 | `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` |
68 68
 | `SERIAL_ERROR_START`| None | Prefix an error line | `SERIAL_ERROR_START();` | `Error:` |

Laddar…
Avbryt
Spara