Skip to content
4 changes: 2 additions & 2 deletions Marlin/src/module/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ void Endstops::update() {
#define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX)
#endif

#define AXIS_IS_MOVING(A) TERN(FT_MOTION, ftMotion, stepper).axis_is_moving(A##_REAL)
#define AXIS_DIR_REV(A) !TERN(FT_MOTION, ftMotion, stepper).axis_direction(A##_REAL)
#define AXIS_IS_MOVING(A) stepper.axis_is_moving(A##_REAL)
#define AXIS_DIR_REV(A) !stepper.axis_direction(A##_REAL)

#if ENABLED(G38_PROBE_TARGET)
// For G38 moves check the probe's pin for ALL movement
Expand Down
21 changes: 7 additions & 14 deletions Marlin/src/module/ft_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ void ft_config_t::update_shaping_params() { TERN_(HAS_FTM_SHAPING, ftMotion.upda
ft_config_t FTMotion::cfg;
bool FTMotion::busy; // = false

AxisBits FTMotion::moving_axis_flags, // These axes are moving in the planner block being processed
FTMotion::axis_move_dir; // ...in these directions

// Private variables.

// Block data variables.
Expand Down Expand Up @@ -252,7 +249,7 @@ void FTMotion::reset() {
TERN_(HAS_EXTRUDERS, prev_traj_e = 0.0f); // Reset linear advance variables.
TERN_(DISTINCT_E_FACTORS, block_extruder_axis = E_AXIS);

moving_axis_flags.reset();
stepper.axis_did_move.reset();
last_target_traj.reset();
#if HAS_FTM_DIR_CHANGE_HOLD
last_traj_dir.reset();
Expand Down Expand Up @@ -394,11 +391,6 @@ bool FTMotion::plan_next_block() {
recovery.info.current_position = current_block->start_position;
#endif

// Some kinematics track axis motion in RX, RY, RZ
TERN_(HAS_REAL_X, stepper.last_direction_bits.rx = current_block->direction_bits.rx);
TERN_(HAS_REAL_Y, stepper.last_direction_bits.ry = current_block->direction_bits.ry);
TERN_(HAS_REAL_Z, stepper.last_direction_bits.rz = current_block->direction_bits.rz);

// Cache the extruder index / axis for this block
#if ANY(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER)
stepper.stepper_extruder = current_block->extruder;
Expand All @@ -420,16 +412,17 @@ bool FTMotion::plan_next_block() {

TERN_(FTM_HAS_LIN_ADVANCE, use_advance_lead = current_block->use_advance_lead);

axis_move_dir = current_block->direction_bits;
// Update stepper direction bits for the next block whatever printer type.
stepper.last_direction_bits = current_block->direction_bits;

// Set moving flags for axes that have movement in this block
// For CORE kinematics: moveDist.x/.y/.z contain motor distances (a/b/c)
// HEAD movement flags need to be inferred: if either motor moves, the head moves
#define _SET_MOVE_END(A) moving_axis_flags.A = bool(moveDist.A);
#define _SET_MOVE_END(A) stepper.axis_did_move.A = bool(moveDist.A);
LOGICAL_AXIS_MAP(_SET_MOVE_END);
TERN_(HAS_REAL_X, moving_axis_flags.rx = bool(moveDist.real.x));
TERN_(HAS_REAL_Y, moving_axis_flags.ry = bool(moveDist.real.y));
TERN_(HAS_REAL_Z, moving_axis_flags.rz = bool(moveDist.real.z));
TERN_(HAS_REAL_X, stepper.axis_did_move.rx = bool(moveDist.real.x));
TERN_(HAS_REAL_Y, stepper.axis_did_move.ry = bool(moveDist.real.y));
TERN_(HAS_REAL_Z, stepper.axis_did_move.rz = bool(moveDist.real.z));

// If the endstop is already pressed, endstop interrupts won't invoke
// endstop_triggered and the move will grind. So check here for a
Expand Down
10 changes: 0 additions & 10 deletions Marlin/src/module/ft_motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,6 @@ class FTMotion {
reset();
}

static AxisBits moving_axis_flags, // These axes are moving in the planner block being processed
axis_move_dir; // ...in these directions

// Public methods
static void init();
static void loop(); // Controller main, to be invoked from non-isr task.
Expand Down Expand Up @@ -300,13 +297,6 @@ class FTMotion {
static TrajectoryType getTrajectoryType() { return TERN(FTM_POLYS, trajectoryType, TrajectoryType::TRAPEZOIDAL); }
static FSTR_P getTrajectoryName();

FORCE_INLINE static bool axis_is_moving(const AxisEnum real) {
return cfg.active ? moving_axis_flags[real] : TERN0(HAS_STANDARD_MOTION, stepper.axis_is_moving(real));
}
FORCE_INLINE static bool axis_direction(const AxisEnum real) {
return cfg.active ? axis_move_dir[real] : stepper.last_direction_bits[real];
}

// A frame of the stepping plan
static stepping_t stepping;

Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ stepper_flags_t Stepper::axis_enabled; // {0}

block_t* Stepper::current_block; // (= nullptr) A pointer to the block currently being traced

#if HAS_STANDARD_MOTION
AxisBits Stepper::axis_did_move; // = 0
#endif
AxisBits Stepper::axis_did_move; // = 0

AxisBits Stepper::last_direction_bits; // = 0

bool Stepper::abort_current_block;
Expand Down
36 changes: 17 additions & 19 deletions Marlin/src/module/stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,7 @@ class Stepper {

static AxisBits last_direction_bits; // The last set of directions applied to all axes

#if HAS_STANDARD_MOTION
static AxisBits axis_did_move; // Last Movement in the given direction is not null, as computed when the last movement was fetched from planner
#endif
static AxisBits axis_did_move; // Last Movement in the given direction is not null, as computed when the last movement was fetched from planner

static bool abort_current_block; // Signals to the stepper that current block should be aborted

Expand Down Expand Up @@ -642,28 +640,28 @@ class Stepper {
// Report the positions of the steppers, in steps
static void report_a_position(const xyz_long_t &pos);
static void report_positions();

// Discard current block and free any resources
FORCE_INLINE static void discard_current_block() {
#if ENABLED(DIRECT_STEPPING)
if (current_block->is_page()) page_manager.free_page(current_block->page_idx);
#endif
current_block = nullptr;
TERN_(HAS_STANDARD_MOTION, axis_did_move.reset());
planner.release_current_block();
TERN_(HAS_ROUGH_LIN_ADVANCE, la_interval = nextAdvanceISR = LA_ADV_NEVER);
}


#if HAS_STANDARD_MOTION
// Discard current block and free any resources
FORCE_INLINE static void discard_current_block() {
#if ENABLED(DIRECT_STEPPING)
if (current_block->is_page()) page_manager.free_page(current_block->page_idx);
#endif
current_block = nullptr;
axis_did_move.reset();
planner.release_current_block();
TERN_(HAS_ROUGH_LIN_ADVANCE, la_interval = nextAdvanceISR = LA_ADV_NEVER);
}
#endif

// Quickly stop all steppers
FORCE_INLINE static void quick_stop() { abort_current_block = true; }

// The direction of a single motor and/or real axis. A true result indicates forward or positive motion.
FORCE_INLINE static bool axis_direction(const AxisEnum real) { return last_direction_bits[real]; }

#if HAS_STANDARD_MOTION
// The last segment moved on the specified motor and/or real axis.
FORCE_INLINE static bool axis_is_moving(const AxisEnum real) { return axis_did_move[real]; }
#endif
// The last segment moved on the specified motor and/or real axis.
FORCE_INLINE static bool axis_is_moving(const AxisEnum real) { return axis_did_move[real]; }

// Handle a triggered endstop
static void endstop_triggered(const AxisEnum axis);
Expand Down
Loading