🎨 Misc cleanup and fixes
This commit is contained in:
committed by
Scott Lahteine
parent
c85633b47f
commit
f7d28ce1d6
@ -194,16 +194,20 @@ float measuring_movement(const AxisEnum axis, const int dir, const bool stop_sta
|
||||
inline float measure(const AxisEnum axis, const int dir, const bool stop_state, float * const backlash_ptr, const float uncertainty) {
|
||||
const bool fast = uncertainty == CALIBRATION_MEASUREMENT_UNKNOWN;
|
||||
|
||||
// Save position
|
||||
destination = current_position;
|
||||
const float start_pos = destination[axis];
|
||||
// Save the current position of the specified axis
|
||||
const float start_pos = current_position[axis];
|
||||
|
||||
// Take a measurement. Only the specified axis will be affected.
|
||||
const float measured_pos = measuring_movement(axis, dir, stop_state, fast);
|
||||
|
||||
// Measure backlash
|
||||
if (backlash_ptr && !fast) {
|
||||
const float release_pos = measuring_movement(axis, -dir, !stop_state, fast);
|
||||
*backlash_ptr = ABS(release_pos - measured_pos);
|
||||
}
|
||||
// Return to starting position
|
||||
|
||||
// Move back to the starting position
|
||||
destination = current_position;
|
||||
destination[axis] = start_pos;
|
||||
do_blocking_move_to(destination, MMM_TO_MMS(CALIBRATION_FEEDRATE_TRAVEL));
|
||||
return measured_pos;
|
||||
@ -235,12 +239,12 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t
|
||||
}
|
||||
#endif
|
||||
#if AXIS_CAN_CALIBRATE(X)
|
||||
case RIGHT: dir = -1;
|
||||
case LEFT: axis = X_AXIS; break;
|
||||
case RIGHT: axis = X_AXIS; dir = -1; break;
|
||||
#endif
|
||||
#if AXIS_CAN_CALIBRATE(Y)
|
||||
case BACK: dir = -1;
|
||||
case FRONT: axis = Y_AXIS; break;
|
||||
case BACK: axis = Y_AXIS; dir = -1; break;
|
||||
#endif
|
||||
default: return;
|
||||
}
|
||||
@ -303,16 +307,8 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
|
||||
|
||||
// The difference between the known and the measured location
|
||||
// of the calibration object is the positional error
|
||||
m.pos_error.x = (0
|
||||
#if HAS_X_CENTER
|
||||
+ true_center.x - m.obj_center.x
|
||||
#endif
|
||||
);
|
||||
m.pos_error.y = (0
|
||||
#if HAS_Y_CENTER
|
||||
+ true_center.y - m.obj_center.y
|
||||
#endif
|
||||
);
|
||||
m.pos_error.x = TERN0(HAS_X_CENTER, true_center.x - m.obj_center.x);
|
||||
m.pos_error.y = TERN0(HAS_Y_CENTER, true_center.y - m.obj_center.y);
|
||||
m.pos_error.z = true_center.z - m.obj_center.z;
|
||||
}
|
||||
|
||||
@ -589,12 +585,12 @@ void GcodeSuite::G425() {
|
||||
SET_SOFT_ENDSTOP_LOOSE(true);
|
||||
|
||||
measurements_t m;
|
||||
float uncertainty = parser.seenval('U') ? parser.value_float() : CALIBRATION_MEASUREMENT_UNCERTAIN;
|
||||
const float uncertainty = parser.floatval('U', CALIBRATION_MEASUREMENT_UNCERTAIN);
|
||||
|
||||
if (parser.seen('B'))
|
||||
if (parser.seen_test('B'))
|
||||
calibrate_backlash(m, uncertainty);
|
||||
else if (parser.seen('T'))
|
||||
calibrate_toolhead(m, uncertainty, parser.has_value() ? parser.value_int() : active_extruder);
|
||||
else if (parser.seen_test('T'))
|
||||
calibrate_toolhead(m, uncertainty, parser.intval('T', active_extruder));
|
||||
#if ENABLED(CALIBRATION_REPORTING)
|
||||
else if (parser.seen('V')) {
|
||||
probe_sides(m, uncertainty);
|
||||
|
@ -87,7 +87,7 @@ void GcodeSuite::M201() {
|
||||
#endif
|
||||
|
||||
LOOP_XYZE(i) {
|
||||
if (parser.seen(axis_codes[i])) {
|
||||
if (parser.seenval(axis_codes[i])) {
|
||||
const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i);
|
||||
planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
|
||||
}
|
||||
@ -105,7 +105,7 @@ void GcodeSuite::M203() {
|
||||
if (target_extruder < 0) return;
|
||||
|
||||
LOOP_XYZE(i)
|
||||
if (parser.seen(axis_codes[i])) {
|
||||
if (parser.seenval(axis_codes[i])) {
|
||||
const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i);
|
||||
planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
|
||||
}
|
||||
@ -147,24 +147,14 @@ void GcodeSuite::M204() {
|
||||
* J = Junction Deviation (mm) (If not using CLASSIC_JERK)
|
||||
*/
|
||||
void GcodeSuite::M205() {
|
||||
#if HAS_JUNCTION_DEVIATION
|
||||
#define J_PARAM "J"
|
||||
#else
|
||||
#define J_PARAM
|
||||
#endif
|
||||
#if HAS_CLASSIC_JERK
|
||||
#define XYZE_PARAM "XYZE"
|
||||
#else
|
||||
#define XYZE_PARAM
|
||||
#endif
|
||||
if (!parser.seen("BST" J_PARAM XYZE_PARAM)) return;
|
||||
if (!parser.seen("BST" TERN_(HAS_JUNCTION_DEVIATION, "J") TERN_(HAS_CLASSIC_JERK, "XYZE"))) return;
|
||||
|
||||
//planner.synchronize();
|
||||
if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
|
||||
if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
|
||||
if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
|
||||
if (parser.seenval('B')) planner.settings.min_segment_time_us = parser.value_ulong();
|
||||
if (parser.seenval('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
|
||||
if (parser.seenval('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
|
||||
#if HAS_JUNCTION_DEVIATION
|
||||
if (parser.seen('J')) {
|
||||
if (parser.seenval('J')) {
|
||||
const float junc_dev = parser.value_linear_units();
|
||||
if (WITHIN(junc_dev, 0.01f, 0.3f)) {
|
||||
planner.junction_deviation_mm = junc_dev;
|
||||
@ -175,9 +165,9 @@ void GcodeSuite::M205() {
|
||||
}
|
||||
#endif
|
||||
#if HAS_CLASSIC_JERK
|
||||
if (parser.seen('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units());
|
||||
if (parser.seen('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units());
|
||||
if (parser.seen('Z')) {
|
||||
if (parser.seenval('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units());
|
||||
if (parser.seenval('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units());
|
||||
if (parser.seenval('Z')) {
|
||||
planner.set_max_jerk(Z_AXIS, parser.value_linear_units());
|
||||
#if HAS_MESH && DISABLED(LIMITED_JERK_EDITING)
|
||||
if (planner.max_jerk.z <= 0.1f)
|
||||
@ -185,7 +175,7 @@ void GcodeSuite::M205() {
|
||||
#endif
|
||||
}
|
||||
#if HAS_CLASSIC_E_JERK
|
||||
if (parser.seen('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units());
|
||||
if (parser.seenval('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void report_M92(const bool echo=true, const int8_t e=-1) {
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED_E(e);
|
||||
UNUSED(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,11 +64,8 @@ void GcodeSuite::M92() {
|
||||
if (target_extruder < 0) return;
|
||||
|
||||
// No arguments? Show M92 report.
|
||||
if (!parser.seen("XYZE"
|
||||
#if ENABLED(MAGIC_NUMBERS_GCODE)
|
||||
"HL"
|
||||
#endif
|
||||
)) return report_M92(true, target_extruder);
|
||||
if (!parser.seen("XYZE" TERN_(MAGIC_NUMBERS_GCODE, "HL")))
|
||||
return report_M92(true, target_extruder);
|
||||
|
||||
LOOP_XYZE(i) {
|
||||
if (parser.seenval(axis_codes[i])) {
|
||||
|
@ -34,10 +34,10 @@
|
||||
*/
|
||||
void GcodeSuite::M17() {
|
||||
if (parser.seen("XYZE")) {
|
||||
if (parser.seen('X')) ENABLE_AXIS_X();
|
||||
if (parser.seen('Y')) ENABLE_AXIS_Y();
|
||||
if (parser.seen('Z')) ENABLE_AXIS_Z();
|
||||
if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen('E'))) enable_e_steppers();
|
||||
if (parser.seen_test('X')) ENABLE_AXIS_X();
|
||||
if (parser.seen_test('Y')) ENABLE_AXIS_Y();
|
||||
if (parser.seen_test('Z')) ENABLE_AXIS_Z();
|
||||
if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) enable_e_steppers();
|
||||
}
|
||||
else {
|
||||
LCD_MESSAGEPGM(MSG_NO_MOVE);
|
||||
@ -56,10 +56,10 @@ void GcodeSuite::M18_M84() {
|
||||
else {
|
||||
if (parser.seen("XYZE")) {
|
||||
planner.synchronize();
|
||||
if (parser.seen('X')) DISABLE_AXIS_X();
|
||||
if (parser.seen('Y')) DISABLE_AXIS_Y();
|
||||
if (parser.seen('Z')) DISABLE_AXIS_Z();
|
||||
if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen('E'))) disable_e_steppers();
|
||||
if (parser.seen_test('X')) DISABLE_AXIS_X();
|
||||
if (parser.seen_test('Y')) DISABLE_AXIS_Y();
|
||||
if (parser.seen_test('Z')) DISABLE_AXIS_Z();
|
||||
if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) disable_e_steppers();
|
||||
}
|
||||
else
|
||||
planner.finish_and_disable();
|
||||
|
@ -39,8 +39,8 @@ void GcodeSuite::M211() {
|
||||
SERIAL_ECHOPGM(STR_SOFT_ENDSTOPS);
|
||||
if (parser.seen('S')) soft_endstop._enabled = parser.value_bool();
|
||||
serialprint_onoff(soft_endstop._enabled);
|
||||
print_xyz(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" "));
|
||||
print_xyz(l_soft_max, PSTR(STR_SOFT_MAX));
|
||||
print_pos(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" "));
|
||||
print_pos(l_soft_max, PSTR(STR_SOFT_MAX));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -35,10 +35,19 @@
|
||||
#define M91x_USE(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2160) || AXIS_DRIVER_TYPE(ST, TMC2208) || AXIS_DRIVER_TYPE(ST, TMC2209) || AXIS_DRIVER_TYPE(ST, TMC2660) || AXIS_DRIVER_TYPE(ST, TMC5130) || AXIS_DRIVER_TYPE(ST, TMC5160))
|
||||
#define M91x_USE_E(N) (E_STEPPERS > N && M91x_USE(E##N))
|
||||
|
||||
#define M91x_SOME_X (M91x_USE(X) || M91x_USE(X2))
|
||||
#define M91x_SOME_Y (M91x_USE(Y) || M91x_USE(Y2))
|
||||
#define M91x_SOME_Z (M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4))
|
||||
#define M91x_SOME_E (M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5) || M91x_USE_E(6) || M91x_USE_E(7))
|
||||
#if M91x_USE(X) || M91x_USE(X2)
|
||||
#define M91x_SOME_X 1
|
||||
#endif
|
||||
#if M91x_USE(Y) || M91x_USE(Y2)
|
||||
#define M91x_SOME_Y 1
|
||||
#endif
|
||||
#if M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4)
|
||||
#define M91x_SOME_Z 1
|
||||
#endif
|
||||
|
||||
#if M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5) || M91x_USE_E(6) || M91x_USE_E(7)
|
||||
#define M91x_SOME_E 1
|
||||
#endif
|
||||
|
||||
#if !M91x_SOME_X && !M91x_SOME_Y && !M91x_SOME_Z && !M91x_SOME_E
|
||||
#error "MONITOR_DRIVER_STATUS requires at least one TMC2130, 2160, 2208, 2209, 2660, 5130, or 5160."
|
||||
@ -112,31 +121,12 @@
|
||||
* M912 E1 ; clear E1 only
|
||||
*/
|
||||
void GcodeSuite::M912() {
|
||||
#if M91x_SOME_X
|
||||
const bool hasX = parser.seen(axis_codes.x);
|
||||
#else
|
||||
constexpr bool hasX = false;
|
||||
#endif
|
||||
const bool hasX = TERN0(M91x_SOME_X, parser.seen(axis_codes.x)),
|
||||
hasY = TERN0(M91x_SOME_Y, parser.seen(axis_codes.y)),
|
||||
hasZ = TERN0(M91x_SOME_Z, parser.seen(axis_codes.z)),
|
||||
hasE = TERN0(M91x_SOME_E, parser.seen(axis_codes.e));
|
||||
|
||||
#if M91x_SOME_Y
|
||||
const bool hasY = parser.seen(axis_codes.y);
|
||||
#else
|
||||
constexpr bool hasY = false;
|
||||
#endif
|
||||
|
||||
#if M91x_SOME_Z
|
||||
const bool hasZ = parser.seen(axis_codes.z);
|
||||
#else
|
||||
constexpr bool hasZ = false;
|
||||
#endif
|
||||
|
||||
#if M91x_SOME_E
|
||||
const bool hasE = parser.seen(axis_codes.e);
|
||||
#else
|
||||
constexpr bool hasE = false;
|
||||
#endif
|
||||
|
||||
const bool hasNone = !hasX && !hasY && !hasZ && !hasE;
|
||||
const bool hasNone = !hasE && !hasX && !hasY && !hasZ;
|
||||
|
||||
#if M91x_SOME_X
|
||||
const int8_t xval = int8_t(parser.byteval(axis_codes.x, 0xFF));
|
||||
|
@ -140,7 +140,7 @@ int8_t GcodeSuite::get_target_e_stepper_from_command() {
|
||||
* - Set the feedrate, if included
|
||||
*/
|
||||
void GcodeSuite::get_destination_from_command() {
|
||||
xyze_bool_t seen = { false, false, false, false };
|
||||
xyze_bool_t seen{false};
|
||||
|
||||
#if ENABLED(CANCEL_OBJECTS)
|
||||
const bool &skip_move = cancelable.skipping;
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "../../core/debug_out.h"
|
||||
#endif
|
||||
|
||||
void report_xyze(const xyze_pos_t &pos, const uint8_t n=XYZE, const uint8_t precision=3) {
|
||||
void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=XYZE, const uint8_t precision=3) {
|
||||
char str[12];
|
||||
LOOP_L_N(a, n) {
|
||||
SERIAL_CHAR(' ', axis_codes[a], ':');
|
||||
@ -43,9 +43,9 @@
|
||||
}
|
||||
SERIAL_EOL();
|
||||
}
|
||||
inline void report_xyz(const xyze_pos_t &pos) { report_xyze(pos, XYZ); }
|
||||
inline void report_linear_axis_pos(const xyze_pos_t &pos) { report_all_axis_pos(pos, XYZ); }
|
||||
|
||||
void report_xyz(const xyz_pos_t &pos, const uint8_t precision=3) {
|
||||
void report_linear_axis_pos(const xyz_pos_t &pos, const uint8_t precision=3) {
|
||||
char str[12];
|
||||
LOOP_XYZ(a) {
|
||||
SERIAL_CHAR(' ', XYZ_CHAR(a), ':');
|
||||
@ -57,11 +57,11 @@
|
||||
void report_current_position_detail() {
|
||||
// Position as sent by G-code
|
||||
SERIAL_ECHOPGM("\nLogical:");
|
||||
report_xyz(current_position.asLogical());
|
||||
report_linear_axis_pos(current_position.asLogical());
|
||||
|
||||
// Cartesian position in native machine space
|
||||
SERIAL_ECHOPGM("Raw: ");
|
||||
report_xyz(current_position);
|
||||
report_linear_axis_pos(current_position);
|
||||
|
||||
xyze_pos_t leveled = current_position;
|
||||
|
||||
@ -69,20 +69,20 @@
|
||||
// Current position with leveling applied
|
||||
SERIAL_ECHOPGM("Leveled:");
|
||||
planner.apply_leveling(leveled);
|
||||
report_xyz(leveled);
|
||||
report_linear_axis_pos(leveled);
|
||||
|
||||
// Test planner un-leveling. This should match the Raw result.
|
||||
SERIAL_ECHOPGM("UnLevel:");
|
||||
xyze_pos_t unleveled = leveled;
|
||||
planner.unapply_leveling(unleveled);
|
||||
report_xyz(unleveled);
|
||||
report_linear_axis_pos(unleveled);
|
||||
#endif
|
||||
|
||||
#if IS_KINEMATIC
|
||||
// Kinematics applied to the leveled position
|
||||
SERIAL_ECHOPGM(TERN(IS_SCARA, "ScaraK: ", "DeltaK: "));
|
||||
inverse_kinematics(leveled); // writes delta[]
|
||||
report_xyz(delta);
|
||||
report_linear_axis_pos(delta);
|
||||
#endif
|
||||
|
||||
planner.synchronize();
|
||||
@ -165,17 +165,17 @@
|
||||
planner.get_axis_position_degrees(B_AXIS)
|
||||
};
|
||||
SERIAL_ECHOPGM("Degrees:");
|
||||
report_xyze(deg, 2);
|
||||
report_all_axis_pos(deg, 2);
|
||||
#endif
|
||||
|
||||
SERIAL_ECHOPGM("FromStp:");
|
||||
get_cartesian_from_steppers(); // writes 'cartes' (with forward kinematics)
|
||||
xyze_pos_t from_steppers = { cartes.x, cartes.y, cartes.z, planner.get_axis_position_mm(E_AXIS) };
|
||||
report_xyze(from_steppers);
|
||||
report_all_axis_pos(from_steppers);
|
||||
|
||||
const xyze_float_t diff = from_steppers - leveled;
|
||||
SERIAL_ECHOPGM("Diff: ");
|
||||
report_xyze(diff);
|
||||
report_all_axis_pos(diff);
|
||||
|
||||
TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving());
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) {
|
||||
|
||||
if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
|
||||
// When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves
|
||||
if (fwretract.autoretract_enabled && parser.seen('E') && !(parser.seen('X') || parser.seen('Y') || parser.seen('Z'))) {
|
||||
if (fwretract.autoretract_enabled && parser.seen('E') && !parser.seen("XYZ")) {
|
||||
const float echange = destination.e - current_position.e;
|
||||
// Is this a retract or recover move?
|
||||
if (WITHIN(ABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
|
||||
|
@ -291,12 +291,12 @@ void plan_arc(
|
||||
* Mixing IJ/JK/KI with R will throw an error.
|
||||
*
|
||||
* - R specifies the radius. X or Y (Y or Z / Z or X) is required.
|
||||
* Omitting both XY/YZ/ZX will throw an error.
|
||||
* XY/YZ/ZX must differ from the current XY/YZ/ZX.
|
||||
* Mixing R with IJ/JK/KI will throw an error.
|
||||
* Omitting both XY/YZ/ZX will throw an error.
|
||||
* XY/YZ/ZX must differ from the current XY/YZ/ZX.
|
||||
* Mixing R with IJ/JK/KI will throw an error.
|
||||
*
|
||||
* - P specifies the number of full circles to do
|
||||
* before the specified arc move.
|
||||
* before the specified arc move.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
|
@ -222,7 +222,7 @@ void GCodeParser::parse(char *p) {
|
||||
|
||||
#if ENABLED(GCODE_MOTION_MODES)
|
||||
if (letter == 'G'
|
||||
&& (codenum <= TERN(ARC_SUPPORT, 3, 1) || codenum == 5 || TERN0(G38_PROBE_TARGET, codenum == 38))
|
||||
&& (codenum <= TERN(ARC_SUPPORT, 3, 1) || TERN0(BEZIER_CURVE_SUPPORT, codenum == 5) || TERN0(G38_PROBE_TARGET, codenum == 38))
|
||||
) {
|
||||
motion_mode_codenum = codenum;
|
||||
TERN_(USE_GCODE_SUBCODES, motion_mode_subcode = subcode);
|
||||
|
@ -226,7 +226,7 @@ public:
|
||||
|
||||
// Seen any axis parameter
|
||||
static inline bool seen_axis() {
|
||||
return seen_test('X') || seen_test('Y') || seen_test('Z') || seen_test('E');
|
||||
return seen("XYZE");
|
||||
}
|
||||
|
||||
#if ENABLED(GCODE_QUOTED_STRINGS)
|
||||
|
Reference in New Issue
Block a user