@@ -89,6 +89,8 @@ 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
+ uint8_t FTMotion::current_extruder_idx = 0 ; // Cached extruder index.
93
+
92
94
// Shaping variables.
93
95
#if HAS_FTM_SHAPING
94
96
FTMotion::shaping_t FTMotion::shaping = {
@@ -391,6 +393,8 @@ void FTMotion::reset() {
391
393
TERN_ (HAS_EXTRUDERS, e_raw_z1 = e_advanced_z1 = 0 .0f );
392
394
393
395
axis_move_end_ti.reset ();
396
+
397
+ current_extruder_idx = 0 ;
394
398
}
395
399
396
400
// Private functions.
@@ -454,6 +458,9 @@ void FTMotion::init() {
454
458
// Load / convert block data from planner to fixed-time control variables.
455
459
void FTMotion::loadBlockData (block_t * const current_block) {
456
460
461
+ // Cache the extruder index for this block
462
+ current_extruder_idx = current_block->extruder ;
463
+
457
464
const float totalLength = current_block->millimeters ,
458
465
oneOverLength = 1 .0f / totalLength;
459
466
@@ -721,7 +728,7 @@ void FTMotion::convertToSteps(const uint32_t idx) {
721
728
#if ENABLED(STEPS_ROUNDING)
722
729
#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
730
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.
731
+ TOSTEPS (e, E_AXIS_N (current_extruder_idx )), // May be eliminated if guaranteed positive.
725
732
TOSTEPS (x, X_AXIS), TOSTEPS (y, Y_AXIS), TOSTEPS (z, Z_AXIS),
726
733
TOSTEPS (i, I_AXIS), TOSTEPS (j, J_AXIS), TOSTEPS (k, K_AXIS),
727
734
TOSTEPS (u, U_AXIS), TOSTEPS (v, V_AXIS), TOSTEPS (w, W_AXIS)
@@ -730,7 +737,7 @@ void FTMotion::convertToSteps(const uint32_t idx) {
730
737
#else
731
738
#define TOSTEPS (A,B ) int32_t (trajMod.A[idx] * planner.settings.axis_steps_per_mm[B]) - steps.A
732
739
xyze_long_t delta = LOGICAL_AXIS_ARRAY (
733
- TOSTEPS (e, E_AXIS_N (stepper. current_block -> extruder )),
740
+ TOSTEPS (e, E_AXIS_N (current_extruder_idx )),
734
741
TOSTEPS (x, X_AXIS), TOSTEPS (y, Y_AXIS), TOSTEPS (z, Z_AXIS),
735
742
TOSTEPS (i, I_AXIS), TOSTEPS (j, J_AXIS), TOSTEPS (k, K_AXIS),
736
743
TOSTEPS (u, U_AXIS), TOSTEPS (v, V_AXIS), TOSTEPS (w, W_AXIS)
0 commit comments