Browse Source

Add SERIAL_FLOAT_PRECISION option (#18367)

vanilla_fb_2.0.x
Fabio Santos 4 years ago
committed by GitHub
parent
commit
25c7c43a82
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      Marlin/Configuration_adv.h
  2. 2
      Marlin/src/MarlinCore.cpp
  3. 3
      Marlin/src/core/debug_out.h
  4. 2
      Marlin/src/core/macros.h
  5. 4
      Marlin/src/core/serial.cpp
  6. 6
      Marlin/src/core/serial.h
  7. 4
      Marlin/src/core/utility.cpp
  8. 2
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  9. 2
      Marlin/src/feature/encoder_i2c.cpp
  10. 4
      Marlin/src/feature/encoder_i2c.h
  11. 6
      Marlin/src/feature/powerloss.cpp
  12. 2
      Marlin/src/gcode/config/M92.cpp
  13. 2
      Marlin/src/gcode/feature/advance/M900.cpp
  14. 2
      Marlin/src/gcode/probe/G30.cpp
  15. 7
      Marlin/src/module/probe.cpp

3
Marlin/Configuration_adv.h

@ -1901,6 +1901,9 @@
// This option inserts short delays between lines of serial output. // This option inserts short delays between lines of serial output.
#define SERIAL_OVERRUN_PROTECTION #define SERIAL_OVERRUN_PROTECTION
// For serial echo, the number of digits after the decimal point
//#define SERIAL_FLOAT_PRECISION 4
// @section extras // @section extras
/** /**

2
Marlin/src/MarlinCore.cpp

@ -857,7 +857,7 @@ void setup() {
#if ENABLED(MARLIN_DEV_MODE) #if ENABLED(MARLIN_DEV_MODE)
auto log_current_ms = [&](PGM_P const msg) { auto log_current_ms = [&](PGM_P const msg) {
SERIAL_ECHO_START(); SERIAL_ECHO_START();
SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHO("] "); SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHOPGM("] ");
serialprintPGM(msg); serialprintPGM(msg);
SERIAL_EOL(); SERIAL_EOL();
}; };

3
Marlin/src/core/debug_out.h

@ -31,6 +31,7 @@
#undef DEBUG_ERROR_START #undef DEBUG_ERROR_START
#undef DEBUG_CHAR #undef DEBUG_CHAR
#undef DEBUG_ECHO #undef DEBUG_ECHO
#undef DEBUG_DECIMAL
#undef DEBUG_ECHO_F #undef DEBUG_ECHO_F
#undef DEBUG_ECHOLN #undef DEBUG_ECHOLN
#undef DEBUG_ECHOPGM #undef DEBUG_ECHOPGM
@ -57,6 +58,7 @@
#define DEBUG_ERROR_START SERIAL_ERROR_START #define DEBUG_ERROR_START SERIAL_ERROR_START
#define DEBUG_CHAR SERIAL_CHAR #define DEBUG_CHAR SERIAL_CHAR
#define DEBUG_ECHO SERIAL_ECHO #define DEBUG_ECHO SERIAL_ECHO
#define DEBUG_DECIMAL SERIAL_DECIMAL
#define DEBUG_ECHO_F SERIAL_ECHO_F #define DEBUG_ECHO_F SERIAL_ECHO_F
#define DEBUG_ECHOLN SERIAL_ECHOLN #define DEBUG_ECHOLN SERIAL_ECHOLN
#define DEBUG_ECHOPGM SERIAL_ECHOPGM #define DEBUG_ECHOPGM SERIAL_ECHOPGM
@ -82,6 +84,7 @@
#define DEBUG_ERROR_START() NOOP #define DEBUG_ERROR_START() NOOP
#define DEBUG_CHAR(...) NOOP #define DEBUG_CHAR(...) NOOP
#define DEBUG_ECHO(...) NOOP #define DEBUG_ECHO(...) NOOP
#define DEBUG_DECIMAL(...) NOOP
#define DEBUG_ECHO_F(...) NOOP #define DEBUG_ECHO_F(...) NOOP
#define DEBUG_ECHOLN(...) NOOP #define DEBUG_ECHOLN(...) NOOP
#define DEBUG_ECHOPGM(...) NOOP #define DEBUG_ECHOPGM(...) NOOP

2
Marlin/src/core/macros.h

@ -270,7 +270,7 @@
#define NEAR(x,y) NEAR_ZERO((x)-(y)) #define NEAR(x,y) NEAR_ZERO((x)-(y))
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x))) #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 // Maths macros that can be overridden by HAL

4
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, 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, 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, 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, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(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, 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 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); } void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }

6
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)) #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.) // Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
// //

4
Marlin/src/core/utility.cpp

@ -123,10 +123,10 @@ void safe_delay(millis_t ms) {
#if ABL_PLANAR #if ABL_PLANAR
SERIAL_ECHOPGM("ABL Adjustment X"); SERIAL_ECHOPGM("ABL Adjustment X");
LOOP_XYZ(a) { 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)); SERIAL_CHAR(' ', XYZ_CHAR(a));
if (v > 0) SERIAL_CHAR('+'); if (v > 0) SERIAL_CHAR('+');
SERIAL_ECHO(v); SERIAL_DECIMAL(v);
} }
#else #else
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)

2
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

@ -433,7 +433,7 @@
if (g29_verbose_level > 1) { if (g29_verbose_level > 1) {
SERIAL_ECHOPAIR("Probing around (", g29_pos.x); SERIAL_ECHOPAIR("Probing around (", g29_pos.x);
SERIAL_CHAR(','); SERIAL_CHAR(',');
SERIAL_ECHO(g29_pos.y); SERIAL_DECIMAL(g29_pos.y);
SERIAL_ECHOLNPGM(").\n"); SERIAL_ECHOLNPGM(").\n");
} }
const xy_pos_t near_probe_xy = g29_pos + probe.offset_xy; const xy_pos_t near_probe_xy = g29_pos + probe.offset_xy;

2
Marlin/src/feature/encoder_i2c.cpp

@ -107,7 +107,7 @@ void I2CPositionEncoder::update() {
SERIAL_ECHOLNPAIR("New zero-offset of ", zeroOffset); SERIAL_ECHOLNPAIR("New zero-offset of ", zeroOffset);
SERIAL_ECHOPAIR("New position reads as ", get_position()); SERIAL_ECHOPAIR("New position reads as ", get_position());
SERIAL_CHAR('('); SERIAL_CHAR('(');
SERIAL_ECHO(mm_from_count(get_position())); SERIAL_DECIMAL(mm_from_count(get_position()));
SERIAL_ECHOLNPGM(")"); SERIAL_ECHOLNPGM(")");
#endif #endif
} }

4
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) { static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
encoders[idx].set_ec_threshold(newThreshold); 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) { static void get_ec_threshold(const int8_t idx, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
const float threshold = encoders[idx].get_ec_threshold(); 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) { static int8_t idx_from_axis(const AxisEnum axis) {

6
Marlin/src/feature/powerloss.cpp

@ -472,7 +472,7 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOPGM("current_position: "); DEBUG_ECHOPGM("current_position: ");
LOOP_XYZE(i) { LOOP_XYZE(i) {
if (i) DEBUG_CHAR(','); if (i) DEBUG_CHAR(',');
DEBUG_ECHO(info.current_position[i]); DEBUG_DECIMAL(info.current_position[i]);
} }
DEBUG_EOL(); DEBUG_EOL();
@ -480,7 +480,7 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOPGM("home_offset: "); DEBUG_ECHOPGM("home_offset: ");
LOOP_XYZ(i) { LOOP_XYZ(i) {
if (i) DEBUG_CHAR(','); if (i) DEBUG_CHAR(',');
DEBUG_ECHO(info.home_offset[i]); DEBUG_DECIMAL(info.home_offset[i]);
} }
DEBUG_EOL(); DEBUG_EOL();
#endif #endif
@ -489,7 +489,7 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOPGM("position_shift: "); DEBUG_ECHOPGM("position_shift: ");
LOOP_XYZ(i) { LOOP_XYZ(i) {
if (i) DEBUG_CHAR(','); if (i) DEBUG_CHAR(',');
DEBUG_ECHO(info.position_shift[i]); DEBUG_DECIMAL(info.position_shift[i]);
} }
DEBUG_EOL(); DEBUG_EOL();
#endif #endif

2
Marlin/src/gcode/config/M92.cpp

@ -105,7 +105,7 @@ void GcodeSuite::M92() {
if (wanted) { if (wanted) {
const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm; const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm;
SERIAL_ECHOPAIR(", best:[", best); 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_CHAR(']');
} }
SERIAL_ECHOLNPGM(" }"); SERIAL_ECHOLNPGM(" }");

2
Marlin/src/gcode/feature/advance/M900.cpp

@ -134,7 +134,7 @@ void GcodeSuite::M900() {
SERIAL_ECHOPGM("Advance K"); SERIAL_ECHOPGM("Advance K");
LOOP_L_N(i, EXTRUDERS) { LOOP_L_N(i, EXTRUDERS) {
SERIAL_CHAR(' ', '0' + i, ':'); SERIAL_CHAR(' ', '0' + i, ':');
SERIAL_ECHO(planner.extruder_advance_K[i]); SERIAL_DECIMAL(planner.extruder_advance_K[i]);
} }
SERIAL_EOL(); SERIAL_EOL();
#endif #endif

2
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 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); const float measured_z = probe.probe_at_point(pos, raise_after, 1);
if (!isnan(measured_z)) 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(); restore_feedrate_and_scaling();

7
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) else if (raise_after == PROBE_PT_STOW)
if (stow()) measured_z = NAN; // Error on stow? if (stow()) measured_z = NAN; // Error on stow?
if (verbose_level > 2) { if (verbose_level > 2)
SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3); SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
SERIAL_ECHOPAIR_F( " Y: ", LOGICAL_Y_POSITION(ry), 3);
SERIAL_ECHOLNPAIR_F( " Z: ", measured_z, 3);
}
} }
feedrate_mm_s = old_feedrate_mm_s; feedrate_mm_s = old_feedrate_mm_s;

Loading…
Cancel
Save