ADVANCE_K per-extruder (#24821)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Giuliano Zaro
2022-10-10 20:49:37 +02:00
committed by Scott Lahteine
parent 8481264566
commit 0203e32c73
13 changed files with 68 additions and 52 deletions

View File

@ -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
//