From 1bd35072cbf45b2b5574dc6a05f411b00238e120 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 7 Apr 2021 15:43:07 -0500 Subject: [PATCH] Fix axis char printing --- Marlin/src/core/serial.h | 1 + Marlin/src/feature/fwretract.cpp | 16 +++++++-------- Marlin/src/feature/powerloss.cpp | 2 +- Marlin/src/gcode/calibrate/M666.cpp | 2 +- Marlin/src/gcode/control/M605.cpp | 2 +- Marlin/src/gcode/parser.cpp | 2 +- .../extui/lib/anycubic_chiron/chiron_tft.cpp | 2 +- .../lib/dgus/fysetc/DGUSScreenHandler.cpp | 6 +++--- .../lib/dgus/hiprecy/DGUSScreenHandler.cpp | 6 +++--- .../extui/lib/dgus/mks/DGUSScreenHandler.cpp | 8 ++++---- .../lib/dgus/origin/DGUSScreenHandler.cpp | 6 +++--- .../src/lcd/extui/lib/nextion/nextion_tft.cpp | 8 ++++---- Marlin/src/lcd/marlinui.cpp | 4 ++-- Marlin/src/module/motion.cpp | 20 +++++++++---------- 14 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 45a1ab012e73..b503c0f42925 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -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; inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.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 inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); } diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 4e57ba015006..bfcdb8c00106 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -111,14 +111,14 @@ void FWRetract::retract(const bool retracting /* // debugging SERIAL_ECHOLNPAIR( - "retracting ", retracting, + "retracting ", AS_DIGIT(retracting), " swapping ", swapping, " active extruder ", active_extruder ); LOOP_L_N(i, EXTRUDERS) { - SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); + SERIAL_ECHOLNPAIR("retracted[", i, "] ", AS_DIGIT(retracted[i])); #if HAS_MULTI_EXTRUDER - SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); + SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i])); #endif } SERIAL_ECHOLNPAIR("current_position.z ", current_position.z); @@ -185,13 +185,13 @@ void FWRetract::retract(const bool retracting #endif /* // debugging - SERIAL_ECHOLNPAIR("retracting ", retracting); - SERIAL_ECHOLNPAIR("swapping ", swapping); + SERIAL_ECHOLNPAIR("retracting ", AS_DIGIT(retracting)); + SERIAL_ECHOLNPAIR("swapping ", AS_DIGIT(swapping)); SERIAL_ECHOLNPAIR("active_extruder ", active_extruder); LOOP_L_N(i, EXTRUDERS) { - SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); + SERIAL_ECHOLNPAIR("retracted[", i, "] ", AS_DIGIT(retracted[i])); #if HAS_MULTI_EXTRUDER - SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); + SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i])); #endif } 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*/) { 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 diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index e45864b48488..dd4c78726aa5 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -612,7 +612,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOLNPAIR("sd_filename: ", info.sd_filename); DEBUG_ECHOLNPAIR("sdpos: ", info.sdpos); 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); } else diff --git a/Marlin/src/gcode/calibrate/M666.cpp b/Marlin/src/gcode/calibrate/M666.cpp index e915aa8ff7b7..75becf13f369 100644 --- a/Marlin/src/gcode/calibrate/M666.cpp +++ b/Marlin/src/gcode/calibrate/M666.cpp @@ -43,7 +43,7 @@ if (parser.seen(XYZ_CHAR(i))) { const float v = parser.value_linear_units(); 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]); } } } diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 3d13cb1c2444..e0c79f0e54e2 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -141,7 +141,7 @@ HOTEND_LOOP() { 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(); diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index ebe9d3b2cd67..f7812bf3f630 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -307,7 +307,7 @@ void GCodeParser::parse(char *p) { #if ENABLED(DEBUG_GCODE_PARSER) 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)"); } #endif diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index aa78fcb539dd..5eb8611b5e66 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -639,7 +639,7 @@ namespace Anycubic { float newposition = atof(&panel_command[6]); #if ACDEBUG(AC_ACTION) - SERIAL_ECHOLNPAIR("Nudge ", panel_command[4], " axis ", newposition); + SERIAL_ECHOLNPAIR("Nudge ", AS_CHAR(panel_command[4]), " axis ", newposition); #endif switch (panel_command[4]) { diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp index 5497dd53cc82..26dafeaaab27 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp @@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!movevalue) { // homing - DEBUG_ECHOPAIR(" homing ", axiscode); + DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode)); char buf[6] = "G28 X"; buf[4] = axiscode; //DEBUG_ECHOPAIR(" ", buf); @@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } else { // movement - DEBUG_ECHOPAIR(" move ", axiscode); + DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode)); bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); @@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode)); return; } diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp index c170c288aa10..f91c2737e0c6 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp @@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!movevalue) { // homing - DEBUG_ECHOPAIR(" homing ", axiscode); + DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode)); char buf[6] = "G28 X"; buf[4] = axiscode; //DEBUG_ECHOPAIR(" ", buf); @@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } else { // movement - DEBUG_ECHOPAIR(" move ", axiscode); + DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode)); bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); @@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode)); return; } diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index 109e9a8ac6a8..b507c1ec3eb1 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -835,7 +835,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!movevalue) { // homing - DEBUG_ECHOPAIR(" homing ", axiscode); + DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode)); // char buf[6] = "G28 X"; // buf[4] = axiscode; @@ -850,14 +850,14 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { else if (movevalue == 5) { DEBUG_ECHOPAIR("send M84"); char buf[6]; - snprintf_P(buf,6,PSTR("M84 %c"),axiscode); + snprintf_P(buf,6,PSTR("M84 %c"), axiscode); queue.enqueue_one_now(buf); ForceCompleteUpdate(); return; } else { // movement - DEBUG_ECHOPAIR(" move ", axiscode); + DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode)); bool old_relative_mode = relative_mode; if (!relative_mode) { @@ -895,7 +895,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode)); return; } diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp index ff924f4061f3..8806623b69fa 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp @@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!movevalue) { // homing - DEBUG_ECHOPAIR(" homing ", axiscode); + DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode)); char buf[6] = "G28 X"; buf[4] = axiscode; //DEBUG_ECHOPAIR(" ", buf); @@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } else { // movement - DEBUG_ECHOPAIR(" move ", axiscode); + DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode)); bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); @@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode)); return; } diff --git a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp index e2fa6bc51800..23857c65c340 100644 --- a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp @@ -144,10 +144,10 @@ bool NextionTFT::ReadTFTCommand() { #if NEXDEBUG(N_SOME) uint8_t req = atoi(&nextion_command[1]); if (req > 7 && req != 20) - DEBUG_ECHOLNPAIR( "> ", nextion_command[0], - "\n> ", nextion_command[1], - "\n> ", nextion_command[2], - "\n> ", nextion_command[3], + DEBUG_ECHOLNPAIR( "> ", AS_CHAR(nextion_command[0]), + "\n> ", AS_CHAR(nextion_command[1]), + "\n> ", AS_CHAR(nextion_command[2]), + "\n> ", AS_CHAR(nextion_command[3]), "\nprinter_state:", printer_state); #endif } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 4d457dc6aa01..149da8b54e5d 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -761,7 +761,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { // 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); - //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; @@ -782,7 +782,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #endif start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves 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) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 81c3a81fbeb4..48535b63d67d 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -622,7 +622,7 @@ void restore_feedrate_and_scaling() { #endif 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). */ 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_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)); } @@ -1458,7 +1458,7 @@ void prepare_line_to_destination() { if (ABS(phaseDelta) * planner.steps_to_mm[axis] / phasePerUStep < 0.05f) SERIAL_ECHOLNPAIR("Selected home phase ", home_phase[axis], " 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. if (phaseDelta < 0) phaseDelta += 1024; @@ -1469,7 +1469,7 @@ void prepare_line_to_destination() { // Optional debug messages if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR( - "Endstop ", axis_codes[axis], " hit at Phase:", phaseCurrent, + "Endstop ", AS_CHAR(axis_codes[axis]), " hit at Phase:", phaseCurrent, " Delta:", phaseDelta, " Distance:", mmDelta ); } @@ -1507,7 +1507,7 @@ void prepare_line_to_destination() { if (!_CAN_HOME(X) && !_CAN_HOME(Y) && !_CAN_HOME(Z)) return; #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) ? x_home_dir(active_extruder) : home_dir(axis); @@ -1585,7 +1585,7 @@ void prepare_line_to_destination() { case Z_AXIS: es = Z_ENDSTOP; break; } 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)); } #endif @@ -1807,7 +1807,7 @@ void prepare_line_to_destination() { if (axis == Z_AXIS) fwretract.current_hop = 0.0; #endif - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", axis_codes[axis], ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", AS_CHAR(axis_codes[axis]), ")"); } // 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]); #endif 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 void update_workspace_offset(const AxisEnum 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