Move set_all_z_lock to Stepper

This commit is contained in:
Scott Lahteine 2020-05-31 01:03:28 -05:00
parent c9a260ee12
commit a1f3d2f3cd
3 changed files with 17 additions and 28 deletions

View File

@ -47,17 +47,6 @@
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h" #include "../../core/debug_out.h"
inline void set_all_z_lock(const bool lock) {
stepper.set_z_lock(lock);
stepper.set_z2_lock(lock);
#if NUM_Z_STEPPER_DRIVERS >= 3
stepper.set_z3_lock(lock);
#if NUM_Z_STEPPER_DRIVERS >= 4
stepper.set_z4_lock(lock);
#endif
#endif
}
/** /**
* G34: Z-Stepper automatic alignment * G34: Z-Stepper automatic alignment
* *
@ -318,17 +307,7 @@ void GcodeSuite::G34() {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " corrected by ", z_align_move); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " corrected by ", z_align_move);
// Lock all steppers except one // Lock all steppers except one
set_all_z_lock(true); stepper.set_all_z_lock(true, zstepper);
switch (zstepper) {
case 0: stepper.set_z_lock(false); break;
case 1: stepper.set_z2_lock(false); break;
#if NUM_Z_STEPPER_DRIVERS >= 3
case 2: stepper.set_z3_lock(false); break;
#endif
#if NUM_Z_STEPPER_DRIVERS == 4
case 3: stepper.set_z4_lock(false); break;
#endif
}
#if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
// Decreasing accuracy was detected so move was inverted. // Decreasing accuracy was detected so move was inverted.
@ -342,7 +321,7 @@ void GcodeSuite::G34() {
} // for (zstepper) } // for (zstepper)
// Back to normal stepper operations // Back to normal stepper operations
set_all_z_lock(false); stepper.set_all_z_lock(false);
stepper.set_separate_multi_axis(false); stepper.set_separate_multi_axis(false);
if (err_break) break; if (err_break) break;

View File

@ -1644,9 +1644,9 @@ void homeaxis(const AxisEnum axis) {
const float adj = ABS(endstops.z2_endstop_adj); const float adj = ABS(endstops.z2_endstop_adj);
if (adj) { if (adj) {
if (pos_dir ? (endstops.z2_endstop_adj > 0) : (endstops.z2_endstop_adj < 0)) stepper.set_z_lock(true); else stepper.set_z2_lock(true); if (pos_dir ? (endstops.z2_endstop_adj > 0) : (endstops.z2_endstop_adj < 0)) stepper.set_z1_lock(true); else stepper.set_z2_lock(true);
do_homing_move(axis, pos_dir ? -adj : adj); do_homing_move(axis, pos_dir ? -adj : adj);
stepper.set_z_lock(false); stepper.set_z1_lock(false);
stepper.set_z2_lock(false); stepper.set_z2_lock(false);
} }
@ -1657,7 +1657,7 @@ void homeaxis(const AxisEnum axis) {
typedef void (*adjustFunc_t)(const bool); typedef void (*adjustFunc_t)(const bool);
adjustFunc_t lock[] = { adjustFunc_t lock[] = {
stepper.set_z_lock, stepper.set_z2_lock, stepper.set_z3_lock stepper.set_z1_lock, stepper.set_z2_lock, stepper.set_z3_lock
#if NUM_Z_STEPPER_DRIVERS >= 4 #if NUM_Z_STEPPER_DRIVERS >= 4
, stepper.set_z4_lock , stepper.set_z4_lock
#endif #endif
@ -1725,7 +1725,7 @@ void homeaxis(const AxisEnum axis) {
do_homing_move(axis, adj[0] - adj[1]); do_homing_move(axis, adj[0] - adj[1]);
} }
stepper.set_z_lock(false); stepper.set_z1_lock(false);
stepper.set_z2_lock(false); stepper.set_z2_lock(false);
stepper.set_z3_lock(false); stepper.set_z3_lock(false);
#if NUM_Z_STEPPER_DRIVERS >= 4 #if NUM_Z_STEPPER_DRIVERS >= 4

View File

@ -484,7 +484,7 @@ class Stepper {
FORCE_INLINE static void set_y2_lock(const bool state) { locked_Y2_motor = state; } FORCE_INLINE static void set_y2_lock(const bool state) { locked_Y2_motor = state; }
#endif #endif
#if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN)
FORCE_INLINE static void set_z_lock(const bool state) { locked_Z_motor = state; } FORCE_INLINE static void set_z1_lock(const bool state) { locked_Z_motor = state; }
FORCE_INLINE static void set_z2_lock(const bool state) { locked_Z2_motor = state; } FORCE_INLINE static void set_z2_lock(const bool state) { locked_Z2_motor = state; }
#if NUM_Z_STEPPER_DRIVERS >= 3 #if NUM_Z_STEPPER_DRIVERS >= 3
FORCE_INLINE static void set_z3_lock(const bool state) { locked_Z3_motor = state; } FORCE_INLINE static void set_z3_lock(const bool state) { locked_Z3_motor = state; }
@ -492,6 +492,16 @@ class Stepper {
FORCE_INLINE static void set_z4_lock(const bool state) { locked_Z4_motor = state; } FORCE_INLINE static void set_z4_lock(const bool state) { locked_Z4_motor = state; }
#endif #endif
#endif #endif
static inline void set_all_z_lock(const bool lock, const int8_t except=-1) {
set_z1_lock(lock ^ (except == 0));
set_z2_lock(lock ^ (except == 1));
#if NUM_Z_STEPPER_DRIVERS >= 3
set_z3_lock(lock ^ (except == 2));
#if NUM_Z_STEPPER_DRIVERS >= 4
set_z4_lock(lock ^ (except == 3));
#endif
#endif
}
#endif #endif
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)