@@ -89,6 +89,12 @@ xyze_long_t FTMotion::steps = { 0 }; // Step count accumulator.
89
89
90
90
uint32_t FTMotion::interpIdx = 0 ; // Index of current data point being interpolated.
91
91
92
+ #if ENABLED(DISTINCT_E_FACTORS)
93
+ uint8_t FTMotion::block_extruder_axis; // Cached E Axis from last-fetched block
94
+ #else
95
+ constexpr uint8_t FTMotion::block_extruder_axis;
96
+ #endif
97
+
92
98
// Shaping variables.
93
99
#if HAS_FTM_SHAPING
94
100
FTMotion::shaping_t FTMotion::shaping = {
@@ -143,6 +149,12 @@ void FTMotion::loop() {
143
149
continue ;
144
150
}
145
151
loadBlockData (stepper.current_block );
152
+
153
+ // If the endstop is already pressed, endstop interrupts won't invoke
154
+ // endstop_triggered and the move will grind. So check here for a
155
+ // triggered endstop, which shortly marks the block for discard.
156
+ endstops.update ();
157
+
146
158
blockProcRdy = true ;
147
159
// Some kinematics track axis motion in HX, HY, HZ
148
160
#if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX)
@@ -389,6 +401,7 @@ void FTMotion::reset() {
389
401
#endif
390
402
391
403
TERN_ (HAS_EXTRUDERS, e_raw_z1 = e_advanced_z1 = 0 .0f );
404
+ TERN_ (DISTINCT_E_FACTORS, block_extruder_axis = E_AXIS);
392
405
393
406
axis_move_end_ti.reset ();
394
407
}
@@ -453,13 +466,15 @@ void FTMotion::init() {
453
466
454
467
// Load / convert block data from planner to fixed-time control variables.
455
468
void FTMotion::loadBlockData (block_t * const current_block) {
469
+ // Cache the extruder index for this block
470
+ TERN_ (DISTINCT_E_FACTORS, block_extruder_axis = E_AXIS_N (current_block->extruder ));
456
471
457
472
const float totalLength = current_block->millimeters ,
458
473
oneOverLength = 1 .0f / totalLength;
459
474
460
475
startPosn = endPosn_prevBlock;
461
476
const xyze_pos_t moveDist = LOGICAL_AXIS_ARRAY (
462
- current_block->steps .e * planner.mm_per_step [E_AXIS_N (current_block-> extruder ) ] * (current_block->direction_bits .e ? 1 : -1 ),
477
+ current_block->steps .e * planner.mm_per_step [block_extruder_axis ] * (current_block->direction_bits .e ? 1 : -1 ),
463
478
current_block->steps .x * planner.mm_per_step [X_AXIS] * (current_block->direction_bits .x ? 1 : -1 ),
464
479
current_block->steps .y * planner.mm_per_step [Y_AXIS] * (current_block->direction_bits .y ? 1 : -1 ),
465
480
current_block->steps .z * planner.mm_per_step [Z_AXIS] * (current_block->direction_bits .z ? 1 : -1 ),
@@ -568,12 +583,6 @@ void FTMotion::loadBlockData(block_t * const current_block) {
568
583
#endif
569
584
TERN_ (HAS_Z_AXIS, _SET_MOVE_END (Z));
570
585
SECONDARY_AXIS_MAP (_SET_MOVE_END);
571
-
572
- // If the endstop is already pressed, endstop interrupts won't invoke
573
- // endstop_triggered and the move will grind. So check here for a
574
- // triggered endstop, which shortly marks the block for discard.
575
- endstops.update ();
576
-
577
586
}
578
587
579
588
// Generate data points of the trajectory.
@@ -721,7 +730,7 @@ void FTMotion::convertToSteps(const uint32_t idx) {
721
730
#if ENABLED(STEPS_ROUNDING)
722
731
#define TOSTEPS (A,B ) int32_t (trajMod.A[idx] * planner.settings.axis_steps_per_mm[B] + (trajMod.A[idx] < 0 .0f ? -0 .5f : 0 .5f ))
723
732
const xyze_long_t steps_tar = LOGICAL_AXIS_ARRAY (
724
- TOSTEPS (e, E_AXIS_N (stepper. current_block -> extruder ) ), // May be eliminated if guaranteed positive.
733
+ TOSTEPS (e, block_extruder_axis ), // May be eliminated if guaranteed positive.
725
734
TOSTEPS (x, X_AXIS), TOSTEPS (y, Y_AXIS), TOSTEPS (z, Z_AXIS),
726
735
TOSTEPS (i, I_AXIS), TOSTEPS (j, J_AXIS), TOSTEPS (k, K_AXIS),
727
736
TOSTEPS (u, U_AXIS), TOSTEPS (v, V_AXIS), TOSTEPS (w, W_AXIS)
@@ -730,7 +739,7 @@ void FTMotion::convertToSteps(const uint32_t idx) {
730
739
#else
731
740
#define TOSTEPS (A,B ) int32_t (trajMod.A[idx] * planner.settings.axis_steps_per_mm[B]) - steps.A
732
741
xyze_long_t delta = LOGICAL_AXIS_ARRAY (
733
- TOSTEPS (e, E_AXIS_N (stepper. current_block -> extruder ) ),
742
+ TOSTEPS (e, block_extruder_axis ),
734
743
TOSTEPS (x, X_AXIS), TOSTEPS (y, Y_AXIS), TOSTEPS (z, Z_AXIS),
735
744
TOSTEPS (i, I_AXIS), TOSTEPS (j, J_AXIS), TOSTEPS (k, K_AXIS),
736
745
TOSTEPS (u, U_AXIS), TOSTEPS (v, V_AXIS), TOSTEPS (w, W_AXIS)
0 commit comments