From a54daeeb39d47f2662ab1e15ffec8be717ed2c2c Mon Sep 17 00:00:00 2001 From: narno2202 <130909513+narno2202@users.noreply.github.com> Date: Mon, 8 Sep 2025 03:38:37 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Optimize=20FT=20Motion=20l?= =?UTF-8?q?oad=20block=20data=20(#27991)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lcd/e3v2/marlinui/ui_status_480x272.cpp | 12 +++---- Marlin/src/module/ft_motion.cpp | 33 ++++++------------- Marlin/src/module/planner.cpp | 2 ++ Marlin/src/module/planner.h | 4 +++ 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index c0b7ba90ec..8c9b51e029 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -290,17 +290,17 @@ void MarlinUI::draw_status_screen() { ); } - uint16_t hx = STATUS_HEATERS_X; + uint16_t shx = STATUS_HEATERS_X; #if HAS_HOTEND - _draw_heater_status(H_E0, hx, STATUS_HEATERS_Y); - hx += STATUS_HEATERS_XSPACE; + _draw_heater_status(H_E0, shx, STATUS_HEATERS_Y); + shx += STATUS_HEATERS_XSPACE; #endif #if HAS_MULTI_HOTEND - _draw_heater_status(H_E1, hx, STATUS_HEATERS_Y); - hx += STATUS_HEATERS_XSPACE; + _draw_heater_status(H_E1, shx, STATUS_HEATERS_Y); + shx += STATUS_HEATERS_XSPACE; #endif #if HAS_HEATED_BED - _draw_heater_status(H_BED, hx, STATUS_HEATERS_Y); + _draw_heater_status(H_BED, shx, STATUS_HEATERS_Y); #endif #if HAS_FAN _draw_fan_status(LCD_PIXEL_WIDTH - STATUS_CHR_WIDTH * 5, STATUS_FAN_Y); diff --git a/Marlin/src/module/ft_motion.cpp b/Marlin/src/module/ft_motion.cpp index 1cc90776d6..e459b244fc 100644 --- a/Marlin/src/module/ft_motion.cpp +++ b/Marlin/src/module/ft_motion.cpp @@ -467,18 +467,8 @@ void FTMotion::loadBlockData(block_t * const current_block) { oneOverLength = 1.0f / totalLength; startPosn = endPosn_prevBlock; - const xyze_pos_t moveDist = LOGICAL_AXIS_ARRAY( - current_block->steps.e * planner.mm_per_step[block_extruder_axis] * (current_block->direction_bits.e ? 1 : -1), - current_block->steps.x * planner.mm_per_step[X_AXIS] * (current_block->direction_bits.x ? 1 : -1), - current_block->steps.y * planner.mm_per_step[Y_AXIS] * (current_block->direction_bits.y ? 1 : -1), - current_block->steps.z * planner.mm_per_step[Z_AXIS] * (current_block->direction_bits.z ? 1 : -1), - current_block->steps.i * planner.mm_per_step[I_AXIS] * (current_block->direction_bits.i ? 1 : -1), - current_block->steps.j * planner.mm_per_step[J_AXIS] * (current_block->direction_bits.j ? 1 : -1), - current_block->steps.k * planner.mm_per_step[K_AXIS] * (current_block->direction_bits.k ? 1 : -1), - current_block->steps.u * planner.mm_per_step[U_AXIS] * (current_block->direction_bits.u ? 1 : -1), - current_block->steps.v * planner.mm_per_step[V_AXIS] * (current_block->direction_bits.v ? 1 : -1), - current_block->steps.w * planner.mm_per_step[W_AXIS] * (current_block->direction_bits.w ? 1 : -1) - ); + + const xyze_pos_t& moveDist = current_block->dist_mm; ratio = moveDist * oneOverLength; @@ -566,17 +556,14 @@ void FTMotion::loadBlockData(block_t * const current_block) { // Watch endstops until the move ends const millis_t move_end_ti = millis() + SEC_TO_MS((FTM_TS) * float(max_intervals + num_samples_shaper_settle() + ((PROP_BATCHES) + 1) * (FTM_BATCH_SIZE)) + (float(FTM_STEPPERCMD_BUFF_SIZE) / float(FTM_STEPPER_FS))); - #define __SET_MOVE_END(A,V) do{ if (V) { axis_move_end_ti.A = move_end_ti; axis_move_dir.A = (V > 0); } }while(0); - #define _SET_MOVE_END(A) __SET_MOVE_END(A, moveDist[_AXIS(A)]) - #if CORE_IS_XY - __SET_MOVE_END(X, moveDist.x + moveDist.y); - __SET_MOVE_END(Y, moveDist.x - moveDist.y); - #else - _SET_MOVE_END(X); - _SET_MOVE_END(Y); - #endif - TERN_(HAS_Z_AXIS, _SET_MOVE_END(Z)); - SECONDARY_AXIS_MAP(_SET_MOVE_END); + #define _SET_MOVE_END(A) do{ \ + if (moveDist.A) { \ + axis_move_end_ti.A = move_end_ti; \ + axis_move_dir.A = moveDist.A > 0; \ + } \ + }while(0); + + LOGICAL_AXIS_MAP(_SET_MOVE_END); } // Generate data points of the trajectory. diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index d9f2e86a90..2918f14bd2 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2097,6 +2097,8 @@ bool Planner::_populate_block( TERN_(BACKLASH_COMPENSATION, backlash.add_correction_steps(dist, dm, block)); } + TERN_(FT_MOTION, block->dist_mm = dist_mm); // Store the distance for all axes in mm for this block + TERN_(HAS_EXTRUDERS, block->steps.e = esteps); block->step_event_count = ( diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index eb8f2ed17f..2695c1768e 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -266,6 +266,10 @@ typedef struct PlannerBlock { AxisBits direction_bits; // Direction bits set for this block, where 1 is negative motion + #if ENABLED(FT_MOTION) + xyze_pos_t dist_mm; // The distance traveled in mm along each axis + #endif + // Advance extrusion #if ENABLED(LIN_ADVANCE) #if ENABLED(SMOOTH_LIN_ADVANCE)