🩹 Fix LA block flag for FTMotion (#28065)

This commit is contained in:
David Buezas 2025-09-23 20:02:44 +02:00 committed by GitHub
parent 25a2a89517
commit 6ff18a942c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 32 deletions

View file

@ -349,7 +349,7 @@
#endif
#if ALL(FT_MOTION, HAS_EXTRUDERS)
#define HAS_FTM_LIN_ADVANCE 1
#define FTM_HAS_LIN_ADVANCE 1
#endif
// Some displays can toggle Adaptive Step Smoothing.

View file

@ -2380,7 +2380,7 @@ bool Planner::_populate_block(
block->steps_per_mm = steps_per_mm;
uint32_t accel;
#if ANY(LIN_ADVANCE, FTM_HAS_LIN_ADVANCE)
bool use_advance_lead = false;
bool use_adv_lead = false;
#endif
if (!ANY_AXIS_MOVES(block)) { // Is this a retract / recover move?
accel = CEIL(settings.retract_acceleration * steps_per_mm); // Convert to: acceleration steps/sec^2
@ -2408,43 +2408,42 @@ bool Planner::_populate_block(
#define MAX_E_JERK(N) TERN(HAS_LINEAR_E_JERK, max_e_jerk[E_INDEX_N(N)], max_jerk.e)
/**
* Use LIN_ADVANCE for blocks if all these are true:
*
* esteps : This is a print move, because we checked for A, B, C steps before.
*
* extruder_advance_K[extruder] : There is an advance factor set for this extruder.
*
* dm.e : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
* Apply Linear/Pressure Advance for blocks when:
* !!esteps : This is a print move, because we checked for A, B, C steps before.
* !!dm.e : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
* ...then...
* !!advanceK : There is an Advance K set so Linear/Pressure Advance is active.
* Check the appropriate K value for Standard or Fixed-Time Motion.
*/
use_advance_lead = esteps && extruder_advance_K[E_INDEX_N(extruder)] && dm.e;
if (esteps && dm.e) {
const bool ftm_active = TERN0(FTM_HAS_LIN_ADVANCE, ftMotion.cfg.active);
const float advK = TERN_(FTM_HAS_LIN_ADVANCE, ftm_active ? ftMotion.cfg.linearAdvK :) extruder_advance_K[E_INDEX_N(extruder)];
if (advK) {
float e_D_ratio = (target_float.e - position_float.e) /
TERN(IS_KINEMATIC, block->millimeters,
SQRT(sq(target_float.x - position_float.x)
+ sq(target_float.y - position_float.y)
+ sq(target_float.z - position_float.z))
);
if (use_advance_lead) {
float e_D_ratio = (target_float.e - position_float.e) /
TERN(IS_KINEMATIC, block->millimeters,
SQRT(sq(target_float.x - position_float.x)
+ sq(target_float.y - position_float.y)
+ sq(target_float.z - position_float.z))
);
// Check for unusual high e_D ratio to detect if a retract move was combined with the last print move due to min. steps per segment. Never execute this with advance!
// This assumes no one will use a retract length of 0mm < retr_length < ~0.2mm and no one will print 100mm wide lines using 3mm filament or 35mm wide lines using 1.75mm filament.
if (e_D_ratio > 3.0f)
use_advance_lead = false;
else {
#if HAS_ROUGH_LIN_ADVANCE
const bool limit_accel = TERN1(HAS_FTM_LIN_ADVANCE, !ftMotion.cfg.active);
if (limit_accel) {
// Stay below an unusually high e_D ratio, a retract move combined with the last print move (due to min steps per segment).
// Never execute this with advance!
// This assumes no one will use a retract length of 0mm < retr_length < ~0.2mm
// and no one will print 100mm wide lines using 3mm filament or 35mm wide lines using 1.75mm filament.
use_adv_lead = e_D_ratio <= 3.0f;
if (use_adv_lead) {
if (TERN0(HAS_ROUGH_LIN_ADVANCE, !ftm_active)) {
// Scale E acceleration so that it will be possible to jump to the advance speed.
const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[E_INDEX_N(extruder)] * e_D_ratio) * steps_per_mm;
const uint32_t max_accel_steps_per_s2 = (MAX_E_JERK(extruder) / (advK * e_D_ratio)) * steps_per_mm;
if (accel > max_accel_steps_per_s2) {
accel = max_accel_steps_per_s2;
if (TERN0(LA_DEBUG, DEBUGGING(INFO))) SERIAL_ECHOLNPGM("Acceleration limited.");
}
}
#endif
}
}
#if ANY(SMOOTH_LIN_ADVANCE, FTM_HAS_LIN_ADVANCE)
block->use_advance_lead = use_advance_lead;
block->use_advance_lead = use_adv_lead;
#endif
}
#endif // LIN_ADVANCE || FTM_HAS_LIN_ADVANCE
@ -2476,7 +2475,7 @@ bool Planner::_populate_block(
#if HAS_ROUGH_LIN_ADVANCE
block->la_advance_rate = 0;
block->la_scaling = 0;
if (use_advance_lead) {
if (use_adv_lead) {
// The Bresenham algorithm will convert this step rate into extruder steps
block->la_advance_rate = extruder_advance_K[E_INDEX_N(extruder)] * block->acceleration_steps_per_s2;

View file

@ -270,9 +270,8 @@ typedef struct PlannerBlock {
xyze_pos_t dist_mm; // The distance traveled in mm along each axis
#endif
// Advance extrusion
#if ANY(SMOOTH_LIN_ADVANCE, FTM_HAS_LIN_ADVANCE)
bool use_advance_lead;
bool use_advance_lead; // Linear / Pressure Advance extrusion
#endif
#if ENABLED(LIN_ADVANCE)