Skip to content

Commit 167672d

Browse files
committed
πŸ§‘β€πŸ’» Forward-compatible axis strings
1 parent a93146b commit 167672d

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

β€ŽMarlin/src/core/serial.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@
3030
uint8_t marlin_debug_flags = MARLIN_DEBUG_NONE;
3131

3232
// Commonly-used strings in serial output
33-
PGMSTR(NUL_STR, ""); PGMSTR(SP_P_STR, " P"); PGMSTR(SP_T_STR, " T");
34-
PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C");
35-
LOGICAL_AXIS_CODE(PGMSTR(SP_E_STR, " E"), PGMSTR(SP_X_STR, " X"), PGMSTR(SP_Y_STR, " Y"), PGMSTR(SP_Z_STR, " Z"), PGMSTR(SP_I_STR, " " STR_I), PGMSTR(SP_J_STR, " " STR_J), PGMSTR(SP_K_STR, " " STR_K), PGMSTR(SP_U_STR, " " STR_U), PGMSTR(SP_V_STR, " " STR_V), PGMSTR(SP_W_STR, " " STR_W));
36-
LOGICAL_AXIS_CODE(PGMSTR(SP_E_LBL, " E:"), PGMSTR(SP_X_LBL, " X:"), PGMSTR(SP_Y_LBL, " Y:"), PGMSTR(SP_Z_LBL, " Z:"), PGMSTR(SP_I_LBL, " " STR_I ":"), PGMSTR(SP_J_LBL, " " STR_J ":"), PGMSTR(SP_K_LBL, " " STR_K ":"), PGMSTR(SP_U_LBL, " " STR_U ":"), PGMSTR(SP_V_LBL, " " STR_V ":"), PGMSTR(SP_W_LBL, " " STR_W ":"));
37-
LOGICAL_AXIS_CODE(PGMSTR(E_STR, "E"), PGMSTR(X_STR, "X"), PGMSTR(Y_STR, "Y"), PGMSTR(Z_STR, "Z"), PGMSTR(I_STR, STR_I), PGMSTR(J_STR, STR_J), PGMSTR(K_STR, STR_K), PGMSTR(U_STR, STR_U), PGMSTR(V_STR, STR_V), PGMSTR(W_STR, STR_W));
38-
LOGICAL_AXIS_CODE(PGMSTR(E_LBL, "E:"), PGMSTR(X_LBL, "X:"), PGMSTR(Y_LBL, "Y:"), PGMSTR(Z_LBL, "Z:"), PGMSTR(I_LBL, STR_I ":"), PGMSTR(J_LBL, STR_J ":"), PGMSTR(K_LBL, STR_K ":"), PGMSTR(U_LBL, STR_U ":"), PGMSTR(V_LBL, STR_V ":"), PGMSTR(W_LBL, STR_W ":"));
33+
PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C");
34+
PGMSTR(SP_P_STR, " P"); PGMSTR(SP_T_STR, " T"); PGMSTR(NUL_STR, "");
35+
36+
#define _N_STR(N) PGMSTR(N##_STR, STR_##N);
37+
#define _N_LBL(N) PGMSTR(N##_LBL, STR_##N ":");
38+
#define _SP_N_STR(N) PGMSTR(SP_##N##_STR, STR_##N ":");
39+
#define _SP_N_LBL(N) PGMSTR(SP_##N##_LBL, " " STR_##N ":");
40+
MAP(_N_STR, LOGICAL_AXIS_NAMES); MAP(_SP_N_STR, LOGICAL_AXIS_NAMES);
41+
MAP(_N_LBL, LOGICAL_AXIS_NAMES); MAP(_SP_N_LBL, LOGICAL_AXIS_NAMES);
3942

4043
// Hook Meatpack if it's enabled on the first leaf
4144
#if ENABLED(MEATPACK_ON_SERIAL_PORT_1)

β€ŽMarlin/src/core/serial.h

+29-11
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@
2828
#include "../feature/meatpack.h"
2929
#endif
3030

31-
// Commonly-used strings in serial output
32-
extern const char NUL_STR[], SP_P_STR[], SP_T_STR[],
33-
SP_A_STR[], SP_B_STR[], SP_C_STR[],
34-
LOGICAL_AXIS_LIST(SP_E_STR[], SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_I_STR[], SP_J_STR[], SP_K_STR[], SP_U_STR[], SP_V_STR[], SP_W_STR[]),
35-
LOGICAL_AXIS_LIST(SP_E_LBL[], SP_X_LBL[], SP_Y_LBL[], SP_Z_LBL[], SP_I_LBL[], SP_J_LBL[], SP_K_LBL[], SP_U_LBL[], SP_V_LBL[], SP_W_LBL[]),
36-
LOGICAL_AXIS_LIST(E_STR[], X_STR[], Y_STR[], Z_STR[], I_STR[], J_STR[], K_STR[], U_STR[], V_STR[], W_STR[]),
37-
LOGICAL_AXIS_LIST(E_LBL[], X_LBL[], Y_LBL[], Z_LBL[], I_LBL[], J_LBL[], K_LBL[], U_LBL[], V_LBL[], W_LBL[]);
38-
39-
PGM_P const SP_AXIS_LBL[] PROGMEM = LOGICAL_AXIS_ARRAY(SP_E_LBL, SP_X_LBL, SP_Y_LBL, SP_Z_LBL, SP_I_LBL, SP_J_LBL, SP_K_LBL, SP_U_LBL, SP_V_LBL, SP_W_LBL);
40-
PGM_P const SP_AXIS_STR[] PROGMEM = LOGICAL_AXIS_ARRAY(SP_E_STR, SP_X_STR, SP_Y_STR, SP_Z_STR, SP_I_STR, SP_J_STR, SP_K_STR, SP_U_STR, SP_V_STR, SP_W_STR);
41-
4231
//
4332
// Debugging flags for use by M111
4433
//
@@ -354,3 +343,32 @@ inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P
354343

355344
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0)
356345
#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, F(PREFIX)); }while(0)
346+
347+
//
348+
// Commonly-used strings in serial output
349+
//
350+
351+
#define _N_STR(N) N##_STR
352+
#define _N_LBL(N) N##_LBL
353+
#define _N_STR_A(N) _N_STR(N)[]
354+
#define _N_LBL_A(N) _N_LBL(N)[]
355+
#define _SP_N_STR(N) SP_##N##_STR
356+
#define _SP_N_LBL(N) SP_##N##_LBL
357+
#define _SP_N_STR_A(N) _SP_N_STR(N)[]
358+
#define _SP_N_LBL_A(N) _SP_N_LBL(N)[]
359+
360+
extern const char SP_A_STR[], SP_B_STR[], SP_C_STR[], SP_P_STR[], SP_T_STR[], NUL_STR[],
361+
MAPLIST(_N_STR_A, LOGICAL_AXIS_NAMES), MAPLIST(_SP_N_STR_A, LOGICAL_AXIS_NAMES),
362+
MAPLIST(_N_LBL_A, LOGICAL_AXIS_NAMES), MAPLIST(_SP_N_LBL_A, LOGICAL_AXIS_NAMES);
363+
364+
PGM_P const SP_AXIS_LBL[] PROGMEM = { MAPLIST(_SP_N_LBL, LOGICAL_AXIS_NAMES) };
365+
PGM_P const SP_AXIS_STR[] PROGMEM = { MAPLIST(_SP_N_STR, LOGICAL_AXIS_NAMES) };
366+
367+
#undef _N_STR
368+
#undef _N_LBL
369+
#undef _N_STR_A
370+
#undef _N_LBL_A
371+
#undef _SP_N_STR
372+
#undef _SP_N_LBL
373+
#undef _SP_N_STR_A
374+
#undef _SP_N_LBL_A

0 commit comments

Comments
Β (0)