🎨 Apply F() to serial macros

This commit is contained in:
Scott Lahteine 2021-09-27 11:03:07 -05:00
parent 46c53f6730
commit 433eedd50f
30 changed files with 187 additions and 147 deletions

View file

@ -90,15 +90,15 @@ bool PersistentStore::access_finish() {
// to see errors that are happening in read_data / write_data // to see errors that are happening in read_data / write_data
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) { 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) {
#if ENABLED(DEBUG_SD_EEPROM_EMULATION) #if ENABLED(DEBUG_SD_EEPROM_EMULATION)
PGM_P const rw_str = write ? PSTR("write") : PSTR("read"); FSTR_P const rw_str = write ? F("write") : F("read");
SERIAL_CHAR(' '); SERIAL_CHAR(' ');
SERIAL_ECHOPGM_P(rw_str); SERIAL_ECHOF(rw_str);
SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)"); SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)");
if (total) { if (total) {
SERIAL_ECHOPGM(" f_"); SERIAL_ECHOPGM(" f_");
SERIAL_ECHOPGM_P(rw_str); SERIAL_ECHOF(rw_str);
SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_"); SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total); SERIAL_ECHOLNF(write ? F("written=") : F("read="), total);
} }
else else
SERIAL_ECHOLNPGM(" f_lseek()=", s); SERIAL_ECHOLNPGM(" f_lseek()=", s);

View file

@ -36,6 +36,8 @@
#undef DEBUG_ECHOLN #undef DEBUG_ECHOLN
#undef DEBUG_ECHOPGM #undef DEBUG_ECHOPGM
#undef DEBUG_ECHOLNPGM #undef DEBUG_ECHOLNPGM
#undef DEBUG_ECHOF
#undef DEBUG_ECHOLNF
#undef DEBUG_ECHOPGM_P #undef DEBUG_ECHOPGM_P
#undef DEBUG_ECHOLNPGM_P #undef DEBUG_ECHOLNPGM_P
#undef DEBUG_ECHOPAIR_F #undef DEBUG_ECHOPAIR_F
@ -54,7 +56,7 @@
#if DEBUG_OUT #if DEBUG_OUT
#include "debug_section.h" #include "debug_section.h"
#define DEBUG_SECTION(N,S,D) SectionLog N(PSTR(S),D) #define DEBUG_SECTION(N,S,D) SectionLog N(F(S),D)
#define DEBUG_ECHO_START SERIAL_ECHO_START #define DEBUG_ECHO_START SERIAL_ECHO_START
#define DEBUG_ERROR_START SERIAL_ERROR_START #define DEBUG_ERROR_START SERIAL_ERROR_START
@ -65,6 +67,8 @@
#define DEBUG_ECHOLN SERIAL_ECHOLN #define DEBUG_ECHOLN SERIAL_ECHOLN
#define DEBUG_ECHOPGM SERIAL_ECHOPGM #define DEBUG_ECHOPGM SERIAL_ECHOPGM
#define DEBUG_ECHOLNPGM SERIAL_ECHOLNPGM #define DEBUG_ECHOLNPGM SERIAL_ECHOLNPGM
#define DEBUG_ECHOF SERIAL_ECHOF
#define DEBUG_ECHOLNF SERIAL_ECHOLNF
#define DEBUG_ECHOPGM SERIAL_ECHOPGM #define DEBUG_ECHOPGM SERIAL_ECHOPGM
#define DEBUG_ECHOPGM_P SERIAL_ECHOPGM_P #define DEBUG_ECHOPGM_P SERIAL_ECHOPGM_P
#define DEBUG_ECHOPAIR_F SERIAL_ECHOPAIR_F #define DEBUG_ECHOPAIR_F SERIAL_ECHOPAIR_F
@ -94,6 +98,8 @@
#define DEBUG_ECHOLN(...) NOOP #define DEBUG_ECHOLN(...) NOOP
#define DEBUG_ECHOPGM(...) NOOP #define DEBUG_ECHOPGM(...) NOOP
#define DEBUG_ECHOLNPGM(...) NOOP #define DEBUG_ECHOLNPGM(...) NOOP
#define DEBUG_ECHOF(...) NOOP
#define DEBUG_ECHOLNF(...) NOOP
#define DEBUG_ECHOPGM_P(...) NOOP #define DEBUG_ECHOPGM_P(...) NOOP
#define DEBUG_ECHOLNPGM_P(...) NOOP #define DEBUG_ECHOLNPGM_P(...) NOOP
#define DEBUG_ECHOPAIR_F(...) NOOP #define DEBUG_ECHOPAIR_F(...) NOOP

View file

@ -26,22 +26,22 @@
class SectionLog { class SectionLog {
public: public:
SectionLog(PGM_P const msg=nullptr, bool inbug=true) { SectionLog(FSTR_P const fmsg=nullptr, bool inbug=true) {
the_msg = msg; the_msg = fmsg;
if ((debug = inbug)) echo_msg(PSTR(">>>")); if ((debug = inbug)) echo_msg(F(">>>"));
} }
~SectionLog() { if (debug) echo_msg(PSTR("<<<")); } ~SectionLog() { if (debug) echo_msg(F("<<<")); }
private: private:
PGM_P the_msg; FSTR_P the_msg;
bool debug; bool debug;
void echo_msg(PGM_P const pre) { void echo_msg(FSTR_P const fpre) {
SERIAL_ECHOPGM_P(pre); SERIAL_ECHOF(fpre);
if (the_msg) { if (the_msg) {
SERIAL_CHAR(' '); SERIAL_CHAR(' ');
SERIAL_ECHOPGM_P(the_msg); SERIAL_ECHOF(the_msg);
} }
SERIAL_CHAR(' '); SERIAL_CHAR(' ');
print_pos(current_position); print_pos(current_position);

View file

@ -69,23 +69,23 @@ PGMSTR(SP_I_LBL, " " AXIS4_STR ":"); PGMSTR(SP_J_LBL, " " AXIS5_STR ":"); PGMSTR
#endif #endif
void serialprintPGM(PGM_P str) { void serial_print_P(PGM_P str) {
while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c); while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c);
} }
void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serialprintPGM(echomagic); } void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serial_print_P(echomagic); }
void serial_error_start() { static PGMSTR(errormagic, "Error:"); serialprintPGM(errormagic); } void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P(errormagic); }
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); } void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post/*=nullptr*/) { void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) {
if (pre) serialprintPGM(pre); if (pre) serial_print(pre);
serialprintPGM(onoff ? on : off); serial_print(onoff ? on : off);
if (post) serialprintPGM(post); if (post) serial_print(post);
} }
void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(STR_ON) : PSTR(STR_OFF)); } void serialprint_onoff(const bool onoff) { serial_print(onoff ? F(STR_ON) : F(STR_OFF)); }
void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); } void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
void serialprint_truefalse(const bool tf) { serialprintPGM(tf ? PSTR("true") : PSTR("false")); } void serialprint_truefalse(const bool tf) { serial_print(tf ? F("true") : F("false")); }
void print_bin(uint16_t val) { void print_bin(uint16_t val) {
for (uint8_t i = 16; i--;) { for (uint8_t i = 16; i--;) {
@ -94,10 +94,10 @@ void print_bin(uint16_t val) {
} }
} }
void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) { void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) {
if (prefix) serialprintPGM(prefix); if (prefix) serial_print(prefix);
SERIAL_ECHOPGM_P( SERIAL_ECHOPGM_P(
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) 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)
); );
if (suffix) serialprintPGM(suffix); else SERIAL_EOL(); if (suffix) serial_print(suffix); else SERIAL_EOL();
} }

View file

@ -167,13 +167,10 @@ inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); }
#define AS_CHAR(C) serial_char_t(C) #define AS_CHAR(C) serial_char_t(C)
#define AS_DIGIT(C) AS_CHAR('0' + (C)) #define AS_DIGIT(C) AS_CHAR('0' + (C))
// SERIAL_ECHO_F prints a floating point value with optional precision
inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
template <typename T> template <typename T>
void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); } void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); }
// SERIAL_PRINT works like SERIAL_ECHO but allow to specify the encoding base of the number printed // SERIAL_PRINT works like SERIAL_ECHO but also takes the numeric base
template <typename T, typename U> template <typename T, typename U>
void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); } void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); }
@ -184,8 +181,20 @@ void SERIAL_PRINTLN(T x, PrintBase y) { SERIAL_IMPL.println(x, y); }
inline void SERIAL_FLUSH() { SERIAL_IMPL.flush(); } inline void SERIAL_FLUSH() { SERIAL_IMPL.flush(); }
inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); } inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); }
// Print a single PROGMEM string to serial // Serial echo and error prefixes
void serialprintPGM(PGM_P str); #define SERIAL_ECHO_START() serial_echo_start()
#define SERIAL_ERROR_START() serial_error_start()
// Serial end-of-line
#define SERIAL_EOL() SERIAL_CHAR('\n')
// Print a single PROGMEM, PGM_P, or PSTR() string.
void serial_print_P(PGM_P str);
inline void serial_println_P(PGM_P str) { serial_print_P(str); SERIAL_EOL(); }
// Print a single FSTR_P, F(), or FPSTR() string.
inline void serial_print(FSTR_P const fstr) { serial_print_P(FTOP(fstr)); }
inline void serial_println(FSTR_P const fstr) { serial_println_P(FTOP(fstr)); }
// //
// SERIAL_ECHOPGM... macros are used to output string-value pairs. // SERIAL_ECHOPGM... macros are used to output string-value pairs.
@ -195,8 +204,8 @@ void serialprintPGM(PGM_P str);
#define __SEP_N(N,V...) _SEP_##N(V) #define __SEP_N(N,V...) _SEP_##N(V)
#define _SEP_N(N,V...) __SEP_N(N,V) #define _SEP_N(N,V...) __SEP_N(N,V)
#define _SEP_N_REF() _SEP_N #define _SEP_N_REF() _SEP_N
#define _SEP_1(s) serialprintPGM(PSTR(s)); #define _SEP_1(s) serial_print(F(s));
#define _SEP_2(s,v) serial_echopair_PGM(PSTR(s),v); #define _SEP_2(s,v) serial_echopair(F(s),v);
#define _SEP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SEP_N_REF)()(TWO_ARGS(V),V); #define _SEP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SEP_N_REF)()(TWO_ARGS(V),V);
#define SERIAL_ECHOPGM(V...) do{ EVAL(_SEP_N(TWO_ARGS(V),V)); }while(0) #define SERIAL_ECHOPGM(V...) do{ EVAL(_SEP_N(TWO_ARGS(V),V)); }while(0)
@ -204,8 +213,8 @@ void serialprintPGM(PGM_P str);
#define __SELP_N(N,V...) _SELP_##N(V) #define __SELP_N(N,V...) _SELP_##N(V)
#define _SELP_N(N,V...) __SELP_N(N,V) #define _SELP_N(N,V...) __SELP_N(N,V)
#define _SELP_N_REF() _SELP_N #define _SELP_N_REF() _SELP_N
#define _SELP_1(s) serialprintPGM(PSTR(s "\n")); #define _SELP_1(s) serial_print(F(s "\n"));
#define _SELP_2(s,v) serial_echopair_PGM(PSTR(s),v); SERIAL_EOL(); #define _SELP_2(s,v) serial_echolnpair(F(s),v);
#define _SELP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SELP_N_REF)()(TWO_ARGS(V),V); #define _SELP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SELP_N_REF)()(TWO_ARGS(V),V);
#define SERIAL_ECHOLNPGM(V...) do{ EVAL(_SELP_N(TWO_ARGS(V),V)); }while(0) #define SERIAL_ECHOLNPGM(V...) do{ EVAL(_SELP_N(TWO_ARGS(V),V)); }while(0)
@ -213,8 +222,8 @@ void serialprintPGM(PGM_P str);
#define __SEP_N_P(N,V...) _SEP_##N##_P(V) #define __SEP_N_P(N,V...) _SEP_##N##_P(V)
#define _SEP_N_P(N,V...) __SEP_N_P(N,V) #define _SEP_N_P(N,V...) __SEP_N_P(N,V)
#define _SEP_N_P_REF() _SEP_N_P #define _SEP_N_P_REF() _SEP_N_P
#define _SEP_1_P(p) serialprintPGM(p); #define _SEP_1_P(p) serial_print_P(p);
#define _SEP_2_P(p,v) serial_echopair_PGM(p,v); #define _SEP_2_P(p,v) serial_echopair_P(p,v);
#define _SEP_3_P(p,v,V...) _SEP_2_P(p,v); DEFER2(_SEP_N_P_REF)()(TWO_ARGS(V),V); #define _SEP_3_P(p,v,V...) _SEP_2_P(p,v); DEFER2(_SEP_N_P_REF)()(TWO_ARGS(V),V);
#define SERIAL_ECHOPGM_P(V...) do{ EVAL(_SEP_N_P(TWO_ARGS(V),V)); }while(0) #define SERIAL_ECHOPGM_P(V...) do{ EVAL(_SEP_N_P(TWO_ARGS(V),V)); }while(0)
@ -222,11 +231,29 @@ void serialprintPGM(PGM_P str);
#define __SELP_N_P(N,V...) _SELP_##N##_P(V) #define __SELP_N_P(N,V...) _SELP_##N##_P(V)
#define _SELP_N_P(N,V...) __SELP_N_P(N,V) #define _SELP_N_P(N,V...) __SELP_N_P(N,V)
#define _SELP_N_P_REF() _SELP_N_P #define _SELP_N_P_REF() _SELP_N_P
#define _SELP_1_P(p) { serialprintPGM(p); SERIAL_EOL(); } #define _SELP_1_P(p) serial_println_P(p)
#define _SELP_2_P(p,v) { serial_echopair_PGM(p,v); SERIAL_EOL(); } #define _SELP_2_P(p,v) serial_echolnpair_P(p,v)
#define _SELP_3_P(p,v,V...) { _SEP_2_P(p,v); DEFER2(_SELP_N_P_REF)()(TWO_ARGS(V),V); } #define _SELP_3_P(p,v,V...) { _SEP_2_P(p,v); DEFER2(_SELP_N_P_REF)()(TWO_ARGS(V),V); }
#define SERIAL_ECHOLNPGM_P(V...) do{ EVAL(_SELP_N_P(TWO_ARGS(V),V)); }while(0) #define SERIAL_ECHOLNPGM_P(V...) do{ EVAL(_SELP_N_P(TWO_ARGS(V),V)); }while(0)
// Print up to 20 pairs of values. Odd elements must be FSTR_P, F(), or FPSTR().
#define __SEP_N_F(N,V...) _SEP_##N##_F(V)
#define _SEP_N_F(N,V...) __SEP_N_F(N,V)
#define _SEP_N_F_REF() _SEP_N_F
#define _SEP_1_F(p) serial_print(p);
#define _SEP_2_F(p,v) serial_echopair(p,v);
#define _SEP_3_F(p,v,V...) _SEP_2_F(p,v); DEFER2(_SEP_N_F_REF)()(TWO_ARGS(V),V);
#define SERIAL_ECHOF(V...) do{ EVAL(_SEP_N_F(TWO_ARGS(V),V)); }while(0)
// Print up to 20 pairs of values followed by newline. Odd elements must be FSTR_P, F(), or FPSTR().
#define __SELP_N_F(N,V...) _SELP_##N##_F(V)
#define _SELP_N_F(N,V...) __SELP_N_F(N,V)
#define _SELP_N_F_REF() _SELP_N_F
#define _SELP_1_F(p) serial_println(p)
#define _SELP_2_F(p,v) serial_echolnpair(p,v)
#define _SELP_3_F(p,v,V...) { _SEP_2_F(p,v); DEFER2(_SELP_N_F_REF)()(TWO_ARGS(V),V); }
#define SERIAL_ECHOLNF(V...) do{ EVAL(_SELP_N_F(TWO_ARGS(V),V)); }while(0)
#ifdef AllowDifferentTypeInList #ifdef AllowDifferentTypeInList
inline void SERIAL_ECHOLIST_IMPL() {} inline void SERIAL_ECHOLIST_IMPL() {}
@ -236,47 +263,49 @@ void serialprintPGM(PGM_P str);
template <typename T, typename ... Args> template <typename T, typename ... Args>
void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) { void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) {
SERIAL_IMPL.print(t); SERIAL_IMPL.print(t);
serialprintPGM(PSTR(", ")); serial_print(F(", "));
SERIAL_ECHOLIST_IMPL(args...); SERIAL_ECHOLIST_IMPL(args...);
} }
template <typename ... Args> template <typename ... Args>
void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) { void SERIAL_ECHOLIST(FSTR_P const str, Args && ... args) {
SERIAL_IMPL.print(str); SERIAL_IMPL.print(FTOP(str));
SERIAL_ECHOLIST_IMPL(args...); SERIAL_ECHOLIST_IMPL(args...);
} }
#else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead) #else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead)
template <typename ... Args> template <typename ... Args>
void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) { void SERIAL_ECHOLIST(FSTR_P const fstr, Args && ... args) {
serialprintPGM(str); serial_print(fstr);
typename Private::first_type_of<Args...>::type values[] = { args... }; typename Private::first_type_of<Args...>::type values[] = { args... };
constexpr size_t argsSize = sizeof...(args); constexpr size_t argsSize = sizeof...(args);
for (size_t i = 0; i < argsSize; i++) { for (size_t i = 0; i < argsSize; i++) {
if (i) serialprintPGM(PSTR(", ")); if (i) serial_print(F(", "));
SERIAL_IMPL.print(values[i]); SERIAL_IMPL.print(values[i]);
} }
} }
#endif #endif
#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serialprintPGM(P); SERIAL_ECHO_F(V); }while(0) // SERIAL_ECHO_F prints a floating point value with optional precision
#define SERIAL_ECHOLNPAIR_F_P(V...) do{ SERIAL_ECHOPAIR_F_P(V); SERIAL_EOL(); }while(0) inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
#define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_P(PSTR(S),V) #define SERIAL_ECHOPAIR_F_P(P,V...) do{ serial_print_P(P); SERIAL_ECHO_F(V); }while(0)
#define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0) #define SERIAL_ECHOLNPAIR_F_P(P,V...) do{ SERIAL_ECHOPAIR_F_P(P,V); SERIAL_EOL(); }while(0)
#define SERIAL_ECHO_START() serial_echo_start() #define SERIAL_ECHOPAIR_F_F(S,V...) do{ serial_print(S); SERIAL_ECHO_F(V); }while(0)
#define SERIAL_ERROR_START() serial_error_start() #define SERIAL_ECHOLNPAIR_F_F(S,V...) do{ SERIAL_ECHOPAIR_F_F(S,V); SERIAL_EOL(); }while(0)
#define SERIAL_EOL() SERIAL_CHAR('\n')
#define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0) #define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_F(F(S),V)
#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0) #define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0)
#define SERIAL_ECHO_SP(C) serial_spaces(C) #define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0)
#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0)
#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, PSTR(PRE), PSTR(ON), PSTR(OFF), PSTR(POST)) #define SERIAL_ECHO_SP(C) serial_spaces(C)
#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, F(PRE), F(ON), F(OFF), F(POST))
#if SERIAL_FLOAT_PRECISION #if SERIAL_FLOAT_PRECISION
#define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION) #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION)
@ -287,33 +316,42 @@ void serialprintPGM(PGM_P str);
// //
// Functions for serial printing from PROGMEM. (Saves loads of SRAM.) // Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
// //
inline void serial_echopair_PGM(PGM_P const s_P, serial_char_t v) { serialprintPGM(s_P); SERIAL_CHAR(v.c); } inline void serial_echopair_P(PGM_P const pstr, serial_char_t v) { serial_print_P(pstr); SERIAL_CHAR(v.c); }
inline void serial_echopair_P(PGM_P const pstr, float v) { serial_print_P(pstr); SERIAL_DECIMAL(v); }
inline void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } inline void serial_echopair_P(PGM_P const pstr, double v) { serial_print_P(pstr); SERIAL_DECIMAL(v); }
inline void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } //inline void serial_echopair_P(PGM_P const pstr, const char *v) { serial_print_P(pstr); SERIAL_ECHO(v); }
inline void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); } inline void serial_echopair_P(PGM_P const pstr, FSTR_P v) { serial_print_P(pstr); SERIAL_ECHOF(v); }
// Default implementation for types without a specialization. Handles integers. // Default implementation for types without a specialization. Handles integers.
template <typename T> template <typename T>
void serial_echopair_PGM(PGM_P const s_P, T v) { serialprintPGM(s_P); SERIAL_ECHO(v); } inline void serial_echopair_P(PGM_P const pstr, T v) { serial_print_P(pstr); SERIAL_ECHO(v); }
inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); } // Add a newline.
inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (uintptr_t)v); } template <typename T>
inline void serial_echolnpair_P(PGM_P const pstr, T v) { serial_echopair_P(pstr, v); SERIAL_EOL(); }
// Catch-all for __FlashStringHelper *
template <typename T>
inline void serial_echopair(FSTR_P const fstr, T v) { serial_echopair_P(FTOP(fstr), v); }
// Add a newline to the serial output
template <typename T>
inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP(fstr), v); }
void serial_echo_start(); void serial_echo_start();
void serial_error_start(); void serial_error_start();
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post=nullptr); void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr);
void serialprint_onoff(const bool onoff); void serialprint_onoff(const bool onoff);
void serialprintln_onoff(const bool onoff); void serialprintln_onoff(const bool onoff);
void serialprint_truefalse(const bool tf); void serialprint_truefalse(const bool tf);
void serial_spaces(uint8_t count); void serial_spaces(uint8_t count);
void print_bin(const uint16_t val); void print_bin(const uint16_t val);
void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix=nullptr, PGM_P const suffix=nullptr); void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr);
inline void print_pos(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) { inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) {
print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix); print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix);
} }
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0) #define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0)
#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, PSTR(PREFIX), nullptr); }while(0) #define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, F(PREFIX)); }while(0)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -561,7 +561,7 @@
}; };
template<class TMC> template<class TMC>
static void print_vsense(TMC &st) { SERIAL_ECHOPGM_P(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); } static void print_vsense(TMC &st) { SERIAL_ECHOF(st.vsense() ? F("1=.18") : F("0=.325")); }
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130) #if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130)
static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) { static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
@ -732,7 +732,7 @@
SERIAL_ECHO(st.cs()); SERIAL_ECHO(st.cs());
SERIAL_ECHOPGM("/31"); SERIAL_ECHOPGM("/31");
break; break;
case TMC_VSENSE: SERIAL_ECHOPGM_P(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break; case TMC_VSENSE: SERIAL_ECHOF(st.vsense() ? F("1=.165") : F("0=.310")); break;
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break; case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
//case TMC_OTPW: serialprint_truefalse(st.otpw()); break; //case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
//case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break; //case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
@ -1256,15 +1256,14 @@ static bool test_connection(TMC &st) {
if (test_result > 0) SERIAL_ECHOPGM("Error: All "); if (test_result > 0) SERIAL_ECHOPGM("Error: All ");
const char *stat; FSTR_P stat;
switch (test_result) { switch (test_result) {
default: default:
case 0: stat = PSTR("OK"); break; case 0: stat = F("OK"); break;
case 1: stat = PSTR("HIGH"); break; case 1: stat = F("HIGH"); break;
case 2: stat = PSTR("LOW"); break; case 2: stat = F("LOW"); break;
} }
SERIAL_ECHOPGM_P(stat); SERIAL_ECHOLNF(stat);
SERIAL_EOL();
return test_result; return test_result;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -47,10 +47,10 @@ inline void L6470_say_status(const L64XX_axis_t axis) {
} }
#endif #endif
SERIAL_ECHOPGM("\n...OUTPUT: "); SERIAL_ECHOPGM("\n...OUTPUT: ");
SERIAL_ECHOPGM_P(sh.STATUS_AXIS & STATUS_HIZ ? PSTR("OFF") : PSTR("ON ")); SERIAL_ECHOF(sh.STATUS_AXIS & STATUS_HIZ ? F("OFF") : F("ON "));
SERIAL_ECHOPGM(" BUSY: "); echo_yes_no((sh.STATUS_AXIS & STATUS_BUSY) == 0); SERIAL_ECHOPGM(" BUSY: "); echo_yes_no((sh.STATUS_AXIS & STATUS_BUSY) == 0);
SERIAL_ECHOPGM(" DIR: "); SERIAL_ECHOPGM(" DIR: ");
SERIAL_ECHOPGM_P((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? PSTR("FORWARD") : PSTR("REVERSE")); SERIAL_ECHOF((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? F("FORWARD") : F("REVERSE"));
if (sh.STATUS_AXIS_LAYOUT == L6480_STATUS_LAYOUT) { if (sh.STATUS_AXIS_LAYOUT == L6480_STATUS_LAYOUT) {
SERIAL_ECHOPGM(" Last Command: "); SERIAL_ECHOPGM(" Last Command: ");
if (sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD) SERIAL_ECHOPGM("VALID"); 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) {
SERIAL_ECHOPGM(" Last Command: "); SERIAL_ECHOPGM(" Last Command: ");
if (!(sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD)) SERIAL_ECHOPGM("IN"); if (!(sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD)) SERIAL_ECHOPGM("IN");
SERIAL_ECHOPGM("VALID "); SERIAL_ECHOPGM("VALID ");
SERIAL_ECHOPGM_P(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ? PSTR("COMPLETED ") : PSTR("Not PERFORMED")); SERIAL_ECHOF(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ? F("COMPLETED ") : F("Not PERFORMED"));
SERIAL_ECHOPGM("\n...THERMAL: ", !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_SD) ? "SHUTDOWN " : !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_WRN) ? "WARNING " : "OK "); SERIAL_ECHOPGM("\n...THERMAL: ", !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_SD) ? "SHUTDOWN " : !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_WRN) ? "WARNING " : "OK ");
} }
SERIAL_ECHOPGM(" OVERCURRENT:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_OCD) == 0); SERIAL_ECHOPGM(" OVERCURRENT:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_OCD) == 0);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -306,7 +306,7 @@ void ChironTFT::PowerLossRecovery() {
printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover. printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover.
last_error = AC_error_powerloss; last_error = AC_error_powerloss;
PlayTune(BEEPER_PIN, SOS, 1); PlayTune(BEEPER_PIN, SOS, 1);
SERIAL_ECHOLNPGM_P(AC_msg_powerloss_recovery); SERIAL_ECHOLNF(AC_msg_powerloss_recovery);
} }
void ChironTFT::PrintComplete() { void ChironTFT::PrintComplete() {
@ -488,7 +488,7 @@ void ChironTFT::ProcessPanelRequest() {
if (tpos != -1) { if (tpos != -1) {
if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') { if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') {
panel_type = AC_panel_standard; panel_type = AC_panel_standard;
SERIAL_ECHOLNPGM_P(AC_msg_old_panel_detected); SERIAL_ECHOLNF(AC_msg_old_panel_detected);
} }
} }
else { else {
@ -496,7 +496,7 @@ void ChironTFT::ProcessPanelRequest() {
if (tpos != -1) { if (tpos != -1) {
if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') { if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') {
panel_type = AC_panel_new; panel_type = AC_panel_new;
SERIAL_ECHOLNPGM_P(AC_msg_new_panel_detected); SERIAL_ECHOLNF(AC_msg_new_panel_detected);
} }
} }
} }
@ -825,7 +825,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
if (!isPrinting()) { if (!isPrinting()) {
injectCommands_P(PSTR("M501\nM420 S1")); injectCommands_P(PSTR("M501\nM420 S1"));
selectedmeshpoint.x = selectedmeshpoint.y = 99; selectedmeshpoint.x = selectedmeshpoint.y = 99;
SERIAL_ECHOLNPGM_P(AC_msg_mesh_changes_abandoned); SERIAL_ECHOLNF(AC_msg_mesh_changes_abandoned);
} }
} }
@ -833,7 +833,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
if (!isPrinting()) { if (!isPrinting()) {
setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made
injectCommands_P(PSTR("M500")); injectCommands_P(PSTR("M500"));
SERIAL_ECHOLNPGM_P(AC_msg_mesh_changes_saved); SERIAL_ECHOLNF(AC_msg_mesh_changes_saved);
selectedmeshpoint.x = selectedmeshpoint.y = 99; selectedmeshpoint.x = selectedmeshpoint.y = 99;
} }
} }

View file

@ -755,10 +755,10 @@ volatile bool Temperature::raw_temps_ready = false;
SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED); SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED);
#if EITHER(PIDTEMPBED, PIDTEMPCHAMBER) #if EITHER(PIDTEMPBED, PIDTEMPCHAMBER)
PGM_P const estring = GHV(PSTR("chamber"), PSTR("bed"), NUL_STR); FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR));
say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp);
say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki);
say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd); say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd);
#else #else
say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp);
say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki);
@ -1737,21 +1737,21 @@ void Temperature::manage_heater() {
SERIAL_ECHOPAIR_F_P(SP_B_STR, t.beta, 1); SERIAL_ECHOPAIR_F_P(SP_B_STR, t.beta, 1);
SERIAL_ECHOPAIR_F_P(SP_C_STR, t.sh_c_coeff, 9); SERIAL_ECHOPAIR_F_P(SP_C_STR, t.sh_c_coeff, 9);
SERIAL_ECHOPGM(" ; "); SERIAL_ECHOPGM(" ; ");
SERIAL_ECHOPGM_P( SERIAL_ECHOF(
TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :) TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? F("HOTEND 0") :)
TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :) TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? F("HOTEND 1") :)
TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :) TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? F("HOTEND 2") :)
TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :) TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? F("HOTEND 3") :)
TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :) TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? F("HOTEND 4") :)
TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :) TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? F("HOTEND 5") :)
TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :) TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? F("HOTEND 6") :)
TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :) TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? F("HOTEND 7") :)
TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? PSTR("BED") :) TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? F("BED") :)
TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :) TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? F("CHAMBER") :)
TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? PSTR("COOLER") :) TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? F("COOLER") :)
TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :) TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? F("PROBE") :)
TERN_(TEMP_SENSOR_BOARD_IS_CUSTOM, t_index == CTI_BOARD ? PSTR("BOARD") :) TERN_(TEMP_SENSOR_BOARD_IS_CUSTOM, t_index == CTI_BOARD ? F("BOARD") :)
TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? PSTR("REDUNDANT") :) TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? F("REDUNDANT") :)
nullptr nullptr
); );
SERIAL_EOL(); SERIAL_EOL();

View file

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

View file

@ -62,7 +62,7 @@ The following macros are defined (in `serial.h`) to output data to the serial po
| `SERIAL_ECHOLNPGM` | Same as `SERIAL_ECHOPGM` | Do `SERIAL_ECHOPGM`, adding a newline | `SERIAL_ECHOPGM("Alice", 56);` | `alice56` | | `SERIAL_ECHOLNPGM` | Same as `SERIAL_ECHOPGM` | Do `SERIAL_ECHOPGM`, adding a newline | `SERIAL_ECHOPGM("Alice", 56);` | `alice56` |
| `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` | | `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` |
| `SERIAL_ECHOLNPGM_P` | Same as `SERIAL_ECHOPGM_P` | Do `SERIAL_ECHOPGM_P`, adding a newline | `SERIAL_ECHOLNPGM_P(PSTR("Alice"), 78);` | `alice78\n` | | `SERIAL_ECHOLNPGM_P` | Same as `SERIAL_ECHOPGM_P` | Do `SERIAL_ECHOPGM_P`, adding a newline | `SERIAL_ECHOLNPGM_P(PSTR("Alice"), 78);` | `alice78\n` |
| `SERIAL_ECHOLIST` | String literal, values | Print a string literal and a list of values | `SERIAL_ECHOLIST("Key ", 1, 2, 3);` | `Key 1, 2, 3` | | `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` |
| `SERIAL_ECHO_START` | None | Prefix an echo line | `SERIAL_ECHO_START();` | `echo:` | | `SERIAL_ECHO_START` | None | Prefix an echo line | `SERIAL_ECHO_START();` | `echo:` |
| `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` | | `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` |
| `SERIAL_ERROR_START`| None | Prefix an error line | `SERIAL_ERROR_START();` | `Error:` | | `SERIAL_ERROR_START`| None | Prefix an error line | `SERIAL_ERROR_START();` | `Error:` |