Add SERIAL_FLOAT_PRECISION option (#18367)
This commit is contained in:
parent
1ea4e393c9
commit
25c7c43a82
@ -1901,6 +1901,9 @@
|
||||
// This option inserts short delays between lines of serial output.
|
||||
#define SERIAL_OVERRUN_PROTECTION
|
||||
|
||||
// For serial echo, the number of digits after the decimal point
|
||||
//#define SERIAL_FLOAT_PRECISION 4
|
||||
|
||||
// @section extras
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -270,7 +270,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
|
||||
|
@ -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_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); }
|
||||
|
||||
|
@ -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.)
|
||||
//
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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(" }");
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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_F("Bed X: ", LOGICAL_X_POSITION(rx), 3);
|
||||
SERIAL_ECHOPAIR_F( " Y: ", LOGICAL_Y_POSITION(ry), 3);
|
||||
SERIAL_ECHOLNPAIR_F( " Z: ", measured_z, 3);
|
||||
}
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user