From 9bc2f7c610f4c0f80ec51c7129ffc59f586645d1 Mon Sep 17 00:00:00 2001 From: FabioSan Date: Sat, 20 Jun 2020 08:18:07 -0700 Subject: [PATCH 01/13] Intoduces DEFAULT_PRINT_FLOAT_PRECISION --- Marlin/Configuration_adv.h | 4 ++++ Marlin/src/core/serial.cpp | 4 ++-- Marlin/src/gcode/probe/G30.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b63253a27c49..6a550dee8cae 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1873,6 +1873,10 @@ // This option inserts short delays between lines of serial output. #define SERIAL_OVERRUN_PROTECTION +// Default serial print float precision. +// Probing and delta settings may benefit from reporting more digits. +#define DEFAULT_PRINT_FLOAT_PRECISION 2 + // @section extras /** diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 313d6ce20eb9..093d7efef200 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -42,8 +42,8 @@ void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P) void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } void serial_echopair_PGM(PGM_P const s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_PRINT(v, DEFAULT_PRINT_FLOAT_PRECISION); } +void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_PRINT(v, DEFAULT_PRINT_FLOAT_PRECISION); } void serial_echopair_PGM(PGM_P const s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index 5a01289deae4..0d8049158c57 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -53,7 +53,7 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); if (!isnan(measured_z)) - SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z)); + SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); restore_feedrate_and_scaling(); From fa7f5e43aad548518c6b2bfb0c0052992bba058c Mon Sep 17 00:00:00 2001 From: Fabio Santos Date: Sat, 20 Jun 2020 12:01:55 -0700 Subject: [PATCH 02/13] cant expect define to exist --- Marlin/Configuration_adv.h | 2 +- Marlin/src/core/serial.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6a550dee8cae..be61614cf2b2 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1875,7 +1875,7 @@ // Default serial print float precision. // Probing and delta settings may benefit from reporting more digits. -#define DEFAULT_PRINT_FLOAT_PRECISION 2 +// #define DEFAULT_PRINT_FLOAT_PRECISION 4 // @section extras diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 093d7efef200..a9b1457cf9a1 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -42,8 +42,13 @@ void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P) void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } void serial_echopair_PGM(PGM_P const s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_PRINT(v, DEFAULT_PRINT_FLOAT_PRECISION); } -void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_PRINT(v, DEFAULT_PRINT_FLOAT_PRECISION); } +#ifdef DEFAULT_PRINT_FLOAT_PRECISION + void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_PRINT(v, DEFAULT_PRINT_FLOAT_PRECISION); } + void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_PRINT(v, DEFAULT_PRINT_FLOAT_PRECISION); } +#else + void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } + void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +#endif void serial_echopair_PGM(PGM_P const s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } From 0026297e26ab55b0e387d0d53e8a2ef2c8b2b2c1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Jun 2020 23:46:58 -0500 Subject: [PATCH 03/13] Update serial.cpp --- Marlin/src/core/serial.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index a9b1457cf9a1..83a57a9a17ef 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -42,13 +42,15 @@ void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P) void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } void serial_echopair_PGM(PGM_P const s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -#ifdef DEFAULT_PRINT_FLOAT_PRECISION - void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_PRINT(v, DEFAULT_PRINT_FLOAT_PRECISION); } - void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_PRINT(v, DEFAULT_PRINT_FLOAT_PRECISION); } + +#if DEFAULT_PRINT_FLOAT_PRECISION + #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, DEFAULT_PRINT_FLOAT_PRECISION) #else - void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } - void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); } + #define SERIAL_DECIMAL(V) SERIAL_ECHO(V) #endif + +void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } +void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } From b614708e6b7dcf31335e15b20e1f6e9092e2dfdc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Jun 2020 23:55:34 -0500 Subject: [PATCH 04/13] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index be61614cf2b2..f8ed54115d0f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1873,9 +1873,8 @@ // This option inserts short delays between lines of serial output. #define SERIAL_OVERRUN_PROTECTION -// Default serial print float precision. -// Probing and delta settings may benefit from reporting more digits. -// #define DEFAULT_PRINT_FLOAT_PRECISION 4 +// For serial echo, the number of digits after the decimal point +//#define SERIAL_FLOAT_PRECISION 4 // @section extras From 8909e87b2d21186a0e7740b631ff020a82a9b27b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 21 Jun 2020 04:06:57 -0500 Subject: [PATCH 05/13] Update serial.cpp --- Marlin/src/core/serial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 83a57a9a17ef..137f29edd306 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -43,8 +43,8 @@ void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P) void serial_echopair_PGM(PGM_P const s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -#if DEFAULT_PRINT_FLOAT_PRECISION - #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, DEFAULT_PRINT_FLOAT_PRECISION) +#if SERIAL_FLOAT_PRECISION + #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION) #else #define SERIAL_DECIMAL(V) SERIAL_ECHO(V) #endif From cb430f2f8f7722169c20d1f8fe6a9efc277b6262 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 21 Jun 2020 04:08:17 -0500 Subject: [PATCH 06/13] Update G30.cpp --- Marlin/src/gcode/probe/G30.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index 0d8049158c57..a1f73393956b 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -53,7 +53,7 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); if (!isnan(measured_z)) - SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); + SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", measured_z); restore_feedrate_and_scaling(); From 1264c13eb0128fb7f82d48e9e84b15f50376f54a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 21 Jun 2020 04:11:07 -0500 Subject: [PATCH 07/13] Neaten probe XY --- Marlin/src/gcode/probe/G30.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index a1f73393956b..c6d0dd9f6277 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -52,8 +52,11 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); - if (!isnan(measured_z)) - SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", measured_z); + if (!isnan(measured_z)) { + SERIAL_ECHO("Bed X: "); SERIAL_ECHO(FIXFLOAT(pos.x)); + SERIAL_ECHO( " Y: "); SERIAL_ECHO(FIXFLOAT(pos.y)); + SERIAL_ECHOLNPAIR(" Z: ", measured_z); + } restore_feedrate_and_scaling(); From a9d952f044cde874bf600c7c03e31ba374a92a8d Mon Sep 17 00:00:00 2001 From: FabioSan Date: Sun, 21 Jun 2020 07:19:51 -0700 Subject: [PATCH 08/13] Smaller constant to FIXFLOAT. Invisible to 5 fractional digits. --- Marlin/src/core/macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index ebcb9ebcfb89..50b09b5da651 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -267,7 +267,7 @@ #define NEAR(x,y) NEAR_ZERO((x)-(y)) #define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x))) -#define FIXFLOAT(f) ({__typeof__(f) _f = (f); _f + (_f < 0 ? -0.00005f : 0.00005f);}) +#define FIXFLOAT(f) ({__typeof__(f) _f = (f); _f + (_f < 0 ? -0.0000005f : 0.0000005f);}) // // Maths macros that can be overridden by HAL From 23e207124eb4c3833da9dbf27969bd36592ad715 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 22 Jun 2020 18:31:46 -0500 Subject: [PATCH 09/13] Apply SERIAL_DECIMAL --- Marlin/src/core/debug_out.h | 3 +++ Marlin/src/core/utility.cpp | 4 ++-- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 2 +- Marlin/src/feature/encoder_i2c.cpp | 2 +- Marlin/src/feature/encoder_i2c.h | 4 ++-- Marlin/src/gcode/config/M92.cpp | 2 +- Marlin/src/gcode/feature/advance/M900.cpp | 2 +- Marlin/src/gcode/probe/G30.cpp | 4 ++-- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Marlin/src/core/debug_out.h b/Marlin/src/core/debug_out.h index b7506a8304df..8be6523ca770 100644 --- a/Marlin/src/core/debug_out.h +++ b/Marlin/src/core/debug_out.h @@ -31,6 +31,7 @@ #undef DEBUG_ERROR_START #undef DEBUG_CHAR #undef DEBUG_ECHO +#undef DEBUG_DECIMAL #undef DEBUG_ECHO_F #undef DEBUG_ECHOLN #undef DEBUG_ECHOPGM @@ -57,6 +58,7 @@ #define DEBUG_ERROR_START SERIAL_ERROR_START #define DEBUG_CHAR SERIAL_CHAR #define DEBUG_ECHO SERIAL_ECHO + #define DEBUG_DECIMAL SERIAL_DECIMAL #define DEBUG_ECHO_F SERIAL_ECHO_F #define DEBUG_ECHOLN SERIAL_ECHOLN #define DEBUG_ECHOPGM SERIAL_ECHOPGM @@ -82,6 +84,7 @@ #define DEBUG_ERROR_START() NOOP #define DEBUG_CHAR(...) NOOP #define DEBUG_ECHO(...) NOOP + #define DEBUG_DECIMAL(...) NOOP #define DEBUG_ECHO_F(...) NOOP #define DEBUG_ECHOLN(...) NOOP #define DEBUG_ECHOPGM(...) NOOP diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 62e79e42ea8a..e64d6fb5e6d3 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -123,10 +123,10 @@ void safe_delay(millis_t ms) { #if ABL_PLANAR SERIAL_ECHOPGM("ABL Adjustment X"); LOOP_XYZ(a) { - float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]; + const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]; SERIAL_CHAR(' ', XYZ_CHAR(a)); if (v > 0) SERIAL_CHAR('+'); - SERIAL_ECHO(v); + SERIAL_DECIMAL(v); } #else #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 95addd6c1257..3c604168a603 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -433,7 +433,7 @@ if (g29_verbose_level > 1) { SERIAL_ECHOPAIR("Probing around (", g29_pos.x); SERIAL_CHAR(','); - SERIAL_ECHO(g29_pos.y); + SERIAL_DECIMAL(g29_pos.y); SERIAL_ECHOLNPGM(").\n"); } const xy_pos_t near_probe_xy = g29_pos + probe.offset_xy; diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index cfac36a5d167..d5a8f168db48 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -107,7 +107,7 @@ void I2CPositionEncoder::update() { SERIAL_ECHOLNPAIR("New zero-offset of ", zeroOffset); SERIAL_ECHOPAIR("New position reads as ", get_position()); SERIAL_CHAR('('); - SERIAL_ECHO(mm_from_count(get_position())); + SERIAL_DECIMAL(mm_from_count(get_position())); SERIAL_ECHOLNPGM(")"); #endif } diff --git a/Marlin/src/feature/encoder_i2c.h b/Marlin/src/feature/encoder_i2c.h index 0665ee809d41..f404954cae53 100644 --- a/Marlin/src/feature/encoder_i2c.h +++ b/Marlin/src/feature/encoder_i2c.h @@ -280,13 +280,13 @@ class I2CPositionEncodersMgr { static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) { CHECK_IDX(); encoders[idx].set_ec_threshold(newThreshold); - SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis set to ", FIXFLOAT(newThreshold), "mm."); + SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis set to ", newThreshold, "mm."); } static void get_ec_threshold(const int8_t idx, const AxisEnum axis) { CHECK_IDX(); const float threshold = encoders[idx].get_ec_threshold(); - SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis is ", FIXFLOAT(threshold), "mm."); + SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis is ", threshold, "mm."); } static int8_t idx_from_axis(const AxisEnum axis) { diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index bc86ff4d3256..4f7279fc34b3 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -105,7 +105,7 @@ void GcodeSuite::M92() { if (wanted) { const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm; SERIAL_ECHOPAIR(", best:[", best); - if (best != wanted) { SERIAL_CHAR(','); SERIAL_ECHO(best + z_full_step_mm); } + if (best != wanted) { SERIAL_CHAR(','); SERIAL_DECIMAL(best + z_full_step_mm); } SERIAL_CHAR(']'); } SERIAL_ECHOLNPGM(" }"); diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index b3985401cf1a..683f6fff1b12 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -134,7 +134,7 @@ void GcodeSuite::M900() { SERIAL_ECHOPGM("Advance K"); LOOP_L_N(i, EXTRUDERS) { SERIAL_CHAR(' ', '0' + i, ':'); - SERIAL_ECHO(planner.extruder_advance_K[i]); + SERIAL_DECIMAL(planner.extruder_advance_K[i]); } SERIAL_EOL(); #endif diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index c6d0dd9f6277..6399c2adad58 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -53,8 +53,8 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); if (!isnan(measured_z)) { - SERIAL_ECHO("Bed X: "); SERIAL_ECHO(FIXFLOAT(pos.x)); - SERIAL_ECHO( " Y: "); SERIAL_ECHO(FIXFLOAT(pos.y)); + SERIAL_ECHO("Bed X: "); SERIAL_DECIMAL(pos.x); + SERIAL_ECHO( " Y: "); SERIAL_DECIMAL(pos.y); SERIAL_ECHOLNPAIR(" Z: ", measured_z); } From 261912b2e575d3e99ee6cf0ad2d8092089d4e294 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 22 Jun 2020 18:33:25 -0500 Subject: [PATCH 10/13] etc. --- Marlin/src/feature/powerloss.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 12de2d26ff9e..0ae1280213cf 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -472,7 +472,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOPGM("current_position: "); LOOP_XYZE(i) { if (i) DEBUG_CHAR(','); - DEBUG_ECHO(info.current_position[i]); + DEBUG_DECIMAL(info.current_position[i]); } DEBUG_EOL(); @@ -480,7 +480,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOPGM("home_offset: "); LOOP_XYZ(i) { if (i) DEBUG_CHAR(','); - DEBUG_ECHO(info.home_offset[i]); + DEBUG_DECIMAL(info.home_offset[i]); } DEBUG_EOL(); #endif @@ -489,7 +489,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOPGM("position_shift: "); LOOP_XYZ(i) { if (i) DEBUG_CHAR(','); - DEBUG_ECHO(info.position_shift[i]); + DEBUG_DECIMAL(info.position_shift[i]); } DEBUG_EOL(); #endif From b9ce3afafda7147e45523e29d9fbe9a0cb1810be Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 22 Jun 2020 18:40:37 -0500 Subject: [PATCH 11/13] cleanup --- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/gcode/probe/G30.cpp | 4 ++-- Marlin/src/module/probe.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index aceb0af58f0d..744e63724921 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -857,7 +857,7 @@ void setup() { #if ENABLED(MARLIN_DEV_MODE) auto log_current_ms = [&](PGM_P const msg) { SERIAL_ECHO_START(); - SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHO("] "); + SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHOPGM("] "); serialprintPGM(msg); SERIAL_EOL(); }; diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index 6399c2adad58..a05a392abc63 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -53,8 +53,8 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); if (!isnan(measured_z)) { - SERIAL_ECHO("Bed X: "); SERIAL_DECIMAL(pos.x); - SERIAL_ECHO( " Y: "); SERIAL_DECIMAL(pos.y); + SERIAL_ECHOPAIR("Bed X: ", pos.x); + SERIAL_ECHOPAIR( " Y: ", pos.y); SERIAL_ECHOLNPAIR(" Z: ", measured_z); } diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 6aefcfa8ac7b..d0ebb66d0130 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -716,9 +716,9 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise if (stow()) measured_z = NAN; // Error on stow? if (verbose_level > 2) { - SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3); - SERIAL_ECHOPAIR_F( " Y: ", LOGICAL_Y_POSITION(ry), 3); - SERIAL_ECHOLNPAIR_F( " Z: ", measured_z, 3); + SERIAL_ECHOPAIR("Bed X: ", LOGICAL_X_POSITION(rx)); + SERIAL_ECHOPAIR( " Y: ", LOGICAL_Y_POSITION(ry)); + SERIAL_ECHOLNPAIR( " Z: ", measured_z); } } From e45459943ec356b2d199d70fd77e772aa86c620e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 22 Jun 2020 18:42:24 -0500 Subject: [PATCH 12/13] and... --- Marlin/src/gcode/probe/G30.cpp | 7 ++----- Marlin/src/module/probe.cpp | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index a05a392abc63..0d8049158c57 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -52,11 +52,8 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); - if (!isnan(measured_z)) { - SERIAL_ECHOPAIR("Bed X: ", pos.x); - SERIAL_ECHOPAIR( " Y: ", pos.y); - SERIAL_ECHOLNPAIR(" Z: ", measured_z); - } + if (!isnan(measured_z)) + SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); restore_feedrate_and_scaling(); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index d0ebb66d0130..0fb1276bfcf0 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -715,11 +715,8 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise else if (raise_after == PROBE_PT_STOW) if (stow()) measured_z = NAN; // Error on stow? - if (verbose_level > 2) { - SERIAL_ECHOPAIR("Bed X: ", LOGICAL_X_POSITION(rx)); - SERIAL_ECHOPAIR( " Y: ", LOGICAL_Y_POSITION(ry)); - SERIAL_ECHOLNPAIR( " Z: ", measured_z); - } + if (verbose_level > 2) + SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z); } feedrate_mm_s = old_feedrate_mm_s; From f9505ea340b68162bb1ff0ec4a7bee7b1a0cb0ad Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 22 Jun 2020 18:50:35 -0500 Subject: [PATCH 13/13] Move to .h --- Marlin/src/core/serial.cpp | 7 ------- Marlin/src/core/serial.h | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 137f29edd306..dee452d954ac 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -42,13 +42,6 @@ void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P) void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } void serial_echopair_PGM(PGM_P const s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } - -#if SERIAL_FLOAT_PRECISION - #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION) -#else - #define SERIAL_DECIMAL(V) SERIAL_ECHO(V) -#endif - void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index be4c000b52c8..8b72e46a7580 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -286,6 +286,12 @@ extern uint8_t marlin_debug_flags; #define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, PSTR(PRE), PSTR(ON), PSTR(OFF), PSTR(POST)) +#if SERIAL_FLOAT_PRECISION + #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION) +#else + #define SERIAL_DECIMAL(V) SERIAL_ECHO(V) +#endif + // // Functions for serial printing from PROGMEM. (Saves loads of SRAM.) //