From 04bea727877c931777d69b718482630c40bd86fe Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Sat, 5 Jun 2021 03:02:37 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MMU=20compile=20with=20>5?= =?UTF-8?q?=20EXTRUDERS=20(#22036)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 7 ++----- Marlin/src/feature/mmu/mmu.cpp | 9 ++++++++- Marlin/src/feature/mmu/mmu.h | 1 + Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/SanityCheck.h | 15 +++++++++------ Marlin/src/module/planner.cpp | 10 ++++++---- Marlin/src/module/planner.h | 4 ++-- Marlin/src/module/stepper/indirection.h | 2 +- Marlin/src/pins/pins.h | 5 ----- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 6 +++--- 10 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 4fca64ba6b..75e20364f5 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -317,7 +317,7 @@ void disable_e_steppers() { void disable_e_stepper(const uint8_t e) { #define _CASE_DIS_E(N) case N: DISABLE_AXIS_E##N(); break; switch (e) { - REPEAT(EXTRUDERS, _CASE_DIS_E) + REPEAT(E_STEPPERS, _CASE_DIS_E) } } @@ -1423,10 +1423,7 @@ void setup() { #endif #if HAS_PRUSA_MMU1 - SETUP_LOG("Prusa MMU1"); - SET_OUTPUT(E_MUX0_PIN); - SET_OUTPUT(E_MUX1_PIN); - SET_OUTPUT(E_MUX2_PIN); + SETUP_RUN(mmu_init()); #endif #if HAS_FANMUX diff --git a/Marlin/src/feature/mmu/mmu.cpp b/Marlin/src/feature/mmu/mmu.cpp index 9a448296bb..7189723138 100644 --- a/Marlin/src/feature/mmu/mmu.cpp +++ b/Marlin/src/feature/mmu/mmu.cpp @@ -24,7 +24,14 @@ #if HAS_PRUSA_MMU1 -#include "../module/stepper.h" +#include "../MarlinCore.h" +#include "../module/planner.h" + +void mmu_init() { + SET_OUTPUT(E_MUX0_PIN); + SET_OUTPUT(E_MUX1_PIN); + SET_OUTPUT(E_MUX2_PIN); +} void select_multiplexed_stepper(const uint8_t e) { planner.synchronize(); diff --git a/Marlin/src/feature/mmu/mmu.h b/Marlin/src/feature/mmu/mmu.h index 10805c8e26..23742d00c6 100644 --- a/Marlin/src/feature/mmu/mmu.h +++ b/Marlin/src/feature/mmu/mmu.h @@ -21,4 +21,5 @@ */ #pragma once +void mmu_init(); void select_multiplexed_stepper(const uint8_t e); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index f29b5af66f..8c018ea3ab 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -517,7 +517,7 @@ #define HAS_PRUSA_MMU2 1 #define HAS_PRUSA_MMU2S 1 #endif - #if MMU_MODEL == EXTENDABLE_EMU_MMU2 || MMU_MODEL == EXTENDABLE_EMU_MMU2S + #if MMU_MODEL >= EXTENDABLE_EMU_MMU2 #define HAS_EXTENDABLE_MMU 1 #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ade2ff4586..e52468c42c 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -954,9 +954,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Multi-Material-Unit 2 / EXTENDABLE_EMU_MMU2 requirements */ #if HAS_PRUSA_MMU2 - #if EXTRUDERS != 5 + #if !HAS_EXTENDABLE_MMU && EXTRUDERS != 5 #undef SINGLENOZZLE #error "PRUSA_MMU2(S) requires exactly 5 EXTRUDERS. Please update your Configuration." + #elif HAS_EXTENDABLE_MMU && EXTRUDERS > 15 + #error "EXTRUDERS is too large for MMU(S) emulation mode. The maximum value is 15." #elif DISABLED(NOZZLE_PARK_FEATURE) #error "PRUSA_MMU2(S) requires NOZZLE_PARK_FEATURE. Enable it to continue." #elif HAS_PRUSA_MMU2S && DISABLED(FILAMENT_RUNOUT_SENSOR) @@ -969,18 +971,19 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / HAS_EXTENDABLE_MMU(S)."); #endif #endif -#if HAS_EXTENDABLE_MMU && EXTRUDERS > 15 - #error "Too many extruders for MMU(S) emulation mode. (15 maximum)." -#endif /** * Options only for EXTRUDERS > 1 */ #if HAS_MULTI_EXTRUDER - #if EXTRUDERS > 8 - #error "Marlin supports a maximum of 8 EXTRUDERS." + #if HAS_EXTENDABLE_MMU + #define MAX_EXTRUDERS 15 + #else + #define MAX_EXTRUDERS 8 #endif + static_assert(EXTRUDERS <= MAX_EXTRUDERS, "Marlin supports a maximum of " STRINGIFY(MAX_EXTRUDERS) " EXTRUDERS."); + #undef MAX_EXTRUDERS #if ENABLED(HEATERS_PARALLEL) #error "EXTRUDERS must be 1 with HEATERS_PARALLEL." diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 09db12cd7a..3353609de6 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -213,7 +213,7 @@ xyze_float_t Planner::previous_speed; float Planner::previous_nominal_speed_sqr; #if ENABLED(DISABLE_INACTIVE_EXTRUDER) - last_move_t Planner::g_uc_extruder_last_move[EXTRUDERS] = { 0 }; + last_move_t Planner::g_uc_extruder_last_move[E_STEPPERS] = { 0 }; #endif #ifdef XY_FREQUENCY_LIMIT @@ -2105,11 +2105,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder - LOOP_L_N(i, EXTRUDERS) + LOOP_L_N(i, E_STEPPERS) if (g_uc_extruder_last_move[i]) g_uc_extruder_last_move[i]--; + #define E_STEPPER_INDEX(E) TERN(SWITCHING_EXTRUDER, (E) / 2, E) + #define ENABLE_ONE_E(N) do{ \ - if (extruder == N) { \ + if (E_STEPPER_INDEX(extruder) == N) { \ ENABLE_AXIS_E##N(); \ g_uc_extruder_last_move[N] = (BLOCK_BUFFER_SIZE) * 2; \ if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled)) \ @@ -2128,7 +2130,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif - REPEAT(EXTRUDERS, ENABLE_ONE_E); // (ENABLE_ONE_E must end with semicolon) + REPEAT(E_STEPPERS, ENABLE_ONE_E); // (ENABLE_ONE_E must end with semicolon) } #endif // EXTRUDERS diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index be004dd3f4..928fdaec31 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -450,8 +450,8 @@ class Planner { #endif #if ENABLED(DISABLE_INACTIVE_EXTRUDER) - // Counters to manage disabling inactive extruders - static last_move_t g_uc_extruder_last_move[EXTRUDERS]; + // Counters to manage disabling inactive extruder steppers + static last_move_t g_uc_extruder_last_move[E_STEPPERS]; #endif #if HAS_WIRED_LCD diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index e72d793ca6..6f9fd24ce8 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -418,7 +418,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define REV_E_DIR(E) do{ E0_DIR_WRITE(E ? !INVERT_E0_DIR : INVERT_E0_DIR); }while(0) #endif -#elif HAS_PRUSA_MMU2 +#elif HAS_PRUSA_MMU2 // One multiplexed stepper driver #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index fa6c5208f9..a1f45f5774 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -35,11 +35,6 @@ * These numbers are the same in any pin mapping. */ -#if HAS_EXTENDABLE_MMU - #define MAX_EXTRUDERS 15 -#else - #define MAX_EXTRUDERS 8 -#endif #define MAX_E_STEPPERS 8 #if MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 70ac9a13c3..8f19b1915d 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -23,10 +23,10 @@ #include "env_validate.h" -#if HOTENDS > 8 || E_STEPPERS > 8 - #error "BIGTREE GTR V1.0 supports up to 8 hotends / E-steppers." -#elif HOTENDS > MAX_E_STEPPERS || E_STEPPERS > MAX_E_STEPPERS +#if E_STEPPERS > MAX_E_STEPPERS #error "Marlin extruder/hotends limit! Increase MAX_E_STEPPERS to continue." +#elif HOTENDS > 8 || E_STEPPERS > 8 + #error "BIGTREE GTR V1.0 supports up to 8 hotends / E-steppers." #endif #define BOARD_INFO_NAME "BTT GTR V1.0"