1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-23 12:04:19 +00:00

🚸 M666: Fix value filter, add report (#22337)

In reference to #22325
This commit is contained in:
Scott Lahteine 2021-07-11 18:25:51 -05:00 committed by Scott Lahteine
parent c746b1a2ae
commit f76b063e58
3 changed files with 62 additions and 59 deletions

View File

@ -27,30 +27,72 @@
#include "../gcode.h"
#if ENABLED(DELTA)
#include "../../module/delta.h"
#include "../../module/motion.h"
#else
#include "../../module/endstops.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
void M666_report(const bool forReplay=true) {
if (!forReplay) { SERIAL_ECHOLNPGM("; Endstop adjustment:"); SERIAL_ECHO_START(); }
#if ENABLED(DELTA)
SERIAL_ECHOLNPAIR_P(
PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a)
, SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b)
, SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c)
);
#else
SERIAL_ECHOPGM(" M666");
#if ENABLED(X_DUAL_ENDSTOPS)
SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj));
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj));
#endif
#if ENABLED(Z_MULTI_ENDSTOPS)
#if NUM_Z_STEPPER_DRIVERS >= 3
SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
if (!forReplay) SERIAL_ECHO_START();
SERIAL_ECHOPAIR(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
#if NUM_Z_STEPPER_DRIVERS >= 4
if (!forReplay) SERIAL_ECHO_START();
SERIAL_ECHOPAIR(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj));
#endif
#else
SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj));
#endif
#endif
#endif
}
#if ENABLED(DELTA)
/**
* M666: Set delta endstop adjustment
*/
void GcodeSuite::M666() {
DEBUG_SECTION(log_M666, "M666", DEBUGGING(LEVELING));
bool is_err = false, is_set = false;
LOOP_LINEAR_AXES(i) {
if (parser.seen(AXIS_CHAR(i))) {
is_set = true;
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[", AS_CHAR(AXIS_CHAR(i)), "] = ", delta_endstop_adj[i]);
if (v > 0)
is_err = true;
else {
delta_endstop_adj[i] = v;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(AXIS_CHAR(i)), "] = ", v);
}
}
}
if (is_err) SERIAL_ECHOLNPAIR("?M666 offsets must be <= 0");
if (!is_set) M666_report();
}
#elif HAS_EXTRA_ENDSTOPS
#include "../../module/endstops.h"
#else
/**
* M666: Set Dual Endstops offsets for X, Y, and/or Z.
@ -81,21 +123,7 @@
#endif
}
#endif
if (!parser.seen("XYZ")) {
auto echo_adj = [](PGM_P const label, const_float_t value) { SERIAL_ECHOPAIR_P(label, value); };
SERIAL_ECHOPGM("Dual Endstop Adjustment (mm): ");
#if ENABLED(X_DUAL_ENDSTOPS)
echo_adj(PSTR(" X2:"), endstops.x2_endstop_adj);
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
echo_adj(PSTR(" Y2:"), endstops.y2_endstop_adj);
#endif
#if ENABLED(Z_MULTI_ENDSTOPS)
#define _ECHO_ZADJ(N) echo_adj(PSTR(" Z" STRINGIFY(N) ":"), endstops.z##N##_endstop_adj);
REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _ECHO_ZADJ)
#endif
SERIAL_EOL();
}
if (!parser.seen("XYZ")) M666_report();
}
#endif // HAS_EXTRA_ENDSTOPS

View File

@ -27,7 +27,7 @@
#include "../../gcode.h"
#include "../../../feature/controllerfan.h"
void M710_report(const bool forReplay) {
void M710_report(const bool forReplay=true) {
if (!forReplay) { SERIAL_ECHOLNPGM("; Controller Fan"); SERIAL_ECHO_START(); }
SERIAL_ECHOLNPAIR(" M710"
" S", int(controllerFan.settings.active_speed),
@ -75,7 +75,7 @@ void GcodeSuite::M710() {
if (seenD) controllerFan.settings.duration = parser.value_ushort();
if (!(seenR || seenS || seenI || seenA || seenD))
M710_report(false);
M710_report();
}
#endif // CONTROLLER_FAN_EDITABLE

View File

@ -130,7 +130,7 @@
#include "../feature/controllerfan.h"
#if ENABLED(CONTROLLER_FAN_EDITABLE)
void M710_report(const bool forReplay);
void M710_report(const bool forReplay=true);
#endif
#if ENABLED(CASE_LIGHT_ENABLE)
@ -168,6 +168,10 @@
void M554_report();
#endif
#if EITHER(DELTA, HAS_EXTRA_ENDSTOPS)
void M666_report(const bool forReplay=true);
#endif
#define _EN_ITEM(N) , E##N
typedef struct { uint16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stepper_current_t;
@ -3302,14 +3306,6 @@ void MarlinSettings::reset() {
#elif ENABLED(DELTA)
CONFIG_ECHO_HEADING("Endstop adjustment:");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR_P(
PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a)
, SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b)
, SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c)
);
CONFIG_ECHO_HEADING("Delta settings: L<diagonal rod> R<radius> H<height> S<segments per sec> XYZ<tower angle trim> ABC<rod trim>");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR_P(
@ -3325,32 +3321,11 @@ void MarlinSettings::reset() {
, PSTR(" C"), LINEAR_UNIT(delta_diagonal_rod_trim.c)
);
#elif HAS_EXTRA_ENDSTOPS
#endif
CONFIG_ECHO_HEADING("Endstop adjustment:");
CONFIG_ECHO_START();
SERIAL_ECHOPGM(" M666");
#if ENABLED(X_DUAL_ENDSTOPS)
SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj));
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj));
#endif
#if ENABLED(Z_MULTI_ENDSTOPS)
#if NUM_Z_STEPPER_DRIVERS >= 3
SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
CONFIG_ECHO_START();
SERIAL_ECHOPAIR(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
#if NUM_Z_STEPPER_DRIVERS >= 4
CONFIG_ECHO_START();
SERIAL_ECHOPAIR(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj));
#endif
#else
SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj));
#endif
#endif
#endif // [XYZ]_DUAL_ENDSTOPS
#if EITHER(DELTA, HAS_EXTRA_ENDSTOPS)
M666_report(forReplay);
#endif
#if PREHEAT_COUNT