Mark axes not-homed with HOME_AFTER_DEACTIVATE (#18907)

This commit is contained in:
swissnorp
2020-08-27 23:05:53 +02:00
committed by GitHub
parent 462d3eeab1
commit a12ac5e175
20 changed files with 40 additions and 44 deletions

View File

@ -1097,17 +1097,16 @@ void prepare_line_to_destination() {
current_position = destination;
}
uint8_t axes_need_homing(uint8_t axis_bits/*=0x07*/) {
#define HOMED_FLAGS TERN(HOME_AFTER_DEACTIVATE, axis_known_position, axis_homed)
// Clear test bits that are homed
if (TEST(axis_bits, X_AXIS) && TEST(HOMED_FLAGS, X_AXIS)) CBI(axis_bits, X_AXIS);
if (TEST(axis_bits, Y_AXIS) && TEST(HOMED_FLAGS, Y_AXIS)) CBI(axis_bits, Y_AXIS);
if (TEST(axis_bits, Z_AXIS) && TEST(HOMED_FLAGS, Z_AXIS)) CBI(axis_bits, Z_AXIS);
uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) {
// 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);
return axis_bits;
}
bool axis_unhomed_error(uint8_t axis_bits/*=0x07*/) {
if ((axis_bits = axes_need_homing(axis_bits))) {
bool homing_needed_error(uint8_t axis_bits/*=0x07*/) {
if ((axis_bits = axes_should_home(axis_bits))) {
PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
char msg[strlen_P(home_first)+1];
sprintf_P(msg, home_first,

View File

@ -40,8 +40,7 @@ constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; }
FORCE_INLINE void set_all_unhomed() { axis_homed = 0; }
FORCE_INLINE void set_all_unknown() { axis_known_position = 0; }
FORCE_INLINE void set_all_unhomed() { axis_homed = axis_known_position = 0; }
FORCE_INLINE bool homing_needed() {
return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)();
@ -239,22 +238,18 @@ void do_z_clearance(const float &zclear, const bool z_known=true, const bool rai
//
// Homing
//
uint8_t axes_need_homing(uint8_t axis_bits=0x07);
bool axis_unhomed_error(uint8_t axis_bits=0x07);
void homeaxis(const AxisEnum axis);
void set_axis_is_at_home(const AxisEnum axis);
void set_axis_never_homed(const AxisEnum axis);
uint8_t axes_should_home(uint8_t axis_bits=0x07);
bool homing_needed_error(uint8_t axis_bits=0x07);
#if ENABLED(NO_MOTION_BEFORE_HOMING)
#define MOTION_CONDITIONS (IsRunning() && !axis_unhomed_error())
#define MOTION_CONDITIONS (IsRunning() && !homing_needed_error())
#else
#define MOTION_CONDITIONS IsRunning()
#endif
void set_axis_is_at_home(const AxisEnum axis);
void set_axis_never_homed(const AxisEnum axis);
void homeaxis(const AxisEnum axis);
/**
* Workspace offsets
*/

View File

@ -359,7 +359,7 @@ bool Probe::set_deployed(const bool deploy) {
do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
#if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
if (axis_unhomed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) {
if (homing_needed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) {
SERIAL_ERROR_MSG(STR_STOP_UNHOMED);
stop();
return true;

View File

@ -840,12 +840,13 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
//
// Axis steppers enable / disable macros
//
#define FORGET_AXIS(A) TERN(HOME_AFTER_DEACTIVATE, set_axis_never_homed(A), CBI(axis_known_position, A))
#define ENABLE_AXIS_X() do{ ENABLE_STEPPER_X(); ENABLE_STEPPER_X2(); }while(0)
#define DISABLE_AXIS_X() do{ DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); CBI(axis_known_position, X_AXIS); }while(0)
#define DISABLE_AXIS_X() do{ DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); FORGET_AXIS(X_AXIS); }while(0)
#define ENABLE_AXIS_Y() do{ ENABLE_STEPPER_Y(); ENABLE_STEPPER_Y2(); }while(0)
#define DISABLE_AXIS_Y() do{ DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); CBI(axis_known_position, Y_AXIS); }while(0)
#define DISABLE_AXIS_Y() do{ DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); FORGET_AXIS(Y_AXIS); }while(0)
#define ENABLE_AXIS_Z() do{ ENABLE_STEPPER_Z(); ENABLE_STEPPER_Z2(); ENABLE_STEPPER_Z3(); ENABLE_STEPPER_Z4(); }while(0)
@ -854,7 +855,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#else
#define Z_RESET()
#endif
#define DISABLE_AXIS_Z() do{ DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); CBI(axis_known_position, Z_AXIS); Z_RESET(); }while(0)
#define DISABLE_AXIS_Z() do{ DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); FORGET_AXIS(Z_AXIS); Z_RESET(); }while(0)
//
// Extruder steppers enable / disable macros

View File

@ -174,7 +174,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
grabpos = mpe_settings.parking_xpos[new_tool] + (new_tool ? mpe_settings.grab_distance : -mpe_settings.grab_distance),
offsetcompensation = TERN0(HAS_HOTEND_OFFSET, hotend_offset[active_extruder].x * mpe_settings.compensation_factor);
if (axis_unhomed_error(_BV(X_AXIS))) return;
if (homing_needed_error(_BV(X_AXIS))) return;
/**
* Z Lift and Nozzle Offset shift ar defined in caller method to work equal with any Multi Hotend realization