Adjust axis homed / trusted methods (#20323)

This commit is contained in:
Scott Lahteine
2020-11-29 19:06:40 -06:00
committed by GitHub
parent 0f9ac3026d
commit 8fd8772a6f
22 changed files with 118 additions and 149 deletions

View File

@ -79,11 +79,11 @@
* Flags that each linear axis was homed.
* XYZ on cartesian, ABC on delta, ABZ on SCARA.
*
* axis_known_position
* Flags that the position is known in each linear axis. Set when homed.
* axis_trusted
* Flags that the position is trusted in each linear axis. Set when homed.
* Cleared whenever a stepper powers off, potentially losing its position.
*/
uint8_t axis_homed, axis_known_position; // = 0
uint8_t axis_homed, axis_trusted; // = 0
// Relative Mode. Enable with G91, disable with G90.
bool relative_mode; // = false;
@ -506,8 +506,8 @@ void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRat
do_blocking_move_to(raw.x, raw.y, z, fr_mm_s);
}
void do_z_clearance(const float &zclear, const bool z_known/*=true*/, const bool raise_on_unknown/*=true*/, const bool lower_allowed/*=false*/) {
const bool rel = raise_on_unknown && !z_known;
void do_z_clearance(const float &zclear, const bool z_trusted/*=true*/, const bool raise_on_untrusted/*=true*/, const bool lower_allowed/*=false*/) {
const bool rel = raise_on_untrusted && !z_trusted;
float zdest = zclear + (rel ? current_position.z : 0.0f);
if (!lower_allowed) NOLESS(zdest, current_position.z);
do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), MMM_TO_MMS(TERN(HAS_BED_PROBE, Z_PROBE_SPEED_FAST, HOMING_FEEDRATE_Z)));
@ -649,7 +649,7 @@ void restore_feedrate_and_scaling() {
constexpr xy_pos_t offs{0};
#endif
if (TERN1(IS_SCARA, TEST(axis_homed, X_AXIS) && TEST(axis_homed, Y_AXIS))) {
if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) {
const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y);
if (dist_2 > delta_max_radius_2)
target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66
@ -657,7 +657,7 @@ void restore_feedrate_and_scaling() {
#else
if (TEST(axis_homed, X_AXIS)) {
if (axis_was_homed(X_AXIS)) {
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_X)
NOLESS(target.x, soft_endstop.min.x);
#endif
@ -666,7 +666,7 @@ void restore_feedrate_and_scaling() {
#endif
}
if (TEST(axis_homed, Y_AXIS)) {
if (axis_was_homed(Y_AXIS)) {
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
NOLESS(target.y, soft_endstop.min.y);
#endif
@ -677,7 +677,7 @@ void restore_feedrate_and_scaling() {
#endif
if (TEST(axis_homed, Z_AXIS)) {
if (axis_was_homed(Z_AXIS)) {
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
NOLESS(target.z, soft_endstop.min.z);
#endif
@ -1124,10 +1124,11 @@ void prepare_line_to_destination() {
}
uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) {
#define SHOULD_HOME(A) TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(A)
// Clear test bits that are trusted
if (TEST(axis_bits, X_AXIS) && TEST(axis_homed, X_AXIS)) CBI(axis_bits, X_AXIS);
if (TEST(axis_bits, Y_AXIS) && TEST(axis_homed, Y_AXIS)) CBI(axis_bits, Y_AXIS);
if (TEST(axis_bits, Z_AXIS) && TEST(axis_homed, Z_AXIS)) CBI(axis_bits, Z_AXIS);
if (TEST(axis_bits, X_AXIS) && SHOULD_HOME(X_AXIS)) CBI(axis_bits, X_AXIS);
if (TEST(axis_bits, Y_AXIS) && SHOULD_HOME(Y_AXIS)) CBI(axis_bits, Y_AXIS);
if (TEST(axis_bits, Z_AXIS) && SHOULD_HOME(Z_AXIS)) CBI(axis_bits, Z_AXIS);
return axis_bits;
}
@ -1388,7 +1389,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
*
* DELTA should wait until all homing is done before setting the XYZ
* current_position to home, because homing is a single operation.
* In the case where the axis positions are already known and previously
* In the case where the axis positions are trusted and previously
* homed, DELTA could home to X or Y individually by moving either one
* to the center. However, homing Z always homes XY and Z.
*
@ -1401,8 +1402,8 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
void set_axis_is_at_home(const AxisEnum axis) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", axis_codes[axis], ")");
SBI(axis_known_position, axis);
SBI(axis_homed, axis);
set_axis_trusted(axis);
set_axis_homed(axis);
#if ENABLED(DUAL_X_CARRIAGE)
if (axis == X_AXIS && (active_extruder == 1 || dual_x_carriage_mode == DXC_DUPLICATION_MODE)) {
@ -1462,8 +1463,8 @@ void set_axis_is_at_home(const AxisEnum axis) {
void set_axis_never_homed(const AxisEnum axis) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", axis_codes[axis], ")");
CBI(axis_known_position, axis);
CBI(axis_homed, axis);
set_axis_untrusted(axis);
set_axis_unhomed(axis);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", axis_codes[axis], ")");