From 56c32f5360b166d51ee8f0c38efa2381a684e6a4 Mon Sep 17 00:00:00 2001 From: GMagician <3684609+GMagician@users.noreply.github.com> Date: Thu, 29 Sep 2022 22:45:10 +0200 Subject: [PATCH 1/6] Lin Advance K per extruder --- Marlin/Configuration_adv.h | 14 +++++++------- Marlin/src/inc/SanityCheck.h | 12 ++++++++++-- Marlin/src/module/settings.cpp | 5 +++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index cb327e9b730d..79c6f0beadab 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1,4 +1,4 @@ -/** +/** * Marlin 3D Printer Firmware * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * @@ -2064,12 +2064,12 @@ */ //#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) - //#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900. - #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed - //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. - //#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. - //#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. - //#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz. + //#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900. + #define LIN_ADVANCE_K { 0.22 } // Unit: mm compression per 1mm/s extruder speed + //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. + //#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. + //#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. + //#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz. #endif // @section leveling diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index e9675feaf1d4..c237b823e68c 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1328,10 +1328,18 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Linear Advance 1.5 - Check K value range */ #if ENABLED(LIN_ADVANCE) + constexpr float lak[] = LIN_ADVANCE_K; + static_assert(COUNT(lak) == EXTRUDERS, "LIN_ADVANCE_K must be an array EXTRUDERS long."); static_assert( - WITHIN(LIN_ADVANCE_K, 0, 10), - "LIN_ADVANCE_K must be a value from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)." + WITHIN(lak[0], 0, 10), + "LIN_ADVANCE_K must be values from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)." ); + #if EXTRUDERS > 1 + static_assert( + WITHIN(lak[1], 0, 10), + "LIN_ADVANCE_K must be values from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)." + ); + #endif #if ENABLED(S_CURVE_ACCELERATION) && DISABLED(EXPERIMENTAL_SCURVE) #error "LIN_ADVANCE and S_CURVE_ACCELERATION may not play well together! Enable EXPERIMENTAL_SCURVE to continue." #elif ENABLED(DIRECT_STEPPING) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 2b6a98b0452f..6aa08ba2daed 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3208,9 +3208,10 @@ void MarlinSettings::reset() { // #if ENABLED(LIN_ADVANCE) + constexpr float linAdvanceK[] = LIN_ADVANCE_K; EXTRUDER_LOOP() { - planner.extruder_advance_K[e] = LIN_ADVANCE_K; - TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[e] = LIN_ADVANCE_K); + planner.extruder_advance_K[e] = linAdvanceK[e]; + TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[e] = linAdvanceK[e]); } #endif From 1b0e0c44ae39049191e57c44c47967e09dae01ac Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Oct 2022 17:06:16 -0500 Subject: [PATCH 2/6] apply DISTINCT_E_FACTORS --- Marlin/Configuration_adv.h | 10 +++++++--- Marlin/src/gcode/feature/advance/M900.cpp | 22 ++++++++++----------- Marlin/src/inc/Conditionals_adv.h | 12 ++++++++++++ Marlin/src/inc/SanityCheck.h | 19 ++++++++---------- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 6 +++--- Marlin/src/lcd/menu/menu_advanced.cpp | 12 ++++++------ Marlin/src/lcd/menu/menu_tune.cpp | 4 ++-- Marlin/src/module/planner.cpp | 10 +++++----- Marlin/src/module/planner.h | 2 +- Marlin/src/module/settings.cpp | 24 +++++++++++++---------- Marlin/src/module/tool_change.cpp | 2 +- buildroot/tests/mega2560 | 2 +- buildroot/tests/rambo | 4 ++-- 14 files changed, 74 insertions(+), 57 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 79c6f0beadab..1566034ab374 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1,4 +1,4 @@ -/** +/** * Marlin 3D Printer Firmware * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * @@ -2064,8 +2064,12 @@ */ //#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) - //#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900. - #define LIN_ADVANCE_K { 0.22 } // Unit: mm compression per 1mm/s extruder speed + #if ENABLED(DISTINCT_E_FACTORS) + #define ADVANCE_K { 0.22 } // (mm) Compression length per 1mm/s extruder speed + #else + #define ADVANCE_K 0.22 // (mm) Compression length per 1mm/s extruder speed + #endif + //#define ADVANCE_K_EXTRA // Add a second linear advance constant, configurable with M900. //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. //#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. //#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index db09faa88310..50d968627b6f 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -27,8 +27,8 @@ #include "../../gcode.h" #include "../../../module/planner.h" -#if ENABLED(EXTRA_LIN_ADVANCE_K) - float other_extruder_advance_K[EXTRUDERS]; +#if ENABLED(ADVANCE_K_EXTRA) + float other_extruder_advance_K[DISTINCT_E]; uint8_t lin_adv_slot = 0; #endif @@ -36,8 +36,8 @@ * M900: Get or Set Linear Advance K-factor * T Which tool to address * K Set current advance K factor (Slot 0). - * L Set secondary advance K factor (Slot 1). Requires EXTRA_LIN_ADVANCE_K. - * S<0/1> Activate slot 0 or 1. Requires EXTRA_LIN_ADVANCE_K. + * L Set secondary advance K factor (Slot 1). Requires ADVANCE_K_EXTRA. + * S<0/1> Activate slot 0 or 1. Requires ADVANCE_K_EXTRA. */ void GcodeSuite::M900() { @@ -58,12 +58,12 @@ void GcodeSuite::M900() { } #endif - float &kref = planner.extruder_advance_K[tool_index], newK = kref; + float &kref = planner.extruder_advance_K[E_INDEX_N(tool_index)], newK = kref; const float oldK = newK; - #if ENABLED(EXTRA_LIN_ADVANCE_K) + #if ENABLED(ADVANCE_K_EXTRA) - float &lref = other_extruder_advance_K[tool_index]; + float &lref = other_extruder_advance_K[E_INDEX_N(tool_index)]; const bool old_slot = TEST(lin_adv_slot, tool_index), // The tool's current slot (0 or 1) new_slot = parser.boolval('S', old_slot); // The passed slot (default = current) @@ -111,9 +111,9 @@ void GcodeSuite::M900() { if (!parser.seen_any()) { - #if ENABLED(EXTRA_LIN_ADVANCE_K) + #if ENABLED(ADVANCE_K_EXTRA) - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 SERIAL_ECHOLNPGM("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")"); #else EXTRUDER_LOOP() { @@ -127,7 +127,7 @@ void GcodeSuite::M900() { #else SERIAL_ECHO_START(); - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 SERIAL_ECHOLNPGM("Advance K=", planner.extruder_advance_K[0]); #else SERIAL_ECHOPGM("Advance K"); @@ -145,7 +145,7 @@ void GcodeSuite::M900() { void GcodeSuite::M900_report(const bool forReplay/*=true*/) { report_heading(forReplay, F(STR_LINEAR_ADVANCE)); - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 report_echo_start(forReplay); SERIAL_ECHOLNPGM(" M900 K", planner.extruder_advance_K[0]); #else diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 7d3306ffb892..5b0bec6caee7 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1067,3 +1067,15 @@ #if ANY(DISABLE_INACTIVE_X, DISABLE_INACTIVE_Y, DISABLE_INACTIVE_Z, DISABLE_INACTIVE_I, DISABLE_INACTIVE_J, DISABLE_INACTIVE_K, DISABLE_INACTIVE_U, DISABLE_INACTIVE_V, DISABLE_INACTIVE_W, DISABLE_INACTIVE_E) #define HAS_DISABLE_INACTIVE_AXIS 1 #endif + +// *** Temporary compatibility for CI *** +#ifdef LIN_ADVANCE_K + #if ENABLED(DISTINCT_E_FACTORS) + #define ADVANCE_K { LIN_ADVANCE_K } + #else + #define ADVANCE_K LIN_ADVANCE_K + #endif +#endif +#if ENABLED(EXTRA_LIN_ADVANCE_K) + #define ADVANCE_K_EXTRA +#endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index c237b823e68c..08beb5e08266 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1328,17 +1328,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Linear Advance 1.5 - Check K value range */ #if ENABLED(LIN_ADVANCE) - constexpr float lak[] = LIN_ADVANCE_K; - static_assert(COUNT(lak) == EXTRUDERS, "LIN_ADVANCE_K must be an array EXTRUDERS long."); - static_assert( - WITHIN(lak[0], 0, 10), - "LIN_ADVANCE_K must be values from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)." - ); - #if EXTRUDERS > 1 - static_assert( - WITHIN(lak[1], 0, 10), - "LIN_ADVANCE_K must be values from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)." - ); + #if DISTINCT_E > 1 + constexpr float lak[] = ADVANCE_K; + static_assert(COUNT(lak) < DISTINCT_E, "The ADVANCE_K array has too many elements (i.e., more than " STRINGIFY(DISTINCT_E) ")."); + #define _LIN_ASSERT(N) static_assert(N >= COUNT(lak) || WITHIN(lak[N], 0, 10), "ADVANCE_K values must be from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."); + REPEAT(DISTINCT_E, _LIN_ASSERT) + #undef _LIN_ASSERT + #else + static_assert(WITHIN(ADVANCE_K, 0, 10), "ADVANCE_K must be from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."); #endif #if ENABLED(S_CURVE_ACCELERATION) && DISABLED(EXPERIMENTAL_SCURVE) #error "LIN_ADVANCE and S_CURVE_ACCELERATION may not play well together! Enable EXPERIMENTAL_SCURVE to continue." diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index df758da61786..9a1668ece38b 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -2772,7 +2772,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(LIN_ADVANCE) case ADVANCED_LA: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccelerated, F("Lin Advance Kp")); + Draw_Menu_Item(row, ICON_MaxAccelerated, F("Lin Advance K")); Draw_Float(planner.extruder_advance_K[0], row, false, 100); } else diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index f4d02d8cca4a..967fb1021d19 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -712,17 +712,17 @@ namespace ExtUI { #if ENABLED(POWER_LOSS_RECOVERY) bool getPowerLossRecoveryEnabled() { return recovery.enabled; } - void setPowerLossRecoveryEnabled(const bool value) { recovery.enable(value); } + void setPowerLossRecoveryEnabled(const bool value) { recovery.enable(value); } #endif #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t extruder) { - return (extruder < EXTRUDERS) ? planner.extruder_advance_K[extruder - E0] : 0; + return (extruder < EXTRUDERS) ? planner.extruder_advance_K[E_INDEX_N(extruder - E0)] : 0; } void setLinearAdvance_mm_mm_s(const_float_t value, const extruder_t extruder) { if (extruder < EXTRUDERS) - planner.extruder_advance_K[extruder - E0] = constrain(value, 0, 10); + planner.extruder_advance_K[E_INDEX_N(extruder - E0)] = constrain(value, 0, 10); } #endif diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index e79fe55938e3..19e38820184d 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -109,9 +109,9 @@ void menu_backlash(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #if ENABLED(LIN_ADVANCE) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER + #else EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif @@ -687,11 +687,11 @@ void menu_advanced_settings() { #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE) SUBMENU(MSG_FILAMENT, menu_advanced_filament); #elif ENABLED(LIN_ADVANCE) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER - LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10); + #else + EXTRUDER_LOOP() + EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif #endif diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index bc5200196717..79d87bb6ca92 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -210,9 +210,9 @@ void menu_tune() { // Advance K: // #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER + #else EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 6ef1ed6c2848..dee86cad90ee 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -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 diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 09afee7db1b5..ad424deb772b 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -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 /** diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6aa08ba2daed..54ff9bde76d7 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -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[_MAX(DISTINCT_E, 1)]; // 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[_MAX(DISTINCT_E, 1)]; _FIELD_TEST(planner_extruder_advance_K); EEPROM_READ(extruder_advance_K); #if ENABLED(LIN_ADVANCE) @@ -3206,13 +3206,17 @@ void MarlinSettings::reset() { // // Linear Advance // - #if ENABLED(LIN_ADVANCE) - constexpr float linAdvanceK[] = LIN_ADVANCE_K; - EXTRUDER_LOOP() { - planner.extruder_advance_K[e] = linAdvanceK[e]; - TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[e] = linAdvanceK[e]); - } + #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 // diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 0ff0856ddd1f..6efd99dd4cf9 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1488,7 +1488,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #endif // Migrate Linear Advance K factor to the new extruder - TERN_(LIN_ADVANCE, planner.extruder_advance_K[active_extruder] = planner.extruder_advance_K[migration_extruder]); + TERN_(LIN_ADVANCE, planner.extruder_advance_K[E_INDEX_N(active_extruder)] = planner.extruder_advance_K[E_INDEX_N(migration_extruder)]); // Perform the tool change tool_change(migration_extruder); diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 9cb50688cdea..838d29939829 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -30,7 +30,7 @@ opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATU REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES MEDIA_MENU_AT_TOP \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE CANCEL_OBJECTS SOUND_MENU_ITEM \ - MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \ + MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE ADVANCE_K_EXTRA QUICK_HOME \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ ENCODER_NOISE_FILTER BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE ..." "$3" diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index b5d6491d2870..de6cdc71297b 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -34,7 +34,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND POWER_OFF_WAIT_FOR_COOLDOWN \ POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \ - SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ + SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE ADVANCE_K_EXTRA \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL opt_add DEBUG_POWER_LOSS_RECOVERY exec_test $1 $2 "RAMBO | EXTRUDERS 2 | CHAR LCD + SD | FIX Probe | ABL-Linear | Advanced Pause | PLR | LEDs ..." "$3" @@ -93,7 +93,7 @@ opt_set MOTHERBOARD BOARD_MINIRAMBO \ opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER \ SDSUPPORT PCA9632 SOUND_MENU_ITEM GCODE_REPEAT_MARKERS \ AUTO_BED_LEVELING_LINEAR PROBE_MANUALLY LCD_BED_LEVELING \ - LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ + LIN_ADVANCE ADVANCE_K_EXTRA \ INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT EXPERIMENTAL_I2CBUS M100_FREE_MEMORY_WATCHER \ NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE \ ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE ADVANCED_PAUSE_CONTINUOUS_PURGE FILAMENT_LOAD_UNLOAD_GCODES \ From f61dc33708342e0eec6b09c4d8573c5e38e19055 Mon Sep 17 00:00:00 2001 From: GMagician <3684609+GMagician@users.noreply.github.com> Date: Sun, 2 Oct 2022 20:57:11 +0200 Subject: [PATCH 3/6] Typo fix --- Marlin/src/inc/Conditionals_LCD.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 5e23cedc4d38..aa0086a0b8ee 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -994,7 +994,7 @@ * with shared motion and temperature settings. * * DISTINCT_E is the number of distinguished extruders. By default this - * well be 1 which indicates all extruders share the same settings. + * will be 1 which indicates all extruders share the same settings. * * E_INDEX_N(E) should be used to get the E index of any item that might be * distinguished. From aabdf5dcb7963bacb3ede738d9144a9be737fea2 Mon Sep 17 00:00:00 2001 From: GMagician <3684609+GMagician@users.noreply.github.com> Date: Mon, 3 Oct 2022 21:31:28 +0200 Subject: [PATCH 4/6] remove max macro Remove unnecessary max --- Marlin/src/module/settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 54ff9bde76d7..a0e601e3bad0 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -442,7 +442,7 @@ typedef struct SettingsDataStruct { // // LIN_ADVANCE // - float planner_extruder_advance_K[_MAX(DISTINCT_E, 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(DISTINCT_E, 1)]; + float extruder_advance_K[DISTINCT_E]; _FIELD_TEST(planner_extruder_advance_K); EEPROM_READ(extruder_advance_K); #if ENABLED(LIN_ADVANCE) From f301b6ec65efcca8ec4c58e5f94ef80527519235 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 10 Oct 2022 09:47:46 -0400 Subject: [PATCH 5/6] sanity-check --- Marlin/Configuration_adv.h | 4 ++-- Marlin/src/inc/SanityCheck.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a54c8479c49e..4a60ec613906 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2062,9 +2062,9 @@ //#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) #if ENABLED(DISTINCT_E_FACTORS) - #define ADVANCE_K { 0.22 } // (mm) Compression length per 1mm/s extruder speed + #define ADVANCE_K { 0.22 } // (mm) Compression length per 1mm/s extruder speed, per extruder #else - #define ADVANCE_K 0.22 // (mm) Compression length per 1mm/s extruder speed + #define ADVANCE_K 0.22 // (mm) Compression length applying to all extruders #endif //#define ADVANCE_K_EXTRA // Add a second linear advance constant, configurable with M900 L. //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index cd1b79795736..017a7b3459b1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -652,6 +652,8 @@ #error "USE_M73_REMAINING_TIME is now SET_REMAINING_TIME." #elif defined(SHOW_SD_PERCENT) #error "SHOW_SD_PERCENT is now SHOW_PROGRESS_PERCENT." +#elif defined(EXTRA_LIN_ADVANCE_K) + #error "EXTRA_LIN_ADVANCE_K is now ADVANCE_K_EXTRA." #endif // L64xx stepper drivers have been removed From e2f38293cab62b6d39e8de90b3aefbf1c948c6a8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 10 Oct 2022 14:09:38 -0400 Subject: [PATCH 6/6] not needed --- Marlin/src/module/tool_change.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 706db3b6c5b9..4eb72a5b7d1d 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1487,7 +1487,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #endif // Migrate Linear Advance K factor to the new extruder - TERN_(LIN_ADVANCE, planner.extruder_advance_K[E_INDEX_N(active_extruder)] = planner.extruder_advance_K[E_INDEX_N(migration_extruder)]); + TERN_(LIN_ADVANCE, planner.extruder_advance_K[active_extruder] = planner.extruder_advance_K[migration_extruder]); // Perform the tool change tool_change(migration_extruder);