🐛 Fix MMU compile with >5 EXTRUDERS (#22036)

This commit is contained in:
Giuliano Zaro 2021-06-05 03:02:37 +02:00 committed by Scott Lahteine
parent ce95f56ac8
commit 04bea72787
10 changed files with 33 additions and 28 deletions

View file

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

View file

@ -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();

View file

@ -21,4 +21,5 @@
*/
#pragma once
void mmu_init();
void select_multiplexed_stepper(const uint8_t e);

View file

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

View file

@ -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."

View file

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

View file

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

View file

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

View file

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

View file

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