Skip to content

Commit

Permalink
🎨 Cosmetic changes for G28
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 20, 2021
1 parent cce585f commit f2f23e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/feature/tmc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true));
extern millis_t sg_guard_period;
constexpr uint16_t default_sg_guard_duration = 400;

struct slow_homing_t {
struct motion_state_t {
xy_ulong_t acceleration;
#if ENABLED(HAS_CLASSIC_JERK)
xy_float_t jerk_xy;
xy_float_t jerk_state;
#endif
};
#endif
Expand Down
30 changes: 16 additions & 14 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,24 @@

#if ENABLED(IMPROVE_HOMING_RELIABILITY)

slow_homing_t begin_slow_homing() {
slow_homing_t slow_homing{0};
slow_homing.acceleration.set(planner.settings.max_acceleration_mm_per_s2[X_AXIS],
motion_state_t begin_slow_homing() {
motion_state_t motion_state{0};
motion_state.acceleration.set(planner.settings.max_acceleration_mm_per_s2[X_AXIS],
planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100;
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100;
#if HAS_CLASSIC_JERK
slow_homing.jerk_xy = planner.max_jerk;
motion_state.jerk_state = planner.max_jerk;
planner.max_jerk.set(0, 0);
#endif
planner.reset_acceleration_rates();
return slow_homing;
return motion_state;
}

void end_slow_homing(const slow_homing_t &slow_homing) {
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x;
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y;
TERN_(HAS_CLASSIC_JERK, planner.max_jerk = slow_homing.jerk_xy);
void end_slow_homing(const motion_state_t &motion_state) {
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = motion_state.acceleration.x;
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = motion_state.acceleration.y;
TERN_(HAS_CLASSIC_JERK, planner.max_jerk = motion_state.jerk_state);
planner.reset_acceleration_rates();
}

Expand Down Expand Up @@ -289,7 +289,9 @@ void GcodeSuite::G28() {
#endif
#endif

TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing_t slow_homing = begin_slow_homing());
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
motion_state_t saved_motion_state = begin_slow_homing();
#endif

// Always home with tool 0 active
#if HAS_MULTI_HOTEND
Expand All @@ -315,7 +317,7 @@ void GcodeSuite::G28() {

home_delta();

TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state));

#elif ENABLED(AXEL_TPARA)

Expand Down Expand Up @@ -401,7 +403,7 @@ void GcodeSuite::G28() {
if (DISABLED(HOME_Y_BEFORE_X) && doY)
homeaxis(Y_AXIS);

TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state));

// Home Z last if homing towards the bed
#if HAS_Z_AXIS && DISABLED(HOME_Z_FIRST)
Expand Down Expand Up @@ -440,7 +442,7 @@ void GcodeSuite::G28() {

if (idex_is_duplicating()) {

TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing = begin_slow_homing());
TERN_(IMPROVE_HOMING_RELIABILITY, saved_motion_state = begin_slow_homing());

// Always home the 2nd (right) extruder first
active_extruder = 1;
Expand All @@ -459,7 +461,7 @@ void GcodeSuite::G28() {
dual_x_carriage_mode = IDEX_saved_mode;
set_duplication_enabled(IDEX_saved_duplication_state);

TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state));
}

#endif // DUAL_X_CARRIAGE
Expand Down

0 comments on commit f2f23e8

Please sign in to comment.