From 0b752435f4701a5be3c74596adda042f986dae69 Mon Sep 17 00:00:00 2001 From: GMagician Date: Tue, 27 Oct 2020 22:56:32 +0100 Subject: [PATCH 01/23] Add SMUFF support - Changed MMU definition to a per model basis - Added SMUFF support (that will actually only expand multicolor up to 15 colors) --- Marlin/Configuration.h | 31 ++-- Marlin/Configuration_adv.h | 67 ++++--- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 4 +- Marlin/src/MarlinCore.cpp | 14 +- Marlin/src/core/macros.h | 9 + Marlin/src/feature/{snmm.cpp => mmu/mmu.cpp} | 4 +- Marlin/src/feature/{snmm.h => mmu/mmu.h} | 0 .../mmu2-serial-protocol.md} | 0 Marlin/src/feature/{mmu2 => mmu}/mmu2.cpp | 169 +++++++++--------- Marlin/src/feature/{mmu2 => mmu}/mmu2.h | 2 +- Marlin/src/gcode/config/M220.cpp | 4 +- Marlin/src/gcode/control/T.cpp | 8 +- Marlin/src/gcode/feature/pause/M701_M702.cpp | 16 +- Marlin/src/gcode/feature/prusa_MMU2/M403.cpp | 6 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 6 +- Marlin/src/gcode/parser.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 29 ++- Marlin/src/inc/SanityCheck.h | 100 ++++++----- Marlin/src/lcd/menu/menu_main.cpp | 2 +- Marlin/src/lcd/menu/menu_mmu2.cpp | 2 +- Marlin/src/module/stepper/indirection.h | 11 +- Marlin/src/module/tool_change.cpp | 16 +- Marlin/src/pins/lpc1768/pins_MKS_SBASE.h | 4 +- buildroot/tests/mega2560-tests | 5 +- platformio.ini | 8 +- 26 files changed, 279 insertions(+), 242 deletions(-) rename Marlin/src/feature/{snmm.cpp => mmu/mmu.cpp} (95%) rename Marlin/src/feature/{snmm.h => mmu/mmu.h} (100%) rename Marlin/src/feature/{mmu2/serial-protocol.md => mmu/mmu2-serial-protocol.md} (100%) rename Marlin/src/feature/{mmu2 => mmu}/mmu2.cpp (90%) rename Marlin/src/feature/{mmu2 => mmu}/mmu2.h (99%) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 5ec41c596b..1d4087224b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -158,33 +158,22 @@ #endif /** - * Průša MK2 Single Nozzle Multi-Material Multiplexer, and variants. + * Multi-Material Unit * - * This device allows one stepper driver on a control board to drive - * two to eight stepper motors, one at a time, in a manner suitable - * for extruders. - * - * This option only allows the multiplexer to switch on tool-change. - * Additional options to configure custom E moves are pending. - */ -//#define MK2_MULTIPLEXER -#if ENABLED(MK2_MULTIPLEXER) - // Override the default DIO selector pins here, if needed. - // Some pins files may provide defaults for these pins. - //#define E_MUX0_PIN 40 // Always Required - //#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs - //#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs -#endif - -/** - * Průša Multi-Material Unit v2 + * Supported unit models: + * PRUSA_MMU1: Průša MMU1 (This is the multiplexer version) + * PRUSA_MMU2: Průša MMU2 + * PRUSA_MMU2S Průša MMU2S (This mode requires a MK3S extruder with a sensor at the extruder idler) + * SMUFF_EMU_MMU2: Christian Gegg SMUFF (Průša MMU2 emulation mode) + * SMUFF_EMU_MMU2S: Christian Gegg SMUFF (Průša MMU2S emulation mode) * * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. - * Requires EXTRUDERS = 5 + * MMU2 requires EXTRUDERS = 5 + * SMUFF supports EXTRUDERS = up to 15 but these are limited to 8 because of Marlin limit * * For additional configuration see Configuration_adv.h */ -//#define PRUSA_MMU2 +//#define MMU_MODEL PRUSA_MMU2 // A dual extruder that uses a single stepper motor //#define SWITCHING_EXTRUDER diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 31661a582e..d5c047a9e4 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3506,11 +3506,29 @@ //#include "Configuration_Secure.h" // External file with WiFi SSID / Password #endif -/** - * Průša Multi-Material Unit v2 - * Enable in Configuration.h - */ -#if ENABLED(PRUSA_MMU2) +#if MMU_MODEL == PRUSA_MMU1 + /** + * Průša Multi-Material-Unit multiplexed + * Enable in Configuration.h + * + * This device allows one stepper driver on a control board to drive + * two to eight stepper motors, one at a time, in a manner suitable + * for extruders. + * + * This option only allows the multiplexer to switch on tool-change. + * Additional options to configure custom E moves are pending. + * + * Override the default DIO selector pins here, if needed. + * Some pins files may provide defaults for these pins. + */ + //#define E_MUX0_PIN 40 // Always Required + //#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs + //#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs +#elif MMU_MODEL == PRUSA_MMU2 || MMU_MODEL == PRUSA_MMU2S + /** + * Průša Multi-Material-Unit v2 + * Enable in Configuration.h + */ // Serial port used for communication with MMU2. // For AVR enable the UART port used for the MMU. (e.g., mmuSerial) @@ -3554,29 +3572,12 @@ { -50.0, 2000 } #endif - /** - * MMU Extruder Sensor - * - * Support for a Průša (or other) IR Sensor to detect filament near the extruder - * and make loading more reliable. Suitable for an extruder equipped with a filament - * sensor less than 38mm from the gears. - * - * During loading the extruder will stop when the sensor is triggered, then do a last - * move up to the gears. If no filament is detected, the MMU2 can make some more attempts. - * If all attempts fail, a filament runout will be triggered. - */ - //#define MMU_EXTRUDER_SENSOR - #if ENABLED(MMU_EXTRUDER_SENSOR) - #define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail - #endif - /** * Using a sensor like the MMU2S * This mode requires a MK3S extruder with a sensor at the extruder idler, like the MMU2S. * See https://help.prusa3d.com/en/guide/3b-mk3s-mk2-5s-extruder-upgrade_41560, step 11 */ - //#define PRUSA_MMU2_S_MODE - #if ENABLED(PRUSA_MMU2_S_MODE) + #if MMU_MODEL == PRUSA_MMU2S #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries) #define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/min) @@ -3592,11 +3593,29 @@ #define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \ { -MMU2_CAN_LOAD_INCREMENT, MMU2_CAN_LOAD_FEEDRATE } + #else + + /** + * MMU1 Extruder Sensor + * + * Support for a Průša (or other) IR Sensor to detect filament near the extruder + * and make loading more reliable. Suitable for an extruder equipped with a filament + * sensor less than 38mm from the gears. + * + * During loading the extruder will stop when the sensor is triggered, then do a last + * move up to the gears. If no filament is detected, the MMU2 can make some more attempts. + * If all attempts fail, a filament runout will be triggered. + */ + //#define MMU_EXTRUDER_SENSOR + #if ENABLED(MMU_EXTRUDER_SENSOR) + #define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail + #endif + #endif //#define MMU2_DEBUG // Write debug info to serial output -#endif // PRUSA_MMU2 +#endif // MMU_MODEL == PRUSA_MMU2 || MMU_MODEL == PRUSA_MMU2S /** * Advanced Print Counter settings diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 8b7d27742d..21d149fcaf 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -97,8 +97,8 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #define IS_RX0(P) (P == P0_03) #if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI) #error "Serial port pins (0) conflict with Trinamic SPI pins!" - #elif ENABLED(MK2_MULTIPLEXER) && (IS_TX0(E_MUX1_PIN) || IS_RX0(E_MUX0_PIN)) - #error "Serial port pins (0) conflict with MK2 multiplexer pins!" + #elif HAS_PRUSA_MMU1 && (IS_TX0(E_MUX1_PIN) || IS_RX0(E_MUX0_PIN)) + #error "Serial port pins (0) conflict with Multi-Material-Unit multiplexer pins!" #elif (AXIS_HAS_SPI(X) && IS_TX0(X_CS_PIN)) || (AXIS_HAS_SPI(Y) && IS_RX0(Y_CS_PIN)) #error "Serial port pins (0) conflict with X/Y axis SPI pins!" #endif diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index e395bdccb8..caa5114386 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -213,8 +213,8 @@ #include "feature/controllerfan.h" #endif -#if ENABLED(PRUSA_MMU2) - #include "feature/mmu2/mmu2.h" +#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #include "feature/mmu/mmu2.h" #endif #if HAS_L64XX @@ -772,7 +772,9 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { #endif // Update the Průša MMU2 - TERN_(PRUSA_MMU2, mmu2.mmu_loop()); + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + mmu2.mmu_loop(); + #endif // Handle Joystick jogging TERN_(POLL_JOG, joystick.inject_jog_moves()); @@ -1179,8 +1181,8 @@ void setup() { SETUP_RUN(caselight.update_brightness()); #endif - #if ENABLED(MK2_MULTIPLEXER) - SETUP_LOG("MK2_MULTIPLEXER"); + #if HAS_PRUSA_MMU1 + SETUP_LOG("PRUSA MMU1 MULTIPLEXER"); SET_OUTPUT(E_MUX0_PIN); SET_OUTPUT(E_MUX1_PIN); SET_OUTPUT(E_MUX2_PIN); @@ -1260,7 +1262,7 @@ void setup() { SETUP_RUN(test_tmc_connection(true, true, true, true)); #endif - #if ENABLED(PRUSA_MMU2) + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S SETUP_RUN(mmu2.init()); #endif diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 7948e8ce87..3de79a9e4d 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -516,3 +516,12 @@ #define MAP0(f, x, peek, ...) f(x) MAP_NEXT (peek, MAP1) (f, peek, __VA_ARGS__) #define MAP1(f, x, peek, ...) f(x) MAP_NEXT (peek, MAP0) (f, peek, __VA_ARGS__) #define MAP(f, ...) EVAL512 (MAP1 (f, __VA_ARGS__, (), 0)) + +// +// Multi-Material-Unit models +// +#define PRUSA_MMU1 1 +#define PRUSA_MMU2 2 +#define PRUSA_MMU2S 3 +#define SMUFF_EMU_MMU2 4 +#define SMUFF_EMU_MMU2S 5 diff --git a/Marlin/src/feature/snmm.cpp b/Marlin/src/feature/mmu/mmu.cpp similarity index 95% rename from Marlin/src/feature/snmm.cpp rename to Marlin/src/feature/mmu/mmu.cpp index 25723f7b38..2b48823ee7 100644 --- a/Marlin/src/feature/snmm.cpp +++ b/Marlin/src/feature/mmu/mmu.cpp @@ -22,7 +22,7 @@ #include "../inc/MarlinConfig.h" -#if ENABLED(MK2_MULTIPLEXER) +#if HAS_PRUSA_MMU1 #include "../module/stepper.h" @@ -35,4 +35,4 @@ void select_multiplexed_stepper(const uint8_t e) { safe_delay(100); } -#endif // MK2_MULTIPLEXER +#endif // HAS_PRUSA_MMU1 diff --git a/Marlin/src/feature/snmm.h b/Marlin/src/feature/mmu/mmu.h similarity index 100% rename from Marlin/src/feature/snmm.h rename to Marlin/src/feature/mmu/mmu.h diff --git a/Marlin/src/feature/mmu2/serial-protocol.md b/Marlin/src/feature/mmu/mmu2-serial-protocol.md similarity index 100% rename from Marlin/src/feature/mmu2/serial-protocol.md rename to Marlin/src/feature/mmu/mmu2-serial-protocol.md diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp similarity index 90% rename from Marlin/src/feature/mmu2/mmu2.cpp rename to Marlin/src/feature/mmu/mmu2.cpp index c5cf485850..5f7cf28cd1 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(PRUSA_MMU2) +#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S #include "mmu2.h" #include "../../lcd/menu/menu_mmu2.h" @@ -94,7 +94,7 @@ MMU2 mmu2; #define mmuSerial MMU2_SERIAL bool MMU2::enabled, MMU2::ready, MMU2::mmu_print_saved; -#if ENABLED(PRUSA_MMU2_S_MODE) +#if HAS_PRUSA_MMU2S bool MMU2::mmu2s_triggered; #endif uint8_t MMU2::cmd, MMU2::cmd_arg, MMU2::last_cmd, MMU2::extruder; @@ -115,7 +115,7 @@ char MMU2::rx_buffer[MMU_RX_SIZE], MMU2::tx_buffer[MMU_TX_SIZE]; static constexpr E_Step ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE } , load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE } - #if ENABLED(PRUSA_MMU2_S_MODE) + #if HAS_PRUSA_MMU2S , can_load_sequence[] PROGMEM = { MMU2_CAN_LOAD_SEQUENCE } , can_load_increment_sequence[] PROGMEM = { MMU2_CAN_LOAD_INCREMENT_SEQUENCE } #endif @@ -162,7 +162,7 @@ uint8_t MMU2::get_current_tool() { return extruder == MMU2_NO_TOOL ? -1 : extruder; } -#if EITHER(PRUSA_MMU2_S_MODE, MMU_EXTRUDER_SENSOR) +#if HAS_PRUSA_MMU2S || ENABLED(MMU_EXTRUDER_SENSOR) #define FILAMENT_PRESENT() (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE) #endif @@ -242,7 +242,7 @@ void MMU2::mmu_loop() { enabled = true; state = 1; - TERN_(PRUSA_MMU2_S_MODE, mmu2s_triggered = false); + TERN_(HAS_PRUSA_MMU2S, mmu2s_triggered = false); } break; @@ -307,7 +307,7 @@ void MMU2::mmu_loop() { state = 2; // wait for response } - TERN_(PRUSA_MMU2_S_MODE, check_filament()); + TERN_(HAS_PRUSA_MMU2S, check_filament()); break; case 2: // response to command P0 @@ -324,7 +324,7 @@ void MMU2::mmu_loop() { else if (ELAPSED(millis(), prev_request + MMU_P0_TIMEOUT)) // Resend request after timeout (3s) state = 1; - TERN_(PRUSA_MMU2_S_MODE, check_filament()); + TERN_(HAS_PRUSA_MMU2S, check_filament()); break; case 3: // response to mmu commands @@ -340,9 +340,9 @@ void MMU2::mmu_loop() { #endif if (rx_ok()) { - // Response to C0 mmu command in PRUSA_MMU2_S_MODE + // Response to C0 mmu command in MMU2S model bool can_reset = true; - #if ENABLED(PRUSA_MMU2_S_MODE) + #if HAS_PRUSA_MMU2S if (!mmu2s_triggered && last_cmd == MMU_CMD_C0) { can_reset = false; // MMU ok received but filament sensor not triggered, retrying... @@ -367,7 +367,7 @@ void MMU2::mmu_loop() { } state = 1; } - TERN_(PRUSA_MMU2_S_MODE, check_filament()); + TERN_(HAS_PRUSA_MMU2S, check_filament()); break; } } @@ -487,7 +487,7 @@ static void mmu2_not_responding() { BUZZ(100, 659); } -#if ENABLED(PRUSA_MMU2_S_MODE) +#if HAS_PRUSA_MMU2S bool MMU2::load_to_gears() { command(MMU_CMD_C0); @@ -542,9 +542,8 @@ static void mmu2_not_responding() { */ void MMU2::tool_change(const char* special) { - if (!enabled) return; - #if ENABLED(MMU2_MENUS) + if (!enabled) return; set_runout_valid(false); @@ -626,10 +625,10 @@ static void mmu2_not_responding() { * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ void MMU2::tool_change(const char* special) { - if (!enabled) return; - #if ENABLED(MMU2_MENUS) + if (!enabled) return; + set_runout_valid(false); switch (*special) { @@ -682,83 +681,83 @@ static void mmu2_not_responding() { mmu_idl_sens = 0; } -#elif DISABLED(MMU_EXTRUDER_SENSOR) && DISABLED(PRUSA_MMU2_S_MODE) +#else // !HAS_PRUSA_MMU2S && DISABLED(MMU_EXTRUDER_SENSOR) -/** - * Handle tool change - */ -void MMU2::tool_change(const uint8_t index) { - if (!enabled) return; - - set_runout_valid(false); - - if (index != extruder) { - DISABLE_AXIS_E0(); - ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); - command(MMU_CMD_T0 + index); - manage_response(true, true); - command(MMU_CMD_C0); - extruder = index; //filament change is finished - active_extruder = 0; - ENABLE_AXIS_E0(); - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder)); - ui.reset_status(); - } - - set_runout_valid(true); -} - -/** - * Handle special T?/Tx/Tc commands - * - * T? Gcode to extrude shouldn't have to follow, load to extruder wheels is done automatically - * Tx Same as T?, except nozzle doesn't have to be preheated. Tc must be placed after extruder nozzle is preheated to finish filament load. - * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. - */ -void MMU2::tool_change(const char* special) { - if (!enabled) return; - - #if ENABLED(MMU2_MENUS) + /** + * Handle tool change + */ + void MMU2::tool_change(const uint8_t index) { + if (!enabled) return; set_runout_valid(false); - switch (*special) { - case '?': { - DEBUG_ECHOLNPGM("case ?\n"); - uint8_t index = mmu2_choose_filament(); - while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); - load_filament_to_nozzle(index); - } break; - - case 'x': { - DEBUG_ECHOLNPGM("case x\n"); - planner.synchronize(); - uint8_t index = mmu2_choose_filament(); - DISABLE_AXIS_E0(); - command(MMU_CMD_T0 + index); - manage_response(true, true); - command(MMU_CMD_C0); - mmu_loop(); - - ENABLE_AXIS_E0(); - extruder = index; - active_extruder = 0; - } break; - - case 'c': { - DEBUG_ECHOLNPGM("case c\n"); - while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); - execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence)); - } break; + if (index != extruder) { + DISABLE_AXIS_E0(); + ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); + command(MMU_CMD_T0 + index); + manage_response(true, true); + command(MMU_CMD_C0); + extruder = index; //filament change is finished + active_extruder = 0; + ENABLE_AXIS_E0(); + SERIAL_ECHO_START(); + SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder)); + ui.reset_status(); } set_runout_valid(true); - - #endif } -#endif // MMU_EXTRUDER_SENSOR + /** + * Handle special T?/Tx/Tc commands + * + * T? Gcode to extrude shouldn't have to follow, load to extruder wheels is done automatically + * Tx Same as T?, except nozzle doesn't have to be preheated. Tc must be placed after extruder nozzle is preheated to finish filament load. + * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. + */ + void MMU2::tool_change(const char* special) { + #if ENABLED(MMU2_MENUS) + + if (!enabled) return; + + set_runout_valid(false); + + switch (*special) { + case '?': { + DEBUG_ECHOLNPGM("case ?\n"); + uint8_t index = mmu2_choose_filament(); + while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); + load_filament_to_nozzle(index); + } break; + + case 'x': { + DEBUG_ECHOLNPGM("case x\n"); + planner.synchronize(); + uint8_t index = mmu2_choose_filament(); + DISABLE_AXIS_E0(); + command(MMU_CMD_T0 + index); + manage_response(true, true); + command(MMU_CMD_C0); + mmu_loop(); + + ENABLE_AXIS_E0(); + extruder = index; + active_extruder = 0; + } break; + + case 'c': { + DEBUG_ECHOLNPGM("case c\n"); + while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); + execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence)); + } break; + } + + set_runout_valid(true); + + #endif + } + +#endif // HAS_PRUSA_MMU2S /** * Set next command @@ -866,7 +865,7 @@ void MMU2::filament_runout() { planner.synchronize(); } -#if ENABLED(PRUSA_MMU2_S_MODE) +#if HAS_PRUSA_MMU2S void MMU2::check_filament() { const bool present = FILAMENT_PRESENT(); @@ -1065,4 +1064,4 @@ void MMU2::filament_runout() { #endif // HAS_LCD_MENU && MMU2_MENUS -#endif // PRUSA_MMU2 +#endif // HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S diff --git a/Marlin/src/feature/mmu2/mmu2.h b/Marlin/src/feature/mmu/mmu2.h similarity index 99% rename from Marlin/src/feature/mmu2/mmu2.h rename to Marlin/src/feature/mmu/mmu2.h index 678f65d072..23a5965d3c 100644 --- a/Marlin/src/feature/mmu2/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -80,7 +80,7 @@ private: static void filament_runout(); - #if ENABLED(PRUSA_MMU2_S_MODE) + #if HAS_PRUSA_MMU2S static bool mmu2s_triggered; static void check_filament(); static bool can_load(); diff --git a/Marlin/src/gcode/config/M220.cpp b/Marlin/src/gcode/config/M220.cpp index 1bec6a7782..a5df7bccd4 100644 --- a/Marlin/src/gcode/config/M220.cpp +++ b/Marlin/src/gcode/config/M220.cpp @@ -31,13 +31,13 @@ * * Report the current speed percentage factor if no parameter is specified * - * With PRUSA_MMU2... + * With MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S/SMUFF_EMU_MMU2/SMUFF_EMU_MMU2S... * B : Flag to back up the current factor * R : Flag to restore the last-saved factor */ void GcodeSuite::M220() { - #if ENABLED(PRUSA_MMU2) + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S static int16_t backup_feedrate_percentage = 100; if (parser.seen('B')) backup_feedrate_percentage = feedrate_percentage; if (parser.seen('R')) feedrate_percentage = backup_feedrate_percentage; diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index d95e60ff8d..ac00b0d196 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -27,8 +27,8 @@ #include "../../module/motion.h" #endif -#if ENABLED(PRUSA_MMU2) - #include "../../feature/mmu2/mmu2.h" +#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #include "../../feature/mmu/mmu2.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) @@ -40,7 +40,7 @@ * F[units/min] Set the movement feedrate * S1 Don't move the tool in XY after change * - * For PRUSA_MMU2: + * For PRUSA_MMU2/PRUSA_MMU2S/SMUFF_EMU_MMU2PRUSA_MMU2S: * T[n] Gcode to extrude at least 38.10 mm at feedrate 19.02 mm/s must follow immediately to load to extruder wheels. * T? Gcode to extrude shouldn't have to follow. Load to extruder wheels is done automatically. * Tx Same as T?, but nozzle doesn't have to be preheated. Tc requires a preheated nozzle to finish filament load. @@ -54,7 +54,7 @@ void GcodeSuite::T(const int8_t tool_index) { // Count this command as movement / activity reset_stepper_timeout(); - #if ENABLED(PRUSA_MMU2) + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S if (parser.string_arg) { mmu2.tool_change(parser.string_arg); // Special commands T?/Tx/Tc return; diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index a193d83d40..35604d8086 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -38,8 +38,8 @@ #include "../../../lcd/marlinui.h" #endif -#if ENABLED(PRUSA_MMU2) - #include "../../../feature/mmu2/mmu2.h" +#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #include "../../../feature/mmu/mmu2.h" #endif #if ENABLED(MIXING_EXTRUDER) @@ -86,7 +86,7 @@ void GcodeSuite::M701() { // Show initial "wait for load" message TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_LOAD, PAUSE_MODE_LOAD_FILAMENT, target_extruder)); - #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU) // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) @@ -98,7 +98,7 @@ void GcodeSuite::M701() { do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); // Load filament - #if ENABLED(PRUSA_MMU2) + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S mmu2.load_filament_to_nozzle(target_extruder); #else constexpr float purge_length = ADVANCED_PAUSE_PURGE_LENGTH, @@ -121,7 +121,7 @@ void GcodeSuite::M701() { if (park_point.z > 0) do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); - #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) tool_change(active_extruder_before_filament_change, false); @@ -186,7 +186,7 @@ void GcodeSuite::M702() { // Show initial "wait for unload" message TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, PAUSE_MODE_UNLOAD_FILAMENT, target_extruder)); - #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU) // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) @@ -198,7 +198,7 @@ void GcodeSuite::M702() { do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); // Unload filament - #if ENABLED(PRUSA_MMU2) + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S mmu2.unload(); #else #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_UNLOAD_ALL_EXTRUDERS) @@ -227,7 +227,7 @@ void GcodeSuite::M702() { if (park_point.z > 0) do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); - #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) tool_change(active_extruder_before_filament_change, false); diff --git a/Marlin/src/gcode/feature/prusa_MMU2/M403.cpp b/Marlin/src/gcode/feature/prusa_MMU2/M403.cpp index 91e35dbf65..1626a126ef 100644 --- a/Marlin/src/gcode/feature/prusa_MMU2/M403.cpp +++ b/Marlin/src/gcode/feature/prusa_MMU2/M403.cpp @@ -22,10 +22,10 @@ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(PRUSA_MMU2) +#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S #include "../../gcode.h" -#include "../../../feature/mmu2/mmu2.h" +#include "../../../feature/mmu/mmu2.h" /** * M403: Set filament type for MMU2 @@ -46,4 +46,4 @@ void GcodeSuite::M403() { SERIAL_ECHO_MSG("M403 - bad arguments."); } -#endif // PRUSA_MMU2 +#endif // HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index e2c70ad3ae..7624957e86 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -699,7 +699,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 402: M402(); break; // M402: Stow probe #endif - #if ENABLED(PRUSA_MMU2) + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S case 403: M403(); break; #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 34df51e517..0dac76d923 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -181,7 +181,7 @@ * M217 - Set filament swap parameters: "M217 S P R". (Requires SINGLENOZZLE) * M218 - Set/get a tool offset: "M218 T X Y". (Requires 2 or more extruders) * M220 - Set Feedrate Percentage: "M220 S" (i.e., "FR" on the LCD) - * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires PRUSA_MMU2) + * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S/SMUFF_EMU_MMU2/SMUFF_EMU_MMU2S) * M221 - Set Flow Percentage: "M221 S" * M226 - Wait until a pin is in a given state: "M226 P S" (Requires DIRECT_PIN_CONTROL) * M240 - Trigger a camera to take a photograph. (Requires PHOTO_GCODE) @@ -735,7 +735,9 @@ private: static void M402(); #endif - TERN_(PRUSA_MMU2, static void M403()); + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + static void M403(); + #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) static void M404(); diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index bba64dbbc4..4daa2e7e62 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -155,7 +155,7 @@ void GCodeParser::parse(char *p) { // Skip spaces to get the numeric part while (*p == ' ') p++; - #if ENABLED(PRUSA_MMU2) + #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S if (letter == 'T') { // check for special MMU2 T?/Tx/Tc commands if (*p == '?' || *p == 'x' || *p == 'c') { diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 6f632aa569..d48159f6b5 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -495,6 +495,23 @@ #endif #endif +/** + * Multi-Material-Unit supported models + */ +#ifdef MMU_MODEL + #define HAS_MMU 1 + #if MMU_MODEL == PRUSA_MMU1 + #define HAS_PRUSA_MMU1 1 + #elif MMU_MODEL == PRUSA_MMU2 || MMU_MODEL == SMUFF_EMU_MMU2 + #define HAS_PRUSA_MMU2 1 + #elif MMU_MODEL == PRUSA_MMU2S || MMU_MODEL == SMUFF_EMU_MMU2S + #define HAS_PRUSA_MMU2S 1 + #endif + #if MMU_MODEL == SMUFF_EMU_MMU2 || MMU_MODEL == SMUFF_EMU_MMU2S + #define HAS_SMUFF 1 + #endif +#endif + /** * Extruders have some combination of stepper motors and hotends * so we separate these concepts into the defines: @@ -512,8 +529,6 @@ #undef SWITCHING_EXTRUDER #undef SWITCHING_NOZZLE #undef MIXING_EXTRUDER - #undef MK2_MULTIPLEXER - #undef PRUSA_MMU2 #undef HOTEND_IDLE_TIMEOUT #elif EXTRUDERS > 1 #define HAS_MULTI_EXTRUDER 1 @@ -539,17 +554,17 @@ #elif ENABLED(SWITCHING_TOOLHEAD) #define E_STEPPERS EXTRUDERS #define E_MANUAL EXTRUDERS -#elif ENABLED(PRUSA_MMU2) +#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S #define E_STEPPERS 1 #endif -// No inactive extruders with MK2_MULTIPLEXER or SWITCHING_NOZZLE -#if EITHER(MK2_MULTIPLEXER, SWITCHING_NOZZLE) +// No inactive extruders with SWITCHING_NOZZLE or Průša MMU1 +#if ENABLED(SWITCHING_NOZZLE) || HAS_PRUSA_MMU1 #undef DISABLE_INACTIVE_EXTRUDER #endif -// Průša MK2 Multiplexer and MMU 2.0 force SINGLENOZZLE -#if EITHER(MK2_MULTIPLEXER, PRUSA_MMU2) +// Průša MMU1, MMU 2.0, MMUS 2.0 and SMUFF force SINGLENOZZLE +#if HAS_MMU #define SINGLENOZZLE #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 657e055241..ed57c54296 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -909,17 +909,23 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TOOLCHANGE_ZRAISE required for EXTRUDERS > 1. Please update your Configuration_adv.h." #endif -#elif ENABLED(MK2_MULTIPLEXER) - #error "MK2_MULTIPLEXER requires 2 or more EXTRUDERS." +#elif HAS_PRUSA_MMU1 || HAS_SMUFF + #error "Multi-Material-Unit requires 2 or more EXTRUDERS." #elif ENABLED(SINGLENOZZLE) #error "SINGLENOZZLE requires 2 or more EXTRUDERS." #endif /** - * Sanity checking for the Průša MK2 Multiplexer + * Sanity checking for all Průša MMU */ #ifdef SNMM - #error "SNMM is now MK2_MULTIPLEXER. Please update your configuration." + #error "SNMM is now MMU_MODEL = PRUSA_MMU1. Please update your configuration." +#elif ENABLED(MK2_MULTIPLEXER) + #error "MK2_MULTIPLEXER is now MMU_MODEL = PRUSA_MMU1. Please update your configuration." +#elif ENABLED(PRUSA_MMU2) + #error "PRUSA_MMU2 is now MMU_MODEL = PRUSA_MMU2. Please update your configuration." +#elif ENABLED(PRUSA_MMU2_S_MODE) + #error "PRUSA_MMU2_S_MODE is now MMU_MODEL = PRUSA_MMU2S. Please update your configuration." #endif /** @@ -1886,48 +1892,46 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * Test Extruder Stepper Pins */ -#if DISABLED(MK2_MULTIPLEXER) // MK2_MULTIPLEXER uses E0 stepper only - #if E_STEPPERS - #if !(PINS_EXIST(E0_STEP, E0_DIR) && HAS_E0_ENABLE) - #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." +#if E_STEPPERS + #if !(PINS_EXIST(E0_STEP, E0_DIR) && HAS_E0_ENABLE) + #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." + #endif + #if E_STEPPERS > 1 + #if !(PINS_EXIST(E1_STEP, E1_DIR) && HAS_E1_ENABLE) + #error "E1_STEP_PIN, E1_DIR_PIN, or E1_ENABLE_PIN not defined for this board." #endif - #if E_STEPPERS > 1 - #if !(PINS_EXIST(E1_STEP, E1_DIR) && HAS_E1_ENABLE) - #error "E1_STEP_PIN, E1_DIR_PIN, or E1_ENABLE_PIN not defined for this board." + #if E_STEPPERS > 2 + #if !(PINS_EXIST(E2_STEP, E2_DIR) && HAS_E2_ENABLE) + #error "E2_STEP_PIN, E2_DIR_PIN, or E2_ENABLE_PIN not defined for this board." #endif - #if E_STEPPERS > 2 - #if !(PINS_EXIST(E2_STEP, E2_DIR) && HAS_E2_ENABLE) - #error "E2_STEP_PIN, E2_DIR_PIN, or E2_ENABLE_PIN not defined for this board." + #if E_STEPPERS > 3 + #if !(PINS_EXIST(E3_STEP, E3_DIR) && HAS_E3_ENABLE) + #error "E3_STEP_PIN, E3_DIR_PIN, or E3_ENABLE_PIN not defined for this board." #endif - #if E_STEPPERS > 3 - #if !(PINS_EXIST(E3_STEP, E3_DIR) && HAS_E3_ENABLE) - #error "E3_STEP_PIN, E3_DIR_PIN, or E3_ENABLE_PIN not defined for this board." + #if E_STEPPERS > 4 + #if !(PINS_EXIST(E4_STEP, E4_DIR) && HAS_E4_ENABLE) + #error "E4_STEP_PIN, E4_DIR_PIN, or E4_ENABLE_PIN not defined for this board." #endif - #if E_STEPPERS > 4 - #if !(PINS_EXIST(E4_STEP, E4_DIR) && HAS_E4_ENABLE) - #error "E4_STEP_PIN, E4_DIR_PIN, or E4_ENABLE_PIN not defined for this board." + #if E_STEPPERS > 5 + #if !(PINS_EXIST(E5_STEP, E5_DIR) && HAS_E5_ENABLE) + #error "E5_STEP_PIN, E5_DIR_PIN, or E5_ENABLE_PIN not defined for this board." #endif - #if E_STEPPERS > 5 - #if !(PINS_EXIST(E5_STEP, E5_DIR) && HAS_E5_ENABLE) - #error "E5_STEP_PIN, E5_DIR_PIN, or E5_ENABLE_PIN not defined for this board." + #if E_STEPPERS > 6 + #if !(PINS_EXIST(E6_STEP, E6_DIR) && HAS_E6_ENABLE) + #error "E6_STEP_PIN, E6_DIR_PIN, or E6_ENABLE_PIN not defined for this board." #endif - #if E_STEPPERS > 6 - #if !(PINS_EXIST(E6_STEP, E6_DIR) && HAS_E6_ENABLE) - #error "E6_STEP_PIN, E6_DIR_PIN, or E6_ENABLE_PIN not defined for this board." + #if E_STEPPERS > 7 + #if !(PINS_EXIST(E7_STEP, E7_DIR) && HAS_E7_ENABLE) + #error "E7_STEP_PIN, E7_DIR_PIN, or E7_ENABLE_PIN not defined for this board." #endif - #if E_STEPPERS > 7 - #if !(PINS_EXIST(E7_STEP, E7_DIR) && HAS_E7_ENABLE) - #error "E7_STEP_PIN, E7_DIR_PIN, or E7_ENABLE_PIN not defined for this board." - #endif - #endif // E_STEPPERS > 7 - #endif // E_STEPPERS > 6 - #endif // E_STEPPERS > 5 - #endif // E_STEPPERS > 4 - #endif // E_STEPPERS > 3 - #endif // E_STEPPERS > 2 - #endif // E_STEPPERS > 1 - #endif // E_STEPPERS -#endif + #endif // E_STEPPERS > 7 + #endif // E_STEPPERS > 6 + #endif // E_STEPPERS > 5 + #endif // E_STEPPERS > 4 + #endif // E_STEPPERS > 3 + #endif // E_STEPPERS > 2 + #endif // E_STEPPERS > 1 +#endif // E_STEPPERS /** * Endstop Tests @@ -2951,19 +2955,19 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #endif /** - * Průša MMU2 requirements + * Multi-Material-Unit requirements */ -#if ENABLED(PRUSA_MMU2) +#if HAS_SMUFF && EXTRUDERS > 15 + #error "MMU_MODEL=SMUFF_EMU_MMU2/SMUFF_EMU_MMU2S requires EXTRUDERS <= 15." +#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S #if EXTRUDERS != 5 - #error "PRUSA_MMU2 requires EXTRUDERS = 5." + #error "MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S requires EXTRUDERS = 5." #elif DISABLED(NOZZLE_PARK_FEATURE) - #error "PRUSA_MMU2 requires NOZZLE_PARK_FEATURE. Enable it to continue." - #elif EITHER(PRUSA_MMU2_S_MODE, MMU_EXTRUDER_SENSOR) && DISABLED(FILAMENT_RUNOUT_SENSOR) - #error "PRUSA_MMU2_S_MODE or MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." - #elif BOTH(PRUSA_MMU2_S_MODE, MMU_EXTRUDER_SENSOR) - #error "Enable only one of PRUSA_MMU2_S_MODE or MMU_EXTRUDER_SENSOR." + #error "MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S requires NOZZLE_PARK_FEATURE. Enable it to continue." + #elif EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) && DISABLED(FILAMENT_RUNOUT_SENSOR) + #error "MMU_MODEL=PRUSA_MMU2S or MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." #elif DISABLED(ADVANCED_PAUSE_FEATURE) - static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2."); + static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S/SMUFF_EMU_MMU2/SMUFF_EMU_MMU2S."); #endif #endif diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 5b98382559..293c536584 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -46,7 +46,7 @@ #define MACHINE_CAN_PAUSE 1 #endif -#if ENABLED(PRUSA_MMU2) +#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S #include "../../lcd/menu/menu_mmu2.h" #endif diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index 0a63d90c63..12d0bdd2e2 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -24,7 +24,7 @@ #if BOTH(HAS_LCD_MENU, MMU2_MENUS) -#include "../../feature/mmu2/mmu2.h" +#include "../../feature/mmu/mmu2.h" #include "menu_mmu2.h" #include "menu_item.h" diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index ec0d63a89d..3815a1819e 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -417,16 +417,17 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define NORM_E_DIR(E) do{ E0_DIR_WRITE(E ? INVERT_E0_DIR : !INVERT_E0_DIR); }while(0) #define REV_E_DIR(E) do{ E0_DIR_WRITE(E ? !INVERT_E0_DIR : INVERT_E0_DIR); }while(0) #endif -#elif ENABLED(PRUSA_MMU2) - #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) - #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) -#elif ENABLED(MK2_MULTIPLEXER) // One multiplexed stepper driver, reversed on odd index +#elif HAS_PRUSA_MMU1 // One multiplexed stepper driver, reversed on odd index #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? !INVERT_E0_DIR: INVERT_E0_DIR); }while(0) #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? INVERT_E0_DIR: !INVERT_E0_DIR); }while(0) +#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) + #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) + #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) + #elif E_STEPPERS > 1 #if E_STEPPERS > 7 diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 1cdafe019d..b497fe1fdd 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -73,10 +73,6 @@ #include "../feature/solenoid.h" #endif -#if ENABLED(MK2_MULTIPLEXER) - #include "../feature/snmm.h" -#endif - #if ENABLED(MIXING_EXTRUDER) #include "../feature/mixing.h" #endif @@ -89,8 +85,10 @@ #include "../feature/fanmux.h" #endif -#if ENABLED(PRUSA_MMU2) - #include "../feature/mmu2/mmu2.h" +#if HAS_PRUSA_MMU1 + #include "../feature/mmu/mmu.h" +#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #include "../feature/mmu/mmu2.h" #endif #if HAS_LCD_MENU @@ -863,7 +861,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { mixer.T(new_tool); #endif - #elif ENABLED(PRUSA_MMU2) + #elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S UNUSED(no_move); @@ -1171,8 +1169,6 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]); #endif - TERN_(PRUSA_MMU2, mmu2.tool_change(new_tool)); - TERN_(SWITCHING_NOZZLE_TWO_SERVOS, lower_nozzle(new_tool)); } // (new_tool != old_tool) @@ -1184,7 +1180,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { enable_solenoid_on_active_extruder(); #endif - #if ENABLED(MK2_MULTIPLEXER) + #if HAS_PRUSA_MMU1 if (new_tool >= E_STEPPERS) return invalid_extruder_error(new_tool); select_multiplexed_stepper(new_tool); #endif diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index 2430958895..b993e38460 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -131,9 +131,9 @@ #define PIN_P2_11 P2_11 // Interrupt Capable // -// Průša i3 MK2 Multi Material Multiplexer Support +// Průša i3 MMU1 (Multi Material Multiplexer) Support // -#if ENABLED(MK2_MULTIPLEXER) +#if HAS_PRUSA_MMU1 #define E_MUX0_PIN P1_23 // J8-3 #define E_MUX1_PIN P2_12 // J8-4 #define E_MUX2_PIN P2_11 // J8-5 diff --git a/buildroot/tests/mega2560-tests b/buildroot/tests/mega2560-tests index d3fd5c0192..f4cb0b0956 100755 --- a/buildroot/tests/mega2560-tests +++ b/buildroot/tests/mega2560-tests @@ -66,14 +66,15 @@ exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE | Sle # restore_configs opt_set LCD_LANGUAGE zh_CN +opt_set MMU_MODEL PRUSA_MMU2S opt_set EXTRUDERS 5 opt_set NUM_SERVOS 1 opt_enable ZONESTAR_LCD Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE BOOT_MARLIN_LOGO_ANIMATED \ AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \ NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \ - PRUSA_MMU2 MMU2_MENUS PRUSA_MMU2_S_MODE DIRECT_STEPPING DETECT_BROKEN_ENDSTOP \ + MMU2_MENUS DIRECT_STEPPING DETECT_BROKEN_ENDSTOP \ FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING -exec_test $1 $2 "RAMPS | ZONESTAR + Chinese | MMU2 | Servo | 3-Point + Debug | G38 ..." +exec_test $1 $2 "RAMPS | ZONESTAR + Chinese | MMU2S | Servo | 3-Point + Debug | G38 ..." # # Test MINIRAMBO with PWM_MOTOR_CURRENT and many features diff --git a/platformio.ini b/platformio.ini index 3e565e6c4e..9880a0af88 100644 --- a/platformio.ini +++ b/platformio.ini @@ -91,7 +91,8 @@ default_src_filter = + - - + - - - - - - + - + - - - - - - @@ -99,7 +100,6 @@ default_src_filter = + - - + - - - - - - - - - - - - - @@ -300,7 +300,8 @@ PRINTER_EVENT_LEDS = src_filter=+ TEMP_STAT_LEDS = src_filter=+ MAX7219_DEBUG = src_filter=+ + MIXING_EXTRUDER = src_filter=+ + -PRUSA_MMU2 = src_filter=+ + +HAS_PRUSA_MMU1 = src_filter=+ +HAS_PRUSA_MMU2|HAS_PRUSA_MMU2S = src_filter=+ + PASSWORD_FEATURE = src_filter=+ + ADVANCED_PAUSE_FEATURE = src_filter=+ + + AUTO_POWER_CONTROL = src_filter=+ @@ -308,7 +309,6 @@ HAS_POWER_MONITOR = src_filter=+ + + PROBE_TEMP_COMPENSATION = src_filter=+ + HAS_FILAMENT_SENSOR = src_filter=+ + -MK2_MULTIPLEXER = src_filter=+ EXT_SOLENOID|MANUAL_SOLENOID_CONTROL = src_filter=+ + HAS_CUTTER = src_filter=+ + EXPERIMENTAL_I2CBUS = src_filter=+ + From be8448c71b62b1cf689953006eba03056fcd6af2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 22:02:52 -0500 Subject: [PATCH 02/23] Update platformio.ini --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9880a0af88..1275e43125 100644 --- a/platformio.ini +++ b/platformio.ini @@ -301,7 +301,7 @@ TEMP_STAT_LEDS = src_filter=+ MAX7219_DEBUG = src_filter=+ + MIXING_EXTRUDER = src_filter=+ + HAS_PRUSA_MMU1 = src_filter=+ -HAS_PRUSA_MMU2|HAS_PRUSA_MMU2S = src_filter=+ + +HAS_PRUSA_MMU2S? = src_filter=+ + PASSWORD_FEATURE = src_filter=+ + ADVANCED_PAUSE_FEATURE = src_filter=+ + + AUTO_POWER_CONTROL = src_filter=+ @@ -309,7 +309,7 @@ HAS_POWER_MONITOR = src_filter=+ + + PROBE_TEMP_COMPENSATION = src_filter=+ + HAS_FILAMENT_SENSOR = src_filter=+ + -EXT_SOLENOID|MANUAL_SOLENOID_CONTROL = src_filter=+ + +(EXT|MANUAL)_SOLENOID.* = src_filter=+ + HAS_CUTTER = src_filter=+ + EXPERIMENTAL_I2CBUS = src_filter=+ + MECHANICAL_GANTRY_CAL.+ = src_filter=+ From c8b3dc849de1df36a2a4af581232cfbb2d816f28 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 22:17:24 -0500 Subject: [PATCH 03/23] Config tweaks --- Marlin/src/core/macros.h | 9 --------- Marlin/src/inc/Conditionals_LCD.h | 12 ++++++++++++ Marlin/src/inc/SanityCheck.h | 8 ++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 3de79a9e4d..7948e8ce87 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -516,12 +516,3 @@ #define MAP0(f, x, peek, ...) f(x) MAP_NEXT (peek, MAP1) (f, peek, __VA_ARGS__) #define MAP1(f, x, peek, ...) f(x) MAP_NEXT (peek, MAP0) (f, peek, __VA_ARGS__) #define MAP(f, ...) EVAL512 (MAP1 (f, __VA_ARGS__, (), 0)) - -// -// Multi-Material-Unit models -// -#define PRUSA_MMU1 1 -#define PRUSA_MMU2 2 -#define PRUSA_MMU2S 3 -#define SMUFF_EMU_MMU2 4 -#define SMUFF_EMU_MMU2S 5 diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index d48159f6b5..fa9c8448fb 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -498,6 +498,12 @@ /** * Multi-Material-Unit supported models */ +#define PRUSA_MMU1 1 +#define PRUSA_MMU2 2 +#define PRUSA_MMU2S 3 +#define SMUFF_EMU_MMU2 4 +#define SMUFF_EMU_MMU2S 5 + #ifdef MMU_MODEL #define HAS_MMU 1 #if MMU_MODEL == PRUSA_MMU1 @@ -512,6 +518,12 @@ #endif #endif +#undef PRUSA_MMU1 +#undef PRUSA_MMU2 +#undef PRUSA_MMU2S +#undef SMUFF_EMU_MMU2 +#undef SMUFF_EMU_MMU2S + /** * Extruders have some combination of stepper motors and hotends * so we separate these concepts into the defines: diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ed57c54296..0c98e9f4f9 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -919,13 +919,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Sanity checking for all Průša MMU */ #ifdef SNMM - #error "SNMM is now MMU_MODEL = PRUSA_MMU1. Please update your configuration." + #error "SNMM is obsolete. Define MMU_MODE as PRUSA_MMU1 instead." #elif ENABLED(MK2_MULTIPLEXER) - #error "MK2_MULTIPLEXER is now MMU_MODEL = PRUSA_MMU1. Please update your configuration." + #error "MK2_MULTIPLEXER is obsolete. Define MMU_MODEL as PRUSA_MMU1 instead." #elif ENABLED(PRUSA_MMU2) - #error "PRUSA_MMU2 is now MMU_MODEL = PRUSA_MMU2. Please update your configuration." + #error "PRUSA_MMU2 is obsolete. Define MMU_MODE as PRUSA_MMU2 instead." #elif ENABLED(PRUSA_MMU2_S_MODE) - #error "PRUSA_MMU2_S_MODE is now MMU_MODEL = PRUSA_MMU2S. Please update your configuration." + #error "PRUSA_MMU2_S_MODE is obsolete. Define MMU_MODE as PRUSA_MMU2S instead." #endif /** From 11ab6da9751031823492283a2bac421a5fe7af09 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 22:32:14 -0500 Subject: [PATCH 04/23] Fix up config --- Marlin/Configuration_adv.h | 28 ++++++++++++---------------- Marlin/src/inc/Conditionals_LCD.h | 10 +++++----- Marlin/src/inc/SanityCheck.h | 14 +++++++++----- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d5c047a9e4..e0487887de 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3506,15 +3506,16 @@ //#include "Configuration_Secure.h" // External file with WiFi SSID / Password #endif -#if MMU_MODEL == PRUSA_MMU1 +/** + * Průša Multi-Material Unit (MMU) multiplexer + * Enable in Configuration.h + * + * These devices allow a single stepper driver on the board to drive + * two to eight stepper motors, one at a time, in a manner suitable + * for extruders. + */ +#if HAS_PRUSA_MMU1 /** - * Průša Multi-Material-Unit multiplexed - * Enable in Configuration.h - * - * This device allows one stepper driver on a control board to drive - * two to eight stepper motors, one at a time, in a manner suitable - * for extruders. - * * This option only allows the multiplexer to switch on tool-change. * Additional options to configure custom E moves are pending. * @@ -3524,12 +3525,7 @@ //#define E_MUX0_PIN 40 // Always Required //#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs //#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs -#elif MMU_MODEL == PRUSA_MMU2 || MMU_MODEL == PRUSA_MMU2S - /** - * Průša Multi-Material-Unit v2 - * Enable in Configuration.h - */ - +#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S // Serial port used for communication with MMU2. // For AVR enable the UART port used for the MMU. (e.g., mmuSerial) // For 32-bit boards check your HAL for available serial ports. (e.g., Serial2) @@ -3577,7 +3573,7 @@ * This mode requires a MK3S extruder with a sensor at the extruder idler, like the MMU2S. * See https://help.prusa3d.com/en/guide/3b-mk3s-mk2-5s-extruder-upgrade_41560, step 11 */ - #if MMU_MODEL == PRUSA_MMU2S + #if HAS_PRUSA_MMU2S #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries) #define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/min) @@ -3615,7 +3611,7 @@ //#define MMU2_DEBUG // Write debug info to serial output -#endif // MMU_MODEL == PRUSA_MMU2 || MMU_MODEL == PRUSA_MMU2S +#endif // HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S /** * Advanced Print Counter settings diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index fa9c8448fb..0b9e1fba4b 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -501,19 +501,19 @@ #define PRUSA_MMU1 1 #define PRUSA_MMU2 2 #define PRUSA_MMU2S 3 -#define SMUFF_EMU_MMU2 4 -#define SMUFF_EMU_MMU2S 5 +#define SMUFF_EMU_MMU2 12 +#define SMUFF_EMU_MMU2S 13 #ifdef MMU_MODEL #define HAS_MMU 1 #if MMU_MODEL == PRUSA_MMU1 #define HAS_PRUSA_MMU1 1 - #elif MMU_MODEL == PRUSA_MMU2 || MMU_MODEL == SMUFF_EMU_MMU2 + #elif MMU_MODEL % 10 == PRUSA_MMU2 #define HAS_PRUSA_MMU2 1 - #elif MMU_MODEL == PRUSA_MMU2S || MMU_MODEL == SMUFF_EMU_MMU2S + #elif MMU_MODEL % 10 == PRUSA_MMU2S #define HAS_PRUSA_MMU2S 1 #endif - #if MMU_MODEL == SMUFF_EMU_MMU2 || MMU_MODEL == SMUFF_EMU_MMU2S + #if MMU_MODEL >= SMUFF_EMU_MMU2 #define HAS_SMUFF 1 #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 0c98e9f4f9..41e1cb6d44 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -910,9 +910,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #elif HAS_PRUSA_MMU1 || HAS_SMUFF + #error "Multi-Material-Unit requires 2 or more EXTRUDERS." + #elif ENABLED(SINGLENOZZLE) + #error "SINGLENOZZLE requires 2 or more EXTRUDERS." + #endif /** @@ -2958,16 +2962,16 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) * Multi-Material-Unit requirements */ #if HAS_SMUFF && EXTRUDERS > 15 - #error "MMU_MODEL=SMUFF_EMU_MMU2/SMUFF_EMU_MMU2S requires EXTRUDERS <= 15." + #error "Too many extruders for SMUFF_EMU_MMU2(S). (15 maximum)." #elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S #if EXTRUDERS != 5 - #error "MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S requires EXTRUDERS = 5." + #error "PRUSA_MMU2 / PRUSA_MMU2S requires EXTRUDERS = 5." #elif DISABLED(NOZZLE_PARK_FEATURE) - #error "MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S requires NOZZLE_PARK_FEATURE. Enable it to continue." + #error "PRUSA_MMU2 / PRUSA_MMU2S requires NOZZLE_PARK_FEATURE. Enable it to continue." #elif EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) && DISABLED(FILAMENT_RUNOUT_SENSOR) - #error "MMU_MODEL=PRUSA_MMU2S or MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." + #error "PRUSA_MMU2S or MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." #elif DISABLED(ADVANCED_PAUSE_FEATURE) - static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S/SMUFF_EMU_MMU2/SMUFF_EMU_MMU2S."); + static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / SMUFF_EMU_MMU2(S)."); #endif #endif From 0327ba185842265990d34aa5a4373e71fb9af073 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 22:38:34 -0500 Subject: [PATCH 05/23] Set HAS_PRUSA_MMU2 for S also --- Marlin/Configuration_adv.h | 4 ++-- Marlin/src/MarlinCore.cpp | 6 +++--- Marlin/src/feature/mmu/mmu2.cpp | 8 ++++---- Marlin/src/gcode/config/M220.cpp | 2 +- Marlin/src/gcode/control/T.cpp | 4 ++-- Marlin/src/gcode/feature/pause/M701_M702.cpp | 6 +++--- Marlin/src/gcode/feature/prusa_MMU2/M403.cpp | 4 ++-- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/gcode/parser.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 3 ++- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/menu/menu_main.cpp | 2 +- Marlin/src/module/stepper/indirection.h | 2 +- Marlin/src/module/tool_change.cpp | 4 ++-- 15 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e0487887de..8d18c51f8a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3525,7 +3525,7 @@ //#define E_MUX0_PIN 40 // Always Required //#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs //#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs -#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#elif HAS_PRUSA_MMU2 // Serial port used for communication with MMU2. // For AVR enable the UART port used for the MMU. (e.g., mmuSerial) // For 32-bit boards check your HAL for available serial ports. (e.g., Serial2) @@ -3611,7 +3611,7 @@ //#define MMU2_DEBUG // Write debug info to serial output -#endif // HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#endif // HAS_PRUSA_MMU2 /** * Advanced Print Counter settings diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index caa5114386..847667fbb2 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -213,7 +213,7 @@ #include "feature/controllerfan.h" #endif -#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#if HAS_PRUSA_MMU2 #include "feature/mmu/mmu2.h" #endif @@ -772,7 +772,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { #endif // Update the Průša MMU2 - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 mmu2.mmu_loop(); #endif @@ -1262,7 +1262,7 @@ void setup() { SETUP_RUN(test_tmc_connection(true, true, true, true)); #endif - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 SETUP_RUN(mmu2.init()); #endif diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 5f7cf28cd1..a495e96dbb 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#if HAS_PRUSA_MMU2 #include "mmu2.h" #include "../../lcd/menu/menu_mmu2.h" @@ -162,7 +162,7 @@ uint8_t MMU2::get_current_tool() { return extruder == MMU2_NO_TOOL ? -1 : extruder; } -#if HAS_PRUSA_MMU2S || ENABLED(MMU_EXTRUDER_SENSOR) +#if EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) #define FILAMENT_PRESENT() (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE) #endif @@ -681,7 +681,7 @@ static void mmu2_not_responding() { mmu_idl_sens = 0; } -#else // !HAS_PRUSA_MMU2S && DISABLED(MMU_EXTRUDER_SENSOR) +#else // !HAS_PRUSA_MMU2S && !MMU_EXTRUDER_SENSOR /** * Handle tool change @@ -1064,4 +1064,4 @@ void MMU2::filament_runout() { #endif // HAS_LCD_MENU && MMU2_MENUS -#endif // HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#endif // HAS_PRUSA_MMU2 diff --git a/Marlin/src/gcode/config/M220.cpp b/Marlin/src/gcode/config/M220.cpp index a5df7bccd4..ae31f9798f 100644 --- a/Marlin/src/gcode/config/M220.cpp +++ b/Marlin/src/gcode/config/M220.cpp @@ -37,7 +37,7 @@ */ void GcodeSuite::M220() { - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 static int16_t backup_feedrate_percentage = 100; if (parser.seen('B')) backup_feedrate_percentage = feedrate_percentage; if (parser.seen('R')) feedrate_percentage = backup_feedrate_percentage; diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index ac00b0d196..163223294d 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -27,7 +27,7 @@ #include "../../module/motion.h" #endif -#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#if HAS_PRUSA_MMU2 #include "../../feature/mmu/mmu2.h" #endif @@ -54,7 +54,7 @@ void GcodeSuite::T(const int8_t tool_index) { // Count this command as movement / activity reset_stepper_timeout(); - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 if (parser.string_arg) { mmu2.tool_change(parser.string_arg); // Special commands T?/Tx/Tc return; diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index 35604d8086..a100d462da 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -38,7 +38,7 @@ #include "../../../lcd/marlinui.h" #endif -#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#if HAS_PRUSA_MMU2 #include "../../../feature/mmu/mmu2.h" #endif @@ -98,7 +98,7 @@ void GcodeSuite::M701() { do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); // Load filament - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 mmu2.load_filament_to_nozzle(target_extruder); #else constexpr float purge_length = ADVANCED_PAUSE_PURGE_LENGTH, @@ -198,7 +198,7 @@ void GcodeSuite::M702() { do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); // Unload filament - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 mmu2.unload(); #else #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_UNLOAD_ALL_EXTRUDERS) diff --git a/Marlin/src/gcode/feature/prusa_MMU2/M403.cpp b/Marlin/src/gcode/feature/prusa_MMU2/M403.cpp index 1626a126ef..31d076337a 100644 --- a/Marlin/src/gcode/feature/prusa_MMU2/M403.cpp +++ b/Marlin/src/gcode/feature/prusa_MMU2/M403.cpp @@ -22,7 +22,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#if HAS_PRUSA_MMU2 #include "../../gcode.h" #include "../../../feature/mmu/mmu2.h" @@ -46,4 +46,4 @@ void GcodeSuite::M403() { SERIAL_ECHO_MSG("M403 - bad arguments."); } -#endif // HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#endif // HAS_PRUSA_MMU2 diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 7624957e86..71d48f540d 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -699,7 +699,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 402: M402(); break; // M402: Stow probe #endif - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 case 403: M403(); break; #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 0dac76d923..3e727a49f5 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -735,7 +735,7 @@ private: static void M402(); #endif - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 static void M403(); #endif diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 4daa2e7e62..3d6ee6477f 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -155,7 +155,7 @@ void GCodeParser::parse(char *p) { // Skip spaces to get the numeric part while (*p == ' ') p++; - #if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #if HAS_PRUSA_MMU2 if (letter == 'T') { // check for special MMU2 T?/Tx/Tc commands if (*p == '?' || *p == 'x' || *p == 'c') { diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 0b9e1fba4b..b0b7743306 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -511,6 +511,7 @@ #elif MMU_MODEL % 10 == PRUSA_MMU2 #define HAS_PRUSA_MMU2 1 #elif MMU_MODEL % 10 == PRUSA_MMU2S + #define HAS_PRUSA_MMU2 1 #define HAS_PRUSA_MMU2S 1 #endif #if MMU_MODEL >= SMUFF_EMU_MMU2 @@ -566,7 +567,7 @@ #elif ENABLED(SWITCHING_TOOLHEAD) #define E_STEPPERS EXTRUDERS #define E_MANUAL EXTRUDERS -#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#elif HAS_PRUSA_MMU2 #define E_STEPPERS 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 41e1cb6d44..8dce85e0af 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2963,7 +2963,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) */ #if HAS_SMUFF && EXTRUDERS > 15 #error "Too many extruders for SMUFF_EMU_MMU2(S). (15 maximum)." -#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#elif HAS_PRUSA_MMU2 #if EXTRUDERS != 5 #error "PRUSA_MMU2 / PRUSA_MMU2S requires EXTRUDERS = 5." #elif DISABLED(NOZZLE_PARK_FEATURE) diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 293c536584..b276573b51 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -46,7 +46,7 @@ #define MACHINE_CAN_PAUSE 1 #endif -#if HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#if HAS_PRUSA_MMU2 #include "../../lcd/menu/menu_mmu2.h" #endif diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 3815a1819e..2bb68f4f40 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -423,7 +423,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? !INVERT_E0_DIR: INVERT_E0_DIR); }while(0) #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? INVERT_E0_DIR: !INVERT_E0_DIR); }while(0) -#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#elif HAS_PRUSA_MMU2 #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index b497fe1fdd..db640e34c9 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -87,7 +87,7 @@ #if HAS_PRUSA_MMU1 #include "../feature/mmu/mmu.h" -#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S +#elif HAS_PRUSA_MMU2 #include "../feature/mmu/mmu2.h" #endif @@ -861,7 +861,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { mixer.T(new_tool); #endif - #elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU2S + #elif HAS_PRUSA_MMU2 UNUSED(no_move); From 392ed3c1cca42f2ced3496b9ccc8daff0dceea33 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 22:46:58 -0500 Subject: [PATCH 06/23] Adjust formatting --- Marlin/Configuration.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 1d4087224b..3b518c4c7d 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -159,19 +159,16 @@ /** * Multi-Material Unit + * Set to one of these predefined models: * - * Supported unit models: - * PRUSA_MMU1: Průša MMU1 (This is the multiplexer version) - * PRUSA_MMU2: Průša MMU2 - * PRUSA_MMU2S Průša MMU2S (This mode requires a MK3S extruder with a sensor at the extruder idler) - * SMUFF_EMU_MMU2: Christian Gegg SMUFF (Průša MMU2 emulation mode) - * SMUFF_EMU_MMU2S: Christian Gegg SMUFF (Průša MMU2S emulation mode) + * PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version) + * PRUSA_MMU2 : Průša MMU2 + * PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5) + * SMUFF_EMU_MMU2 : Christian Gegg SMUFF (Průša MMU2 emulation mode) + * SMUFF_EMU_MMU2S : Christian Gegg SMUFF (Průša MMU2S emulation mode) * * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. - * MMU2 requires EXTRUDERS = 5 - * SMUFF supports EXTRUDERS = up to 15 but these are limited to 8 because of Marlin limit - * - * For additional configuration see Configuration_adv.h + * See additional options in Configuration_adv.h. */ //#define MMU_MODEL PRUSA_MMU2 From ee706f6323a347f39c43a2f0b7ca8c8631351c7a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 23:01:13 -0500 Subject: [PATCH 07/23] Set MAX_EXTRUDERS to 15 for SMUFF --- Marlin/src/pins/pins.h | 7 ++++++- Marlin/src/pins/pins_postprocess.h | 10 +++++----- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 4f3397b98d..3f5cb4d018 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -35,7 +35,12 @@ * These numbers are the same in any pin mapping. */ -#define MAX_EXTRUDERS 8 +#if HAS_SMUFF + #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) #define IS_RAMPS_EFB diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index fdf9f095cb..26c271b1a6 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -521,7 +521,7 @@ #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP) #define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR) #define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE) - #if X2_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(X2_STEP) + #if X2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(X2_STEP) #error "No E stepper plug left for X2!" #endif #endif @@ -594,7 +594,7 @@ #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP) #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR) #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE) - #if Y2_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(Y2_STEP) + #if Y2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Y2_STEP) #error "No E stepper plug left for Y2!" #endif #endif @@ -662,7 +662,7 @@ #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP) #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR) #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE) - #if Z2_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(Z2_STEP) + #if Z2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z2_STEP) #error "No E stepper plug left for Z2!" #endif #endif @@ -729,7 +729,7 @@ #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP) #define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR) #define Z3_ENABLE_PIN _EPIN(Z3_E_INDEX, ENABLE) - #if Z3_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(Z3_STEP) + #if Z3_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z3_STEP) #error "No E stepper plug left for Z3!" #endif #endif @@ -796,7 +796,7 @@ #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP) #define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR) #define Z4_ENABLE_PIN _EPIN(Z4_E_INDEX, ENABLE) - #if Z4_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(Z4_STEP) + #if Z4_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z4_STEP) #error "No E stepper plug left for Z4!" #endif #endif 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 eaf90da1ae..eb1e886fa4 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -25,8 +25,8 @@ #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 8 || E_STEPPERS > 8 #error "BIGTREE GTR V1.0 supports up to 8 hotends / E-steppers." -#elif HOTENDS > MAX_EXTRUDERS || E_STEPPERS > MAX_EXTRUDERS - #error "Marlin extruder/hotends limit! Increase MAX_EXTRUDERS to continue." +#elif HOTENDS > MAX_E_STEPPERS || E_STEPPERS > MAX_E_STEPPERS + #error "Marlin extruder/hotends limit! Increase MAX_E_STEPPERS to continue." #endif #define BOARD_INFO_NAME "BTT GTR V1.0" From 16c79ffb21eb9567707a98a589d535d9c92920b6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 23:01:43 -0500 Subject: [PATCH 08/23] Drop some MAX_EXTRUDERS checks --- Marlin/src/module/settings.cpp | 243 +++++++++++++-------------------- 1 file changed, 96 insertions(+), 147 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index d01486a80d..d77ffe13cc 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1058,46 +1058,30 @@ void MarlinSettings::postprocess() { #if AXIS_IS_TMC(Z4) tmc_stepper_current.Z4 = stepperZ4.getMilliamps(); #endif - #if MAX_EXTRUDERS - #if AXIS_IS_TMC(E0) - tmc_stepper_current.E0 = stepperE0.getMilliamps(); - #endif - #if MAX_EXTRUDERS > 1 - #if AXIS_IS_TMC(E1) - tmc_stepper_current.E1 = stepperE1.getMilliamps(); - #endif - #if MAX_EXTRUDERS > 2 - #if AXIS_IS_TMC(E2) - tmc_stepper_current.E2 = stepperE2.getMilliamps(); - #endif - #if MAX_EXTRUDERS > 3 - #if AXIS_IS_TMC(E3) - tmc_stepper_current.E3 = stepperE3.getMilliamps(); - #endif - #if MAX_EXTRUDERS > 4 - #if AXIS_IS_TMC(E4) - tmc_stepper_current.E4 = stepperE4.getMilliamps(); - #endif - #if MAX_EXTRUDERS > 5 - #if AXIS_IS_TMC(E5) - tmc_stepper_current.E5 = stepperE5.getMilliamps(); - #endif - #if MAX_EXTRUDERS > 6 - #if AXIS_IS_TMC(E6) - tmc_stepper_current.E6 = stepperE6.getMilliamps(); - #endif - #if MAX_EXTRUDERS > 7 - #if AXIS_IS_TMC(E7) - tmc_stepper_current.E7 = stepperE7.getMilliamps(); - #endif - #endif // MAX_EXTRUDERS > 7 - #endif // MAX_EXTRUDERS > 6 - #endif // MAX_EXTRUDERS > 5 - #endif // MAX_EXTRUDERS > 4 - #endif // MAX_EXTRUDERS > 3 - #endif // MAX_EXTRUDERS > 2 - #endif // MAX_EXTRUDERS > 1 - #endif // MAX_EXTRUDERS + #if AXIS_IS_TMC(E0) + tmc_stepper_current.E0 = stepperE0.getMilliamps(); + #endif + #if AXIS_IS_TMC(E1) + tmc_stepper_current.E1 = stepperE1.getMilliamps(); + #endif + #if AXIS_IS_TMC(E2) + tmc_stepper_current.E2 = stepperE2.getMilliamps(); + #endif + #if AXIS_IS_TMC(E3) + tmc_stepper_current.E3 = stepperE3.getMilliamps(); + #endif + #if AXIS_IS_TMC(E4) + tmc_stepper_current.E4 = stepperE4.getMilliamps(); + #endif + #if AXIS_IS_TMC(E5) + tmc_stepper_current.E5 = stepperE5.getMilliamps(); + #endif + #if AXIS_IS_TMC(E6) + tmc_stepper_current.E6 = stepperE6.getMilliamps(); + #endif + #if AXIS_IS_TMC(E7) + tmc_stepper_current.E7 = stepperE7.getMilliamps(); + #endif #endif EEPROM_WRITE(tmc_stepper_current); } @@ -1134,46 +1118,30 @@ void MarlinSettings::postprocess() { #if AXIS_HAS_STEALTHCHOP(Z4) tmc_hybrid_threshold.Z4 = stepperZ4.get_pwm_thrs(); #endif - #if MAX_EXTRUDERS - #if AXIS_HAS_STEALTHCHOP(E0) - tmc_hybrid_threshold.E0 = stepperE0.get_pwm_thrs(); - #endif - #if MAX_EXTRUDERS > 1 - #if AXIS_HAS_STEALTHCHOP(E1) - tmc_hybrid_threshold.E1 = stepperE1.get_pwm_thrs(); - #endif - #if MAX_EXTRUDERS > 2 - #if AXIS_HAS_STEALTHCHOP(E2) - tmc_hybrid_threshold.E2 = stepperE2.get_pwm_thrs(); - #endif - #if MAX_EXTRUDERS > 3 - #if AXIS_HAS_STEALTHCHOP(E3) - tmc_hybrid_threshold.E3 = stepperE3.get_pwm_thrs(); - #endif - #if MAX_EXTRUDERS > 4 - #if AXIS_HAS_STEALTHCHOP(E4) - tmc_hybrid_threshold.E4 = stepperE4.get_pwm_thrs(); - #endif - #if MAX_EXTRUDERS > 5 - #if AXIS_HAS_STEALTHCHOP(E5) - tmc_hybrid_threshold.E5 = stepperE5.get_pwm_thrs(); - #endif - #if MAX_EXTRUDERS > 6 - #if AXIS_HAS_STEALTHCHOP(E6) - tmc_hybrid_threshold.E6 = stepperE6.get_pwm_thrs(); - #endif - #if MAX_EXTRUDERS > 7 - #if AXIS_HAS_STEALTHCHOP(E7) - tmc_hybrid_threshold.E7 = stepperE7.get_pwm_thrs(); - #endif - #endif // MAX_EXTRUDERS > 7 - #endif // MAX_EXTRUDERS > 6 - #endif // MAX_EXTRUDERS > 5 - #endif // MAX_EXTRUDERS > 4 - #endif // MAX_EXTRUDERS > 3 - #endif // MAX_EXTRUDERS > 2 - #endif // MAX_EXTRUDERS > 1 - #endif // MAX_EXTRUDERS + #if AXIS_HAS_STEALTHCHOP(E0) + tmc_hybrid_threshold.E0 = stepperE0.get_pwm_thrs(); + #endif + #if AXIS_HAS_STEALTHCHOP(E1) + tmc_hybrid_threshold.E1 = stepperE1.get_pwm_thrs(); + #endif + #if AXIS_HAS_STEALTHCHOP(E2) + tmc_hybrid_threshold.E2 = stepperE2.get_pwm_thrs(); + #endif + #if AXIS_HAS_STEALTHCHOP(E3) + tmc_hybrid_threshold.E3 = stepperE3.get_pwm_thrs(); + #endif + #if AXIS_HAS_STEALTHCHOP(E4) + tmc_hybrid_threshold.E4 = stepperE4.get_pwm_thrs(); + #endif + #if AXIS_HAS_STEALTHCHOP(E5) + tmc_hybrid_threshold.E5 = stepperE5.get_pwm_thrs(); + #endif + #if AXIS_HAS_STEALTHCHOP(E6) + tmc_hybrid_threshold.E6 = stepperE6.get_pwm_thrs(); + #endif + #if AXIS_HAS_STEALTHCHOP(E7) + tmc_hybrid_threshold.E7 = stepperE7.get_pwm_thrs(); + #endif #else const tmc_hybrid_threshold_t tmc_hybrid_threshold = { .X = 100, .Y = 100, .Z = 3, @@ -1209,73 +1177,54 @@ void MarlinSettings::postprocess() { { _FIELD_TEST(tmc_stealth_enabled); - tmc_stealth_enabled_t tmc_stealth_enabled = { false, false, false, false, false, false, false, false, false, false, false, false, false }; - - #if HAS_STEALTHCHOP - #if AXIS_HAS_STEALTHCHOP(X) - tmc_stealth_enabled.X = stepperX.get_stored_stealthChop(); - #endif - #if AXIS_HAS_STEALTHCHOP(Y) - tmc_stealth_enabled.Y = stepperY.get_stored_stealthChop(); - #endif - #if AXIS_HAS_STEALTHCHOP(Z) - tmc_stealth_enabled.Z = stepperZ.get_stored_stealthChop(); - #endif - #if AXIS_HAS_STEALTHCHOP(X2) - tmc_stealth_enabled.X2 = stepperX2.get_stored_stealthChop(); - #endif - #if AXIS_HAS_STEALTHCHOP(Y2) - tmc_stealth_enabled.Y2 = stepperY2.get_stored_stealthChop(); - #endif - #if AXIS_HAS_STEALTHCHOP(Z2) - tmc_stealth_enabled.Z2 = stepperZ2.get_stored_stealthChop(); - #endif - #if AXIS_HAS_STEALTHCHOP(Z3) - tmc_stealth_enabled.Z3 = stepperZ3.get_stored_stealthChop(); - #endif - #if AXIS_HAS_STEALTHCHOP(Z4) - tmc_stealth_enabled.Z4 = stepperZ4.get_stored_stealthChop(); - #endif - #if MAX_EXTRUDERS - #if AXIS_HAS_STEALTHCHOP(E0) - tmc_stealth_enabled.E0 = stepperE0.get_stored_stealthChop(); - #endif - #if MAX_EXTRUDERS > 1 - #if AXIS_HAS_STEALTHCHOP(E1) - tmc_stealth_enabled.E1 = stepperE1.get_stored_stealthChop(); - #endif - #if MAX_EXTRUDERS > 2 - #if AXIS_HAS_STEALTHCHOP(E2) - tmc_stealth_enabled.E2 = stepperE2.get_stored_stealthChop(); - #endif - #if MAX_EXTRUDERS > 3 - #if AXIS_HAS_STEALTHCHOP(E3) - tmc_stealth_enabled.E3 = stepperE3.get_stored_stealthChop(); - #endif - #if MAX_EXTRUDERS > 4 - #if AXIS_HAS_STEALTHCHOP(E4) - tmc_stealth_enabled.E4 = stepperE4.get_stored_stealthChop(); - #endif - #if MAX_EXTRUDERS > 5 - #if AXIS_HAS_STEALTHCHOP(E5) - tmc_stealth_enabled.E5 = stepperE5.get_stored_stealthChop(); - #endif - #if MAX_EXTRUDERS > 6 - #if AXIS_HAS_STEALTHCHOP(E6) - tmc_stealth_enabled.E6 = stepperE6.get_stored_stealthChop(); - #endif - #if MAX_EXTRUDERS > 7 - #if AXIS_HAS_STEALTHCHOP(E7) - tmc_stealth_enabled.E7 = stepperE7.get_stored_stealthChop(); - #endif - #endif // MAX_EXTRUDERS > 7 - #endif // MAX_EXTRUDERS > 6 - #endif // MAX_EXTRUDERS > 5 - #endif // MAX_EXTRUDERS > 4 - #endif // MAX_EXTRUDERS > 3 - #endif // MAX_EXTRUDERS > 2 - #endif // MAX_EXTRUDERS > 1 - #endif // MAX_EXTRUDERS + tmc_stealth_enabled_t tmc_stealth_enabled = { false }; + #if AXIS_HAS_STEALTHCHOP(X) + tmc_stealth_enabled.X = stepperX.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(Y) + tmc_stealth_enabled.Y = stepperY.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(Z) + tmc_stealth_enabled.Z = stepperZ.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(X2) + tmc_stealth_enabled.X2 = stepperX2.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(Y2) + tmc_stealth_enabled.Y2 = stepperY2.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(Z2) + tmc_stealth_enabled.Z2 = stepperZ2.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(Z3) + tmc_stealth_enabled.Z3 = stepperZ3.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(Z4) + tmc_stealth_enabled.Z4 = stepperZ4.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(E0) + tmc_stealth_enabled.E0 = stepperE0.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(E1) + tmc_stealth_enabled.E1 = stepperE1.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(E2) + tmc_stealth_enabled.E2 = stepperE2.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(E3) + tmc_stealth_enabled.E3 = stepperE3.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(E4) + tmc_stealth_enabled.E4 = stepperE4.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(E5) + tmc_stealth_enabled.E5 = stepperE5.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(E6) + tmc_stealth_enabled.E6 = stepperE6.get_stored_stealthChop(); + #endif + #if AXIS_HAS_STEALTHCHOP(E7) + tmc_stealth_enabled.E7 = stepperE7.get_stored_stealthChop(); #endif EEPROM_WRITE(tmc_stealth_enabled); } From 19ae18979ee30536ab584b54f98cf8f95732bf3a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 23:02:50 -0500 Subject: [PATCH 09/23] MMU2S is also MMU2 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 1275e43125..e49808a70f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -301,7 +301,7 @@ TEMP_STAT_LEDS = src_filter=+ MAX7219_DEBUG = src_filter=+ + MIXING_EXTRUDER = src_filter=+ + HAS_PRUSA_MMU1 = src_filter=+ -HAS_PRUSA_MMU2S? = src_filter=+ + +HAS_PRUSA_MMU2 = src_filter=+ + PASSWORD_FEATURE = src_filter=+ + ADVANCED_PAUSE_FEATURE = src_filter=+ + + AUTO_POWER_CONTROL = src_filter=+ From ca34edc5b0efec395c17948c6d59511b362a8285 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Oct 2020 23:51:51 -0500 Subject: [PATCH 10/23] Misc adjustments --- Marlin/src/feature/mmu/mmu2.cpp | 4 ++-- Marlin/src/gcode/control/T.cpp | 2 +- Marlin/src/lcd/menu/menu_main.cpp | 2 +- Marlin/src/lcd/menu/menu_mmu2.cpp | 32 ++++++++++++------------- Marlin/src/module/stepper/indirection.h | 12 ++++++---- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index a495e96dbb..eb5ac1906e 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -121,7 +121,7 @@ char MMU2::rx_buffer[MMU_RX_SIZE], MMU2::tx_buffer[MMU_TX_SIZE]; #endif ; -#endif // MMU2_MENUS +#endif MMU2::MMU2() { rx_buffer[0] = '\0'; @@ -755,7 +755,7 @@ static void mmu2_not_responding() { set_runout_valid(true); #endif - } + } #endif // HAS_PRUSA_MMU2S diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index 163223294d..592b2b3dce 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -40,7 +40,7 @@ * F[units/min] Set the movement feedrate * S1 Don't move the tool in XY after change * - * For PRUSA_MMU2/PRUSA_MMU2S/SMUFF_EMU_MMU2PRUSA_MMU2S: + * For PRUSA_MMU2(S) and SMUFF_EMU_MMU2(S) * T[n] Gcode to extrude at least 38.10 mm at feedrate 19.02 mm/s must follow immediately to load to extruder wheels. * T? Gcode to extrude shouldn't have to follow. Load to extruder wheels is done automatically. * Tx Same as T?, but nozzle doesn't have to be preheated. Tc requires a preheated nozzle to finish filament load. diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index b276573b51..1b008e9dbe 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -46,7 +46,7 @@ #define MACHINE_CAN_PAUSE 1 #endif -#if HAS_PRUSA_MMU2 +#if ENABLED(MMU2_MENUS) #include "../../lcd/menu/menu_mmu2.h" #endif diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index 12d0bdd2e2..8a34e7d296 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -28,9 +28,6 @@ #include "menu_mmu2.h" #include "menu_item.h" -uint8_t currentTool; -bool mmuMenuWait; - // // Load Filament // @@ -123,9 +120,12 @@ void menu_mmu2() { // T* Choose Filament // -inline void action_mmu2_choose(const uint8_t tool) { - currentTool = tool; - mmuMenuWait = false; +uint8_t feeder_index; +bool wait_for_mmu_menu; + +inline void action_mmu2_chosen(const uint8_t index) { + feeder_index = index; + wait_for_mmu_menu = false; } void menu_mmu2_choose_filament() { @@ -133,7 +133,7 @@ void menu_mmu2_choose_filament() { #if LCD_HEIGHT > 2 STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_DEFAULT|SS_INVERT); #endif - LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_choose(MenuItemBase::itemIndex); }); + LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_chosen(MenuItemBase::itemIndex); }); END_MENU(); } @@ -142,32 +142,32 @@ void menu_mmu2_choose_filament() { // void menu_mmu2_pause() { - currentTool = mmu2.get_current_tool(); + feeder_index = mmu2.get_current_tool(); START_MENU(); #if LCD_HEIGHT > 2 STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, SS_DEFAULT|SS_INVERT); #endif - ACTION_ITEM(MSG_MMU2_RESUME, []{ mmuMenuWait = false; }); + ACTION_ITEM(MSG_MMU2_RESUME, []{ wait_for_mmu_menu = false; }); ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, []{ mmu2.unload(); }); - ACTION_ITEM(MSG_MMU2_LOAD_FILAMENT, []{ mmu2.load_filament(currentTool); }); - ACTION_ITEM(MSG_MMU2_LOAD_TO_NOZZLE, []{ mmu2.load_filament_to_nozzle(currentTool); }); + ACTION_ITEM(MSG_MMU2_LOAD_FILAMENT, []{ mmu2.load_filament(feeder_index); }); + ACTION_ITEM(MSG_MMU2_LOAD_TO_NOZZLE, []{ mmu2.load_filament_to_nozzle(feeder_index); }); END_MENU(); } void mmu2_M600() { ui.defer_status_screen(); ui.goto_screen(menu_mmu2_pause); - mmuMenuWait = true; - while (mmuMenuWait) idle(); + wait_for_mmu_menu = true; + while (wait_for_mmu_menu) idle(); } uint8_t mmu2_choose_filament() { ui.defer_status_screen(); ui.goto_screen(menu_mmu2_choose_filament); - mmuMenuWait = true; - while (mmuMenuWait) idle(); + wait_for_mmu_menu = true; + while (wait_for_mmu_menu) idle(); ui.return_to_status(); - return currentTool; + return feeder_index; } #endif // HAS_LCD_MENU && MMU2_MENUS diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 2bb68f4f40..dfdd63b05b 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -418,16 +418,18 @@ 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_MMU1 // One multiplexed stepper driver, reversed on odd index - #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? !INVERT_E0_DIR: INVERT_E0_DIR); }while(0) - #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? INVERT_E0_DIR: !INVERT_E0_DIR); }while(0) - #elif HAS_PRUSA_MMU2 + #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) +#elif HAS_PRUSA_MMU1 // One multiplexed stepper driver, reversed on odd index + + #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? !INVERT_E0_DIR: INVERT_E0_DIR); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? INVERT_E0_DIR: !INVERT_E0_DIR); }while(0) + #elif E_STEPPERS > 1 #if E_STEPPERS > 7 From 47ad2caab2134d2a20ecf31bef23dc5afd746c36 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 28 Oct 2020 00:26:27 -0500 Subject: [PATCH 11/23] Towards MMU2 without LCD --- Marlin/src/feature/mmu/mmu2.cpp | 297 ++++++++++++++++---------------- Marlin/src/feature/mmu/mmu2.h | 20 +-- Marlin/src/inc/SanityCheck.h | 42 +++-- 3 files changed, 178 insertions(+), 181 deletions(-) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index eb5ac1906e..27679b48ee 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -105,23 +105,19 @@ int16_t MMU2::version = -1, MMU2::buildnr = -1; millis_t MMU2::prev_request, MMU2::prev_P0_request; char MMU2::rx_buffer[MMU_RX_SIZE], MMU2::tx_buffer[MMU_TX_SIZE]; -#if BOTH(HAS_LCD_MENU, MMU2_MENUS) +struct E_Step { + float extrude; //!< extrude distance in mm + feedRate_t feedRate; //!< feed rate in mm/s +}; - struct E_Step { - float extrude; //!< extrude distance in mm - feedRate_t feedRate; //!< feed rate in mm/s - }; - - static constexpr E_Step - ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE } - , load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE } - #if HAS_PRUSA_MMU2S - , can_load_sequence[] PROGMEM = { MMU2_CAN_LOAD_SEQUENCE } - , can_load_increment_sequence[] PROGMEM = { MMU2_CAN_LOAD_INCREMENT_SEQUENCE } - #endif - ; - -#endif +static constexpr E_Step + ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE } + , load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE } + #if HAS_PRUSA_MMU2S + , can_load_sequence[] PROGMEM = { MMU2_CAN_LOAD_SEQUENCE } + , can_load_increment_sequence[] PROGMEM = { MMU2_CAN_LOAD_INCREMENT_SEQUENCE } + #endif +; MMU2::MMU2() { rx_buffer[0] = '\0'; @@ -906,162 +902,159 @@ void MMU2::filament_runout() { DEBUG_ECHOLNPGM(" succeeded."); return true; } + #endif -#if BOTH(HAS_LCD_MENU, MMU2_MENUS) +// Load filament into MMU2 +void MMU2::load_filament(const uint8_t index) { + if (!enabled) return; + command(MMU_CMD_L0 + index); + manage_response(false, false); + BUZZ(200, 404); +} - // Load filament into MMU2 - void MMU2::load_filament(const uint8_t index) { - if (!enabled) return; - command(MMU_CMD_L0 + index); +/** + * Switch material and load to nozzle + */ +bool MMU2::load_filament_to_nozzle(const uint8_t index) { + + if (!enabled) return false; + + if (thermalManager.tooColdToExtrude(active_extruder)) { + BUZZ(200, 404); + LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); + return false; + } + + command(MMU_CMD_T0 + index); + manage_response(true, true); + + const bool success = load_to_gears(); + if (success) { + mmu_loop(); + extruder = index; + active_extruder = 0; + load_to_nozzle(); + BUZZ(200, 404); + } + return success; +} + +/** + * Load filament to nozzle of multimaterial printer + * + * This function is used only only after T? (user select filament) and M600 (change filament). + * It is not used after T0 .. T4 command (select filament), in such case, gcode is responsible for loading + * filament to nozzle. + */ +void MMU2::load_to_nozzle() { + if (!enabled) return; + execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence)); +} + +bool MMU2::eject_filament(const uint8_t index, const bool recover) { + + if (!enabled) return false; + + if (thermalManager.tooColdToExtrude(active_extruder)) { + BUZZ(200, 404); + LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); + return false; + } + + LCD_MESSAGEPGM(MSG_MMU2_EJECTING_FILAMENT); + + ENABLE_AXIS_E0(); + current_position.e -= MMU2_FILAMENTCHANGE_EJECT_FEED; + line_to_current_position(MMM_TO_MMS(2500)); + planner.synchronize(); + command(MMU_CMD_E0 + index); + manage_response(false, false); + + if (recover) { + LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER); + BUZZ(200, 404); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR)); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"))); + wait_for_user_response(); + BUZZ(200, 404); + BUZZ(200, 404); + + command(MMU_CMD_R0); manage_response(false, false); + } + + ui.reset_status(); + + // no active tool + extruder = MMU2_NO_TOOL; + + set_runout_valid(false); + + BUZZ(200, 404); + + DISABLE_AXIS_E0(); + + return true; +} + +/** + * Unload from hotend and retract to MMU + */ +bool MMU2::unload() { + + if (!enabled) return false; + + if (thermalManager.tooColdToExtrude(active_extruder)) { BUZZ(200, 404); + LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); + return false; } - /** - * Switch material and load to nozzle - */ - bool MMU2::load_filament_to_nozzle(const uint8_t index) { + filament_ramming(); - if (!enabled) return false; + command(MMU_CMD_U0); + manage_response(false, true); - if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); - LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); - return false; - } + BUZZ(200, 404); - command(MMU_CMD_T0 + index); - manage_response(true, true); + // no active tool + extruder = MMU2_NO_TOOL; - const bool success = load_to_gears(); - if (success) { - mmu_loop(); - extruder = index; - active_extruder = 0; - load_to_nozzle(); - BUZZ(200, 404); - } - return success; - } + set_runout_valid(false); - /** - * Load filament to nozzle of multimaterial printer - * - * This function is used only only after T? (user select filament) and M600 (change filament). - * It is not used after T0 .. T4 command (select filament), in such case, gcode is responsible for loading - * filament to nozzle. - */ - void MMU2::load_to_nozzle() { - if (!enabled) return; - execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence)); - } + return true; +} - bool MMU2::eject_filament(const uint8_t index, const bool recover) { +/** + * Unload sequence to optimize shape of the tip of the unloaded filament + */ +void MMU2::filament_ramming() { + execute_extruder_sequence((const E_Step *)ramming_sequence, sizeof(ramming_sequence) / sizeof(E_Step)); +} - if (!enabled) return false; +void MMU2::execute_extruder_sequence(const E_Step * sequence, int steps) { - if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); - LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); - return false; - } + planner.synchronize(); + ENABLE_AXIS_E0(); - LCD_MESSAGEPGM(MSG_MMU2_EJECTING_FILAMENT); + const E_Step* step = sequence; - ENABLE_AXIS_E0(); - current_position.e -= MMU2_FILAMENTCHANGE_EJECT_FEED; - line_to_current_position(2500 / 60); + LOOP_L_N(i, steps) { + const float es = pgm_read_float(&(step->extrude)); + const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate)); + + DEBUG_ECHO_START(); + DEBUG_ECHOLNPAIR("E step ", es, "/", fr_mm_m); + + current_position.e += es; + line_to_current_position(MMM_TO_MMS(fr_mm_m)); planner.synchronize(); - command(MMU_CMD_E0 + index); - manage_response(false, false); - if (recover) { - LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER); - BUZZ(200, 404); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR)); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"))); - wait_for_user_response(); - BUZZ(200, 404); - BUZZ(200, 404); - - command(MMU_CMD_R0); - manage_response(false, false); - } - - ui.reset_status(); - - // no active tool - extruder = MMU2_NO_TOOL; - - set_runout_valid(false); - - BUZZ(200, 404); - - DISABLE_AXIS_E0(); - - return true; + step++; } - /** - * Unload from hotend and retract to MMU - */ - bool MMU2::unload() { - - if (!enabled) return false; - - if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); - LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); - return false; - } - - filament_ramming(); - - command(MMU_CMD_U0); - manage_response(false, true); - - BUZZ(200, 404); - - // no active tool - extruder = MMU2_NO_TOOL; - - set_runout_valid(false); - - return true; - } - - /** - * Unload sequence to optimize shape of the tip of the unloaded filament - */ - void MMU2::filament_ramming() { - execute_extruder_sequence((const E_Step *)ramming_sequence, sizeof(ramming_sequence) / sizeof(E_Step)); - } - - void MMU2::execute_extruder_sequence(const E_Step * sequence, int steps) { - - planner.synchronize(); - ENABLE_AXIS_E0(); - - const E_Step* step = sequence; - - LOOP_L_N(i, steps) { - const float es = pgm_read_float(&(step->extrude)); - const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate)); - - DEBUG_ECHO_START(); - DEBUG_ECHOLNPAIR("E step ", es, "/", fr_mm_m); - - current_position.e += es; - line_to_current_position(MMM_TO_MMS(fr_mm_m)); - planner.synchronize(); - - step++; - } - - DISABLE_AXIS_E0(); - } - -#endif // HAS_LCD_MENU && MMU2_MENUS + DISABLE_AXIS_E0(); +} #endif // HAS_PRUSA_MMU2 diff --git a/Marlin/src/feature/mmu/mmu2.h b/Marlin/src/feature/mmu/mmu2.h index 23a5965d3c..09ff3b6683 100644 --- a/Marlin/src/feature/mmu/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -49,13 +49,11 @@ public: static uint8_t get_current_tool(); static void set_filament_type(const uint8_t index, const uint8_t type); - #if BOTH(HAS_LCD_MENU, MMU2_MENUS) - static bool unload(); - static void load_filament(uint8_t); - static void load_all(); - static bool load_filament_to_nozzle(const uint8_t index); - static bool eject_filament(const uint8_t index, const bool recover); - #endif + static bool unload(); + static void load_filament(uint8_t); + static void load_all(); + static bool load_filament_to_nozzle(const uint8_t index); + static bool eject_filament(const uint8_t index, const bool recover); private: static bool rx_str_P(const char* str); @@ -72,11 +70,9 @@ private: static bool get_response(); static void manage_response(const bool move_axes, const bool turn_off_nozzle); - #if BOTH(HAS_LCD_MENU, MMU2_MENUS) - static void load_to_nozzle(); - static void filament_ramming(); - static void execute_extruder_sequence(const E_Step * sequence, int steps); - #endif + static void load_to_nozzle(); + static void filament_ramming(); + static void execute_extruder_sequence(const E_Step * sequence, int steps); static void filament_runout(); diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8dce85e0af..955705b50d 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -874,6 +874,31 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "INDIVIDUAL_AXIS_HOMING_MENU is incompatible with DELTA kinematics." #endif +/** + * Multi-Material-Unit requirements + */ +#if HAS_PRUSA_MMU2 + #if EXTRUDERS != 5 + #undef SINGLENOZZLE + #error "PRUSA_MMU2(S) requires exactly 5 EXTRUDERS. Please update your Configuration." + #elif DISABLED(NOZZLE_PARK_FEATURE) + #error "PRUSA_MMU2(S) requires NOZZLE_PARK_FEATURE. Enable it to continue." + #elif ENABLED(HAS_PRUSA_MMU2S) && DISABLED(FILAMENT_RUNOUT_SENSOR) + #error "PRUSA_MMU2S requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." + #elif ENABLED(MMU_EXTRUDER_SENSOR) && DISABLED(FILAMENT_RUNOUT_SENSOR) + #error "MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." + #elif HAS_PRUSA_MMU2S && !HAS_LCD_MENU + #error "PRUSA_MMU2S requires an LCD supporting MarlinUI to be enabled." + #elif ENABLED(MMU_EXTRUDER_SENSOR) && !HAS_LCD_MENU + #error "MMU_EXTRUDER_SENSOR requires an LCD supporting MarlinUI to be enabled." + #elif DISABLED(ADVANCED_PAUSE_FEATURE) + static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / SMUFF_EMU_MMU2(S)."); + #endif +#endif +#if HAS_SMUFF && EXTRUDERS > 15 + #error "Too many extruders for SMUFF_EMU_MMU2(S). (15 maximum)." +#endif + /** * Options only for EXTRUDERS > 1 */ @@ -2958,23 +2983,6 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #endif #endif -/** - * Multi-Material-Unit requirements - */ -#if HAS_SMUFF && EXTRUDERS > 15 - #error "Too many extruders for SMUFF_EMU_MMU2(S). (15 maximum)." -#elif HAS_PRUSA_MMU2 - #if EXTRUDERS != 5 - #error "PRUSA_MMU2 / PRUSA_MMU2S requires EXTRUDERS = 5." - #elif DISABLED(NOZZLE_PARK_FEATURE) - #error "PRUSA_MMU2 / PRUSA_MMU2S requires NOZZLE_PARK_FEATURE. Enable it to continue." - #elif EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) && DISABLED(FILAMENT_RUNOUT_SENSOR) - #error "PRUSA_MMU2S or MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." - #elif DISABLED(ADVANCED_PAUSE_FEATURE) - static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / SMUFF_EMU_MMU2(S)."); - #endif -#endif - /** * Advanced PRINTCOUNTER settings */ From df092e48ea6a85ed035df312c099127e0c5b6120 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Wed, 28 Oct 2020 08:47:06 +0100 Subject: [PATCH 12/23] Shrink some remarks --- Marlin/src/gcode/config/M220.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/config/M220.cpp b/Marlin/src/gcode/config/M220.cpp index ae31f9798f..bb61621fea 100644 --- a/Marlin/src/gcode/config/M220.cpp +++ b/Marlin/src/gcode/config/M220.cpp @@ -31,7 +31,7 @@ * * Report the current speed percentage factor if no parameter is specified * - * With MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S/SMUFF_EMU_MMU2/SMUFF_EMU_MMU2S... + * With MMU_MODEL=PRUSA_MMU2(S)/SMUFF_EMU_MMU2(S)... * B : Flag to back up the current factor * R : Flag to restore the last-saved factor */ From 611d8da00d89837ff5b882058f5585bc91672007 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Wed, 28 Oct 2020 08:49:40 +0100 Subject: [PATCH 13/23] Shrink remarks message --- Marlin/src/gcode/gcode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 3e727a49f5..87f832ddf1 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -181,7 +181,7 @@ * M217 - Set filament swap parameters: "M217 S P R". (Requires SINGLENOZZLE) * M218 - Set/get a tool offset: "M218 T X Y". (Requires 2 or more extruders) * M220 - Set Feedrate Percentage: "M220 S" (i.e., "FR" on the LCD) - * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires MMU_MODEL=PRUSA_MMU2/PRUSA_MMU2S/SMUFF_EMU_MMU2/SMUFF_EMU_MMU2S) + * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires MMU_MODEL=PRUSA_MMU2(S)/SMUFF_EMU_MMU2(S)) * M221 - Set Flow Percentage: "M221 S" * M226 - Wait until a pin is in a given state: "M226 P S" (Requires DIRECT_PIN_CONTROL) * M240 - Trigger a camera to take a photograph. (Requires PHOTO_GCODE) From f5894437c5f8ce85a5d4758320e12711f14395d4 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Wed, 28 Oct 2020 10:06:33 +0100 Subject: [PATCH 14/23] Reduce smuff supported extruders Due to some changes that will be done soon on smuff firmware, next release, max supported extruders will be reduced --- Marlin/src/inc/SanityCheck.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 955705b50d..f07445f156 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -895,8 +895,8 @@ 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) / SMUFF_EMU_MMU2(S)."); #endif #endif -#if HAS_SMUFF && EXTRUDERS > 15 - #error "Too many extruders for SMUFF_EMU_MMU2(S). (15 maximum)." +#if HAS_SMUFF && EXTRUDERS > 12 + #error "Too many extruders for SMUFF_EMU_MMU2(S). (12 maximum)." #endif /** From da373640b8f6bf7740ef322b2464a7e5a1e2796c Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Wed, 28 Oct 2020 10:09:34 +0100 Subject: [PATCH 15/23] Reduce smuff supported colors Next smuff firmware release new limit --- Marlin/src/pins/pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 3f5cb4d018..0740a2b93e 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -36,7 +36,7 @@ */ #if HAS_SMUFF - #define MAX_EXTRUDERS 15 + #define MAX_EXTRUDERS 12 #else #define MAX_EXTRUDERS 8 #endif From 58e1bcf39edf9743d268a3b4bb50839725d92a53 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Wed, 28 Oct 2020 11:40:59 +0100 Subject: [PATCH 16/23] Remove senseless #undef --- Marlin/src/inc/SanityCheck.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f07445f156..45cda8081c 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -879,7 +879,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if HAS_PRUSA_MMU2 #if EXTRUDERS != 5 - #undef SINGLENOZZLE #error "PRUSA_MMU2(S) requires exactly 5 EXTRUDERS. Please update your Configuration." #elif DISABLED(NOZZLE_PARK_FEATURE) #error "PRUSA_MMU2(S) requires NOZZLE_PARK_FEATURE. Enable it to continue." From 71ff2cfbcd5a55d7cea3c2a793d6e0825fa43759 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 28 Oct 2020 16:18:41 -0500 Subject: [PATCH 17/23] Restore senseless #undef --- Marlin/src/inc/SanityCheck.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 45cda8081c..f07445f156 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -879,6 +879,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if HAS_PRUSA_MMU2 #if EXTRUDERS != 5 + #undef SINGLENOZZLE #error "PRUSA_MMU2(S) requires exactly 5 EXTRUDERS. Please update your Configuration." #elif DISABLED(NOZZLE_PARK_FEATURE) #error "PRUSA_MMU2(S) requires NOZZLE_PARK_FEATURE. Enable it to continue." From 5433f5ef2e3382a49d48b33c75b9cf66da5a8b70 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 28 Oct 2020 16:27:34 -0500 Subject: [PATCH 18/23] human-readability --- Marlin/src/gcode/config/M220.cpp | 2 +- Marlin/src/gcode/gcode.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/config/M220.cpp b/Marlin/src/gcode/config/M220.cpp index bb61621fea..37fe7d3a5f 100644 --- a/Marlin/src/gcode/config/M220.cpp +++ b/Marlin/src/gcode/config/M220.cpp @@ -31,7 +31,7 @@ * * Report the current speed percentage factor if no parameter is specified * - * With MMU_MODEL=PRUSA_MMU2(S)/SMUFF_EMU_MMU2(S)... + * For MMU2 and MMU2S devices... * B : Flag to back up the current factor * R : Flag to restore the last-saved factor */ diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 87f832ddf1..490eb82b72 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -181,7 +181,7 @@ * M217 - Set filament swap parameters: "M217 S P R". (Requires SINGLENOZZLE) * M218 - Set/get a tool offset: "M218 T X Y". (Requires 2 or more extruders) * M220 - Set Feedrate Percentage: "M220 S" (i.e., "FR" on the LCD) - * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires MMU_MODEL=PRUSA_MMU2(S)/SMUFF_EMU_MMU2(S)) + * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires an MMU_MODEL version 2 or 2S) * M221 - Set Flow Percentage: "M221 S" * M226 - Wait until a pin is in a given state: "M226 P S" (Requires DIRECT_PIN_CONTROL) * M240 - Trigger a camera to take a photograph. (Requires PHOTO_GCODE) From 24c0ed35a31f4239cbca8037251eb726dc3ffb8f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 28 Oct 2020 16:46:19 -0500 Subject: [PATCH 19/23] Future units --- Marlin/Configuration_adv.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8d18c51f8a..80091326c0 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3507,12 +3507,11 @@ #endif /** - * Průša Multi-Material Unit (MMU) multiplexer + * Průša Multi-Material Unit (MMU) * Enable in Configuration.h * * These devices allow a single stepper driver on the board to drive - * two to eight stepper motors, one at a time, in a manner suitable - * for extruders. + * multi-material feeders with any number of stepper motors. */ #if HAS_PRUSA_MMU1 /** From f18d3129afaaabffe8c644375863b6e6528cc7bd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 28 Oct 2020 21:49:31 -0500 Subject: [PATCH 20/23] Clean up, permit "Tc" with no LCD --- Marlin/src/MarlinCore.cpp | 15 ++-- Marlin/src/feature/mmu/mmu2.cpp | 128 +++++++++++++++++--------------- 2 files changed, 75 insertions(+), 68 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 847667fbb2..95fd2c78c8 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -713,9 +713,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { TERN_(HAS_FILAMENT_SENSOR, runout.run()); // Run HAL idle tasks - #ifdef HAL_IDLETASK - HAL_idletask(); - #endif + TERN_(HAL_IDLETASK, HAL_idletask()); // Check network connection TERN_(HAS_ETHERNET, ethernet.check()); @@ -772,9 +770,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { #endif // Update the Průša MMU2 - #if HAS_PRUSA_MMU2 - mmu2.mmu_loop(); - #endif + TERN_(HAS_PRUSA_MMU2, mmu2.mmu_loop()); // Handle Joystick jogging TERN_(POLL_JOG, joystick.inject_jog_moves()); @@ -782,9 +778,8 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { // Direct Stepping TERN_(DIRECT_STEPPING, page_manager.write_responses()); - #if HAS_TFT_LVGL_UI - LV_TASK_HANDLER(); - #endif + // Update the LVGL interface + TERN_(HAS_TFT_LVGL_UI, LV_TASK_HANDLER()); } /** @@ -1182,7 +1177,7 @@ void setup() { #endif #if HAS_PRUSA_MMU1 - SETUP_LOG("PRUSA MMU1 MULTIPLEXER"); + SETUP_LOG("Prusa MMU1"); SET_OUTPUT(E_MUX0_PIN); SET_OUTPUT(E_MUX1_PIN); SET_OUTPUT(E_MUX2_PIN); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 27679b48ee..f06c571e68 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -537,32 +537,38 @@ static void mmu2_not_responding() { * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ void MMU2::tool_change(const char* special) { - - #if ENABLED(MMU2_MENUS) if (!enabled) return; set_runout_valid(false); switch (*special) { case '?': { - uint8_t index = mmu2_choose_filament(); - while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); - load_filament_to_nozzle(index); + #if ENABLED(MMU2_MENUS) + const uint8_t index = mmu2_choose_filament(); + while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); + load_filament_to_nozzle(index); + #else + BUZZ(400, 40); + #endif } break; case 'x': { - planner.synchronize(); - uint8_t index = mmu2_choose_filament(); - DISABLE_AXIS_E0(); - command(MMU_CMD_T0 + index); - manage_response(true, true); + #if ENABLED(MMU2_MENUS) + planner.synchronize(); + const uint8_t index = mmu2_choose_filament(); + DISABLE_AXIS_E0(); + command(MMU_CMD_T0 + index); + manage_response(true, true); - if (load_to_gears()) { - mmu_loop(); - ENABLE_AXIS_E0(); - extruder = index; - active_extruder = 0; - } + if (load_to_gears()) { + mmu_loop(); + ENABLE_AXIS_E0(); + extruder = index; + active_extruder = 0; + } + #else + BUZZ(400, 40); + #endif } break; case 'c': { @@ -572,8 +578,6 @@ static void mmu2_not_responding() { } set_runout_valid(true); - - #endif // MMU2_MENUS } #elif ENABLED(MMU_EXTRUDER_SENSOR) @@ -621,22 +625,25 @@ static void mmu2_not_responding() { * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ void MMU2::tool_change(const char* special) { - #if ENABLED(MMU2_MENUS) + if (!enabled) return; - if (!enabled) return; + set_runout_valid(false); - set_runout_valid(false); - - switch (*special) { - case '?': { - DEBUG_ECHOLNPGM("case ?\n"); + switch (*special) { + case '?': { + DEBUG_ECHOLNPGM("case ?\n"); + #if ENABLED(MMU2_MENUS) uint8_t index = mmu2_choose_filament(); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); - } break; + #else + BUZZ(400, 40); + #endif + } break; - case 'x': { - DEBUG_ECHOLNPGM("case x\n"); + case 'x': { + DEBUG_ECHOLNPGM("case x\n"); + #if ENABLED(MMU2_MENUS) planner.synchronize(); uint8_t index = mmu2_choose_filament(); DISABLE_AXIS_E0(); @@ -649,18 +656,19 @@ static void mmu2_not_responding() { ENABLE_AXIS_E0(); extruder = index; active_extruder = 0; - } break; + #else + BUZZ(400, 40); + #endif + } break; - case 'c': { - DEBUG_ECHOLNPGM("case c\n"); - while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); - execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence)); - } break; - } + case 'c': { + DEBUG_ECHOLNPGM("case c\n"); + while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); + execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence)); + } break; + } - set_runout_valid(true); - - #endif // MMU2_MENUS + set_runout_valid(true); } void MMU2::mmu_continue_loading() { @@ -712,22 +720,25 @@ static void mmu2_not_responding() { * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ void MMU2::tool_change(const char* special) { - #if ENABLED(MMU2_MENUS) + if (!enabled) return; - if (!enabled) return; + set_runout_valid(false); - set_runout_valid(false); - - switch (*special) { - case '?': { - DEBUG_ECHOLNPGM("case ?\n"); + switch (*special) { + case '?': { + DEBUG_ECHOLNPGM("case ?\n"); + #if ENABLED(MMU2_MENUS) uint8_t index = mmu2_choose_filament(); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); - } break; + #else + BUZZ(400, 40); + #endif + } break; - case 'x': { - DEBUG_ECHOLNPGM("case x\n"); + case 'x': { + DEBUG_ECHOLNPGM("case x\n"); + #if ENABLED(MMU2_MENUS) planner.synchronize(); uint8_t index = mmu2_choose_filament(); DISABLE_AXIS_E0(); @@ -739,18 +750,19 @@ static void mmu2_not_responding() { ENABLE_AXIS_E0(); extruder = index; active_extruder = 0; - } break; + #else + BUZZ(400, 40); + #endif + } break; - case 'c': { - DEBUG_ECHOLNPGM("case c\n"); - while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); - execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence)); - } break; - } + case 'c': { + DEBUG_ECHOLNPGM("case c\n"); + while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); + execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence)); + } break; + } - set_runout_valid(true); - - #endif + set_runout_valid(true); } #endif // HAS_PRUSA_MMU2S From 283cbe5e3d05eb86ba3e60094d924e312f7d5791 Mon Sep 17 00:00:00 2001 From: GMagician Date: Thu, 29 Oct 2020 22:10:39 +0100 Subject: [PATCH 21/23] Use common way to test MMU options in precompiler conditions --- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/inc/SanityCheck.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index f06c571e68..203373f71b 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -158,7 +158,7 @@ uint8_t MMU2::get_current_tool() { return extruder == MMU2_NO_TOOL ? -1 : extruder; } -#if EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) +#if HAS_PRUSA_MMU2S || MMU_EXTRUDER_SENSOR #define FILAMENT_PRESENT() (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE) #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f07445f156..f021c90606 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -883,7 +883,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "PRUSA_MMU2(S) requires exactly 5 EXTRUDERS. Please update your Configuration." #elif DISABLED(NOZZLE_PARK_FEATURE) #error "PRUSA_MMU2(S) requires NOZZLE_PARK_FEATURE. Enable it to continue." - #elif ENABLED(HAS_PRUSA_MMU2S) && DISABLED(FILAMENT_RUNOUT_SENSOR) + #elif HAS_PRUSA_MMU2S && DISABLED(FILAMENT_RUNOUT_SENSOR) #error "PRUSA_MMU2S requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." #elif ENABLED(MMU_EXTRUDER_SENSOR) && DISABLED(FILAMENT_RUNOUT_SENSOR) #error "MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." From 6469c9c8cc458d35abf1d017ed68fa6e69d0cbc1 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Mon, 2 Nov 2020 11:38:43 +0100 Subject: [PATCH 22/23] Use TERN_ instead of #if --- Marlin/src/gcode/gcode.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 490eb82b72..d2693fd68c 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -735,9 +735,7 @@ private: static void M402(); #endif - #if HAS_PRUSA_MMU2 - static void M403(); - #endif + TERN_(HAS_PRUSA_MMU2, static void M403()); #if ENABLED(FILAMENT_WIDTH_SENSOR) static void M404(); From e20511e1db27c25e85abda7e1fe8933cb26864a3 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Mon, 2 Nov 2020 16:45:48 +0100 Subject: [PATCH 23/23] Use SMUFF developper nickname --- Marlin/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 3b518c4c7d..ef33d3163e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -164,8 +164,8 @@ * PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version) * PRUSA_MMU2 : Průša MMU2 * PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5) - * SMUFF_EMU_MMU2 : Christian Gegg SMUFF (Průša MMU2 emulation mode) - * SMUFF_EMU_MMU2S : Christian Gegg SMUFF (Průša MMU2S emulation mode) + * SMUFF_EMU_MMU2 : Technik Gegg SMUFF (Průša MMU2 emulation mode) + * SMUFF_EMU_MMU2S : Technik Gegg SMUFF (Průša MMU2S emulation mode) * * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. * See additional options in Configuration_adv.h.