✨ ADVANCE_K per-extruder (#24821)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
committed by
Scott Lahteine
parent
8481264566
commit
0203e32c73
@ -227,7 +227,7 @@ float Planner::previous_nominal_speed;
|
||||
#endif
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
float Planner::extruder_advance_K[EXTRUDERS]; // Initialized by settings.load()
|
||||
float Planner::extruder_advance_K[DISTINCT_E]; // Initialized by settings.load()
|
||||
#endif
|
||||
|
||||
#if HAS_POSITION_FLOAT
|
||||
@ -854,7 +854,7 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
if (block->la_advance_rate) {
|
||||
const float comp = extruder_advance_K[block->extruder] * block->steps.e / block->step_event_count;
|
||||
const float comp = extruder_advance_K[E_INDEX_N(block->extruder)] * block->steps.e / block->step_event_count;
|
||||
block->max_adv_steps = cruise_rate * comp;
|
||||
block->final_adv_steps = final_rate * comp;
|
||||
}
|
||||
@ -2541,7 +2541,7 @@ bool Planner::_populate_block(
|
||||
*
|
||||
* de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
|
||||
*/
|
||||
use_advance_lead = esteps && extruder_advance_K[extruder] && de > 0;
|
||||
use_advance_lead = esteps && extruder_advance_K[E_INDEX_N(extruder)] && de > 0;
|
||||
|
||||
if (use_advance_lead) {
|
||||
float e_D_ratio = (target_float.e - position_float.e) /
|
||||
@ -2557,7 +2557,7 @@ bool Planner::_populate_block(
|
||||
use_advance_lead = false;
|
||||
else {
|
||||
// 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[extruder] * e_D_ratio) * steps_per_mm;
|
||||
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;
|
||||
if (TERN0(LA_DEBUG, accel > max_accel_steps_per_s2))
|
||||
SERIAL_ECHOLNPGM("Acceleration limited.");
|
||||
NOMORE(accel, max_accel_steps_per_s2);
|
||||
@ -2594,7 +2594,7 @@ bool Planner::_populate_block(
|
||||
|
||||
if (use_advance_lead) {
|
||||
// the Bresenham algorithm will convert this step rate into extruder steps
|
||||
block->la_advance_rate = extruder_advance_K[extruder] * block->acceleration_steps_per_s2;
|
||||
block->la_advance_rate = extruder_advance_K[E_INDEX_N(extruder)] * block->acceleration_steps_per_s2;
|
||||
|
||||
// reduce LA ISR frequency by calling it only often enough to ensure that there will
|
||||
// never be more than four extruder steps per call
|
||||
|
@ -459,7 +459,7 @@ class Planner {
|
||||
#endif
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
static float extruder_advance_K[EXTRUDERS];
|
||||
static float extruder_advance_K[DISTINCT_E];
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -118,8 +118,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTRA_LIN_ADVANCE_K)
|
||||
extern float other_extruder_advance_K[EXTRUDERS];
|
||||
#if ENABLED(ADVANCE_K_EXTRA)
|
||||
extern float other_extruder_advance_K[DISTINCT_E];
|
||||
#endif
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
@ -442,7 +442,7 @@ typedef struct SettingsDataStruct {
|
||||
//
|
||||
// LIN_ADVANCE
|
||||
//
|
||||
float planner_extruder_advance_K[_MAX(EXTRUDERS, 1)]; // M900 K planner.extruder_advance_K
|
||||
float planner_extruder_advance_K[DISTINCT_E]; // M900 K planner.extruder_advance_K
|
||||
|
||||
//
|
||||
// HAS_MOTOR_CURRENT_PWM
|
||||
@ -2334,7 +2334,7 @@ void MarlinSettings::postprocess() {
|
||||
// Linear Advance
|
||||
//
|
||||
{
|
||||
float extruder_advance_K[_MAX(EXTRUDERS, 1)];
|
||||
float extruder_advance_K[DISTINCT_E];
|
||||
_FIELD_TEST(planner_extruder_advance_K);
|
||||
EEPROM_READ(extruder_advance_K);
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
@ -3206,12 +3206,17 @@ void MarlinSettings::reset() {
|
||||
//
|
||||
// Linear Advance
|
||||
//
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
EXTRUDER_LOOP() {
|
||||
planner.extruder_advance_K[e] = LIN_ADVANCE_K;
|
||||
TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[e] = LIN_ADVANCE_K);
|
||||
}
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
constexpr float linAdvanceK[] = ADVANCE_K;
|
||||
EXTRUDER_LOOP() {
|
||||
const float a = linAdvanceK[_MAX(e, COUNT(linAdvanceK) - 1)];
|
||||
planner.extruder_advance_K[e] = a;
|
||||
TERN_(ADVANCE_K_EXTRA, other_extruder_advance_K[e] = a);
|
||||
}
|
||||
#else
|
||||
planner.extruder_advance_K[0] = ADVANCE_K;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user