Fix axis char printing

This commit is contained in:
Scott Lahteine 2021-04-07 15:43:07 -05:00
parent facbbba789
commit 1879eede0d
14 changed files with 43 additions and 42 deletions

View File

@ -144,6 +144,7 @@ void SERIAL_ECHO(T x) { SERIAL_IMPL.print(x); }
typedef struct SerialChar { char c; SerialChar(char n) : c(n) { } } serial_char_t; typedef struct SerialChar { char c; SerialChar(char n) : c(n) { } } serial_char_t;
inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); } 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))
// SERIAL_ECHO_F prints a floating point value with optional precision // 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); } inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }

View File

@ -111,14 +111,14 @@ void FWRetract::retract(const bool retracting
/* // debugging /* // debugging
SERIAL_ECHOLNPAIR( SERIAL_ECHOLNPAIR(
"retracting ", retracting, "retracting ", AS_DIGIT(retracting),
" swapping ", swapping, " swapping ", swapping,
" active extruder ", active_extruder " active extruder ", active_extruder
); );
LOOP_L_N(i, EXTRUDERS) { LOOP_L_N(i, EXTRUDERS) {
SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); SERIAL_ECHOLNPAIR("retracted[", i, "] ", AS_DIGIT(retracted[i]));
#if HAS_MULTI_EXTRUDER #if HAS_MULTI_EXTRUDER
SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i]));
#endif #endif
} }
SERIAL_ECHOLNPAIR("current_position.z ", current_position.z); SERIAL_ECHOLNPAIR("current_position.z ", current_position.z);
@ -185,13 +185,13 @@ void FWRetract::retract(const bool retracting
#endif #endif
/* // debugging /* // debugging
SERIAL_ECHOLNPAIR("retracting ", retracting); SERIAL_ECHOLNPAIR("retracting ", AS_DIGIT(retracting));
SERIAL_ECHOLNPAIR("swapping ", swapping); SERIAL_ECHOLNPAIR("swapping ", AS_DIGIT(swapping));
SERIAL_ECHOLNPAIR("active_extruder ", active_extruder); SERIAL_ECHOLNPAIR("active_extruder ", active_extruder);
LOOP_L_N(i, EXTRUDERS) { LOOP_L_N(i, EXTRUDERS) {
SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); SERIAL_ECHOLNPAIR("retracted[", i, "] ", AS_DIGIT(retracted[i]));
#if HAS_MULTI_EXTRUDER #if HAS_MULTI_EXTRUDER
SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i]));
#endif #endif
} }
SERIAL_ECHOLNPAIR("current_position.z ", current_position.z); SERIAL_ECHOLNPAIR("current_position.z ", current_position.z);
@ -268,7 +268,7 @@ void FWRetract::M208_report(const bool forReplay/*=false*/) {
void FWRetract::M209_report(const bool forReplay/*=false*/) { void FWRetract::M209_report(const bool forReplay/*=false*/) {
if (!forReplay) { SERIAL_ECHO_MSG("; Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); SERIAL_ECHO_START(); } if (!forReplay) { SERIAL_ECHO_MSG("; Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); SERIAL_ECHO_START(); }
SERIAL_ECHOLNPAIR(" M209 S", autoretract_enabled); SERIAL_ECHOLNPAIR(" M209 S", AS_DIGIT(autoretract_enabled));
} }
#endif // FWRETRACT_AUTORETRACT #endif // FWRETRACT_AUTORETRACT

View File

@ -612,7 +612,7 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOLNPAIR("sd_filename: ", info.sd_filename); DEBUG_ECHOLNPAIR("sd_filename: ", info.sd_filename);
DEBUG_ECHOLNPAIR("sdpos: ", info.sdpos); DEBUG_ECHOLNPAIR("sdpos: ", info.sdpos);
DEBUG_ECHOLNPAIR("print_job_elapsed: ", info.print_job_elapsed); DEBUG_ECHOLNPAIR("print_job_elapsed: ", info.print_job_elapsed);
DEBUG_ECHOLNPAIR("dryrun: ", info.flag.dryrun); DEBUG_ECHOLNPAIR("dryrun: ", AS_DIGIT(info.flag.dryrun));
DEBUG_ECHOLNPAIR("allow_cold_extrusion: ", info.flag.allow_cold_extrusion); DEBUG_ECHOLNPAIR("allow_cold_extrusion: ", info.flag.allow_cold_extrusion);
} }
else else

View File

@ -43,7 +43,7 @@
if (parser.seen(XYZ_CHAR(i))) { if (parser.seen(XYZ_CHAR(i))) {
const float v = parser.value_linear_units(); const float v = parser.value_linear_units();
if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v; if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", XYZ_CHAR(i), "] = ", delta_endstop_adj[i]); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(XYZ_CHAR(i)), "] = ", delta_endstop_adj[i]);
} }
} }
} }

View File

@ -141,7 +141,7 @@
HOTEND_LOOP() { HOTEND_LOOP() {
DEBUG_ECHOPAIR_P(SP_T_STR, e); DEBUG_ECHOPAIR_P(SP_T_STR, e);
LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", e, "].", XYZ_CHAR(a) | 0x20, "=", hotend_offset[e][a]); LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", e, "].", AS_CHAR(XYZ_CHAR(a) | 0x20), "=", hotend_offset[e][a]);
DEBUG_EOL(); DEBUG_EOL();
} }
DEBUG_EOL(); DEBUG_EOL();

View File

@ -307,7 +307,7 @@ void GCodeParser::parse(char *p) {
#if ENABLED(DEBUG_GCODE_PARSER) #if ENABLED(DEBUG_GCODE_PARSER)
if (debug) { if (debug) {
SERIAL_ECHOPAIR("Got param ", param, " at index ", p - command_ptr - 1); SERIAL_ECHOPAIR("Got param ", AS_CHAR(param), " at index ", p - command_ptr - 1);
if (has_val) SERIAL_ECHOPGM(" (has_val)"); if (has_val) SERIAL_ECHOPGM(" (has_val)");
} }
#endif #endif

View File

@ -639,7 +639,7 @@ namespace Anycubic {
float newposition = atof(&panel_command[6]); float newposition = atof(&panel_command[6]);
#if ACDEBUG(AC_ACTION) #if ACDEBUG(AC_ACTION)
SERIAL_ECHOLNPAIR("Nudge ", panel_command[4], " axis ", newposition); SERIAL_ECHOLNPAIR("Nudge ", AS_CHAR(panel_command[4]), " axis ", newposition);
#endif #endif
switch (panel_command[4]) { switch (panel_command[4]) {

View File

@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
if (!movevalue) { if (!movevalue) {
// homing // homing
DEBUG_ECHOPAIR(" homing ", axiscode); DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode));
char buf[6] = "G28 X"; char buf[6] = "G28 X";
buf[4] = axiscode; buf[4] = axiscode;
//DEBUG_ECHOPAIR(" ", buf); //DEBUG_ECHOPAIR(" ", buf);
@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
} }
else { else {
// movement // movement
DEBUG_ECHOPAIR(" move ", axiscode); DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode));
bool old_relative_mode = relative_mode; bool old_relative_mode = relative_mode;
if (!relative_mode) { if (!relative_mode) {
//DEBUG_ECHOPGM(" G91"); //DEBUG_ECHOPGM(" G91");
@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
return; return;
cannotmove: cannotmove:
DEBUG_ECHOLNPAIR(" cannot move ", axiscode); DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode));
return; return;
} }

View File

@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
if (!movevalue) { if (!movevalue) {
// homing // homing
DEBUG_ECHOPAIR(" homing ", axiscode); DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode));
char buf[6] = "G28 X"; char buf[6] = "G28 X";
buf[4] = axiscode; buf[4] = axiscode;
//DEBUG_ECHOPAIR(" ", buf); //DEBUG_ECHOPAIR(" ", buf);
@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
} }
else { else {
// movement // movement
DEBUG_ECHOPAIR(" move ", axiscode); DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode));
bool old_relative_mode = relative_mode; bool old_relative_mode = relative_mode;
if (!relative_mode) { if (!relative_mode) {
//DEBUG_ECHOPGM(" G91"); //DEBUG_ECHOPGM(" G91");
@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
return; return;
cannotmove: cannotmove:
DEBUG_ECHOLNPAIR(" cannot move ", axiscode); DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode));
return; return;
} }

View File

@ -835,7 +835,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
if (!movevalue) { if (!movevalue) {
// homing // homing
DEBUG_ECHOPAIR(" homing ", axiscode); DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode));
// char buf[6] = "G28 X"; // char buf[6] = "G28 X";
// buf[4] = axiscode; // buf[4] = axiscode;
@ -850,14 +850,14 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
else if (movevalue == 5) { else if (movevalue == 5) {
DEBUG_ECHOPAIR("send M84"); DEBUG_ECHOPAIR("send M84");
char buf[6]; char buf[6];
snprintf_P(buf,6,PSTR("M84 %c"),axiscode); snprintf_P(buf,6,PSTR("M84 %c"), axiscode);
queue.enqueue_one_now(buf); queue.enqueue_one_now(buf);
ForceCompleteUpdate(); ForceCompleteUpdate();
return; return;
} }
else { else {
// movement // movement
DEBUG_ECHOPAIR(" move ", axiscode); DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode));
bool old_relative_mode = relative_mode; bool old_relative_mode = relative_mode;
if (!relative_mode) { if (!relative_mode) {
@ -895,7 +895,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
return; return;
cannotmove: cannotmove:
DEBUG_ECHOLNPAIR(" cannot move ", axiscode); DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode));
return; return;
} }

View File

@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
if (!movevalue) { if (!movevalue) {
// homing // homing
DEBUG_ECHOPAIR(" homing ", axiscode); DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode));
char buf[6] = "G28 X"; char buf[6] = "G28 X";
buf[4] = axiscode; buf[4] = axiscode;
//DEBUG_ECHOPAIR(" ", buf); //DEBUG_ECHOPAIR(" ", buf);
@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
} }
else { else {
// movement // movement
DEBUG_ECHOPAIR(" move ", axiscode); DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode));
bool old_relative_mode = relative_mode; bool old_relative_mode = relative_mode;
if (!relative_mode) { if (!relative_mode) {
//DEBUG_ECHOPGM(" G91"); //DEBUG_ECHOPGM(" G91");
@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
return; return;
cannotmove: cannotmove:
DEBUG_ECHOLNPAIR(" cannot move ", axiscode); DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode));
return; return;
} }

View File

@ -144,10 +144,10 @@ bool NextionTFT::ReadTFTCommand() {
#if NEXDEBUG(N_SOME) #if NEXDEBUG(N_SOME)
uint8_t req = atoi(&nextion_command[1]); uint8_t req = atoi(&nextion_command[1]);
if (req > 7 && req != 20) if (req > 7 && req != 20)
DEBUG_ECHOLNPAIR( "> ", nextion_command[0], DEBUG_ECHOLNPAIR( "> ", AS_CHAR(nextion_command[0]),
"\n> ", nextion_command[1], "\n> ", AS_CHAR(nextion_command[1]),
"\n> ", nextion_command[2], "\n> ", AS_CHAR(nextion_command[2]),
"\n> ", nextion_command[3], "\n> ", AS_CHAR(nextion_command[3]),
"\nprinter_state:", printer_state); "\nprinter_state:", printer_state);
#endif #endif
} }

View File

@ -761,7 +761,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
// For Cartesian / Core motion simply move to the current_position // For Cartesian / Core motion simply move to the current_position
planner.buffer_line(current_position, fr_mm_s, axis == E_AXIS ? e_index : active_extruder); planner.buffer_line(current_position, fr_mm_s, axis == E_AXIS ? e_index : active_extruder);
//SERIAL_ECHOLNPAIR("Add planner.move with Axis ", axis, " at FR ", fr_mm_s); //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s);
axis = NO_AXIS; axis = NO_AXIS;
@ -782,7 +782,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
#endif #endif
start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
axis = move_axis; axis = move_axis;
//SERIAL_ECHOLNPAIR("Post Move with Axis ", axis, " soon."); //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon.");
} }
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)

View File

@ -622,7 +622,7 @@ void restore_feedrate_and_scaling() {
#endif #endif
if (DEBUGGING(LEVELING)) if (DEBUGGING(LEVELING))
SERIAL_ECHOLNPAIR("Axis ", XYZ_CHAR(axis), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]); SERIAL_ECHOLNPAIR("Axis ", AS_CHAR(XYZ_CHAR(axis)), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]);
} }
/** /**
@ -1392,12 +1392,12 @@ void prepare_line_to_destination() {
* "trusted" position). * "trusted" position).
*/ */
void set_axis_never_homed(const AxisEnum axis) { void set_axis_never_homed(const AxisEnum axis) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", axis_codes[axis], ")"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", AS_CHAR(axis_codes[axis]), ")");
set_axis_untrusted(axis); set_axis_untrusted(axis);
set_axis_unhomed(axis); set_axis_unhomed(axis);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", axis_codes[axis], ")"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", AS_CHAR(axis_codes[axis]), ")");
TERN_(I2C_POSITION_ENCODERS, I2CPEM.unhomed(axis)); TERN_(I2C_POSITION_ENCODERS, I2CPEM.unhomed(axis));
} }
@ -1458,7 +1458,7 @@ void prepare_line_to_destination() {
if (ABS(phaseDelta) * planner.steps_to_mm[axis] / phasePerUStep < 0.05f) if (ABS(phaseDelta) * planner.steps_to_mm[axis] / phasePerUStep < 0.05f)
SERIAL_ECHOLNPAIR("Selected home phase ", home_phase[axis], SERIAL_ECHOLNPAIR("Selected home phase ", home_phase[axis],
" too close to endstop trigger phase ", phaseCurrent, " too close to endstop trigger phase ", phaseCurrent,
". Pick a different phase for ", axis_codes[axis]); ". Pick a different phase for ", AS_CHAR(axis_codes[axis]));
// Skip to next if target position is behind current. So it only moves away from endstop. // Skip to next if target position is behind current. So it only moves away from endstop.
if (phaseDelta < 0) phaseDelta += 1024; if (phaseDelta < 0) phaseDelta += 1024;
@ -1469,7 +1469,7 @@ void prepare_line_to_destination() {
// Optional debug messages // Optional debug messages
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR( DEBUG_ECHOLNPAIR(
"Endstop ", axis_codes[axis], " hit at Phase:", phaseCurrent, "Endstop ", AS_CHAR(axis_codes[axis]), " hit at Phase:", phaseCurrent,
" Delta:", phaseDelta, " Distance:", mmDelta " Delta:", phaseDelta, " Distance:", mmDelta
); );
} }
@ -1507,7 +1507,7 @@ void prepare_line_to_destination() {
if (!_CAN_HOME(X) && !_CAN_HOME(Y) && !_CAN_HOME(Z)) return; if (!_CAN_HOME(X) && !_CAN_HOME(Y) && !_CAN_HOME(Z)) return;
#endif #endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", axis_codes[axis], ")"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", AS_CHAR(axis_codes[axis]), ")");
const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS) const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS)
? x_home_dir(active_extruder) : home_dir(axis); ? x_home_dir(active_extruder) : home_dir(axis);
@ -1585,7 +1585,7 @@ void prepare_line_to_destination() {
case Z_AXIS: es = Z_ENDSTOP; break; case Z_AXIS: es = Z_ENDSTOP; break;
} }
if (TEST(endstops.state(), es)) { if (TEST(endstops.state(), es)) {
SERIAL_ECHO_MSG("Bad ", axis_codes[axis], " Endstop?"); SERIAL_ECHO_MSG("Bad ", AS_CHAR(axis_codes[axis]), " Endstop?");
kill(GET_TEXT(MSG_KILL_HOMING_FAILED)); kill(GET_TEXT(MSG_KILL_HOMING_FAILED));
} }
#endif #endif
@ -1807,7 +1807,7 @@ void prepare_line_to_destination() {
if (axis == Z_AXIS) fwretract.current_hop = 0.0; if (axis == Z_AXIS) fwretract.current_hop = 0.0;
#endif #endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", axis_codes[axis], ")"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", AS_CHAR(axis_codes[axis]), ")");
} // homeaxis() } // homeaxis()
@ -1885,14 +1885,14 @@ void set_axis_is_at_home(const AxisEnum axis) {
DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(axis_codes[axis]), "] = ", home_offset[axis]); DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(axis_codes[axis]), "] = ", home_offset[axis]);
#endif #endif
DEBUG_POS("", current_position); DEBUG_POS("", current_position);
DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", axis_codes[axis], ")"); DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")");
} }
} }
#if HAS_WORKSPACE_OFFSET #if HAS_WORKSPACE_OFFSET
void update_workspace_offset(const AxisEnum axis) { void update_workspace_offset(const AxisEnum axis) {
workspace_offset[axis] = home_offset[axis] + position_shift[axis]; workspace_offset[axis] = home_offset[axis] + position_shift[axis];
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", XYZ_CHAR(axis), " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", AS_CHAR(XYZ_CHAR(axis)), " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]);
} }
#endif #endif