Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/20140
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Nov 18, 2020
2 parents be6df82 + 41529b6 commit c6a051d
Show file tree
Hide file tree
Showing 53 changed files with 566 additions and 545 deletions.
34 changes: 10 additions & 24 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,33 +158,19 @@
#endif

/**
* Průša MK2 Single Nozzle Multi-Material Multiplexer, and variants.
*
* 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
* Multi-Material Unit
* Set to one of these predefined models:
*
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
* Requires EXTRUDERS = 5
* 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 : Technik Gegg SMUFF (Průša MMU2 emulation mode)
* SMUFF_EMU_MMU2S : Technik Gegg SMUFF (Průša MMU2S emulation mode)
*
* For additional configuration see Configuration_adv.h
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
* See additional options in Configuration_adv.h.
*/
//#define PRUSA_MMU2
//#define MMU_MODEL PRUSA_MMU2

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
Expand Down
65 changes: 40 additions & 25 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,8 @@

//#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files

//#define BROWSE_MEDIA_ON_INSERT // Open the file browser when media is inserted

#define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")

#if ENABLED(PRINTER_EVENT_LEDS)
Expand Down Expand Up @@ -3530,11 +3532,24 @@
#endif

/**
* Průša Multi-Material Unit v2
* Průša Multi-Material Unit (MMU)
* Enable in Configuration.h
*
* These devices allow a single stepper driver on the board to drive
* multi-material feeders with any number of stepper motors.
*/
#if ENABLED(PRUSA_MMU2)

#if HAS_PRUSA_MMU1
/**
* 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 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)
Expand All @@ -3550,29 +3565,12 @@
// G-code to execute when MMU2 F.I.N.D.A. probe detects filament runout
#define MMU2_FILAMENT_RUNOUT_SCRIPT "M600"

/**
* 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 HAS_PRUSA_MMU2S
#define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries)

#define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/min)
Expand All @@ -3588,14 +3586,31 @@
#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

// Add an LCD menu for MMU2
//#define MMU2_MENUS

// MMU2_LOAD_TO_NOZZLE_SEQUENCE and MMU2_RAMMING_SEQUENCE are required for PRUSA_MMU2_S_MODE
#if EITHER(MMU2_MENUS, PRUSA_MMU2_S_MODE)
// Settings for filament load / unload from the LCD menu.
#if EITHER(MMU2_MENUS, HAS_PRUSA_MMU2S)
// Settings for filament load / unload.
// This is for Průša MK3-style extruders. Customize for your hardware.
#define MMU2_FILAMENTCHANGE_EJECT_FEED 80.0
#define MMU2_LOAD_TO_NOZZLE_SEQUENCE \
Expand All @@ -3621,7 +3636,7 @@

//#define MMU2_DEBUG // Write debug info to serial output

#endif // PRUSA_MMU2
#endif // HAS_PRUSA_MMU2

/**
* Advanced Print Counter settings
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/HAL/LPC1768/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
*
*/
#pragma once

#if DISABLED(NO_SD_HOST_DRIVE)
#define HAS_SD_HOST_DRIVE 1
#endif
4 changes: 2 additions & 2 deletions Marlin/src/HAL/LPC1768/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/HAL/LPC1768/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ extern "C" {
#include <debug_frmwrk.h>
}

#include "../../sd/cardreader.h"
#include "../../inc/MarlinConfig.h"
#include "../../core/millis_t.h"

#include "../../sd/cardreader.h"

extern uint32_t MSC_SD_Init(uint8_t pdrv);
extern "C" int isLPC1769();
extern "C" void disk_timerproc();
Expand Down Expand Up @@ -122,7 +123,7 @@ void HAL_init() {
delay(1000); // Give OS time to notice
USB_Connect(TRUE);

#if DISABLED(NO_SD_HOST_DRIVE)
#if HAS_SD_HOST_DRIVE
MSC_SD_Init(0); // Enable USB SD card access
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#error "ERROR - Only STM32F103xE, STM32F103xG, STM32F4xx or STM32F7xx CPUs supported"
#endif

#ifdef USBD_USE_CDC_COMPOSITE
#if HAS_SD_HOST_DRIVE

// use USB drivers

Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/HAL/STM32/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
*
*/
#pragma once

#if defined(USBD_USE_CDC_COMPOSITE) && DISABLED(NO_SD_HOST_DRIVE)
#define HAS_SD_HOST_DRIVE 1
#endif
24 changes: 11 additions & 13 deletions Marlin/src/HAL/STM32F1/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
// Public Variables
// ------------------------

#if (defined(SERIAL_USB) && !defined(USE_USB_COMPOSITE))
#if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE
USBSerial SerialUSB;
#endif

Expand Down Expand Up @@ -251,7 +251,7 @@ void HAL_init() {
#if PIN_EXISTS(LED)
OUT_WRITE(LED_PIN, LOW);
#endif
#ifdef USE_USB_COMPOSITE
#if HAS_SD_HOST_DRIVE
MSC_SD_init();
#endif
#if PIN_EXISTS(USB_CONNECT)
Expand All @@ -263,17 +263,15 @@ void HAL_init() {

// HAL idle task
void HAL_idletask() {
#ifdef USE_USB_COMPOSITE
#if HAS_SHARED_MEDIA
// If Marlin is using the SD card we need to lock it to prevent access from
// a PC via USB.
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
// this will not reliably detect delete operations. To be safe we will lock
// the disk if Marlin has it mounted. Unfortunately there is currently no way
// to unmount the disk from the LCD menu.
// if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
/* copy from lpc1768 framework, should be fixed later for process HAS_SHARED_MEDIA*/
#endif
#if HAS_SHARED_MEDIA
// If Marlin is using the SD card we need to lock it to prevent access from
// a PC via USB.
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
// this will not reliably detect delete operations. To be safe we will lock
// the disk if Marlin has it mounted. Unfortunately there is currently no way
// to unmount the disk from the LCD menu.
// if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
/* copy from lpc1768 framework, should be fixed later for process HAS_SD_HOST_DRIVE*/
// process USB mass storage device class loop
MarlinMSC.loop();
#endif
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/STM32F1/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

#include "../../inc/MarlinConfigPre.h"

#ifdef USE_USB_COMPOSITE
#if HAS_SD_HOST_DRIVE
#include "msc_sd.h"
#endif

Expand All @@ -61,7 +61,7 @@
#endif

#ifdef SERIAL_USB
#ifndef USE_USB_COMPOSITE
#if !HAS_SD_HOST_DRIVE
#define UsbSerial Serial
#else
#define UsbSerial MarlinCompositeSerial
Expand Down
5 changes: 0 additions & 5 deletions Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,3 @@
*
*/
#pragma once

#if ENABLED(USE_USB_COMPOSITE)
//#warning "SD_CHECK_AND_RETRY isn't needed with USE_USB_COMPOSITE."
#undef SD_CHECK_AND_RETRY
#endif
8 changes: 8 additions & 0 deletions Marlin/src/HAL/STM32F1/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@
*
*/
#pragma once

#ifdef USE_USB_COMPOSITE
//#warning "SD_CHECK_AND_RETRY isn't needed with USE_USB_COMPOSITE."
#undef SD_CHECK_AND_RETRY
#if DISABLED(NO_SD_HOST_DRIVE)
#define HAS_SD_HOST_DRIVE 1
#endif
#endif
4 changes: 2 additions & 2 deletions Marlin/src/HAL/STM32F1/msc_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(__STM32F1__) && defined(USE_USB_COMPOSITE)
#if defined(__STM32F1__) && HAS_SD_HOST_DRIVE

#include "msc_sd.h"
#include "SPI.h"
Expand Down Expand Up @@ -77,4 +77,4 @@ void MSC_SD_init() {
#endif
}

#endif // __STM32F1__ && USE_USB_COMPOSITE
#endif // __STM32F1__ && HAS_SD_HOST_DRIVE
9 changes: 5 additions & 4 deletions Marlin/src/HAL/STM32F1/onboard_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
#include "SPI.h"
#include "fastio.h"

#if HAS_SHARED_MEDIA
#ifndef ONBOARD_SPI_DEVICE
#define ONBOARD_SPI_DEVICE SPI_DEVICE
#endif
#ifndef ONBOARD_SPI_DEVICE
#define ONBOARD_SPI_DEVICE SPI_DEVICE
#endif

#if HAS_SD_HOST_DRIVE
#define ONBOARD_SD_SPI SPI
#else
SPIClass OnboardSPI(ONBOARD_SPI_DEVICE);
Expand Down
21 changes: 9 additions & 12 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@
#include "feature/controllerfan.h"
#endif

#if ENABLED(PRUSA_MMU2)
#include "feature/mmu2/mmu2.h"
#if HAS_PRUSA_MMU2
#include "feature/mmu/mmu2.h"
#endif

#if HAS_L64XX
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -772,17 +770,16 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
#endif

// Update the Průša MMU2
TERN_(PRUSA_MMU2, mmu2.mmu_loop());
TERN_(HAS_PRUSA_MMU2, mmu2.mmu_loop());

// Handle Joystick jogging
TERN_(POLL_JOG, joystick.inject_jog_moves());

// 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());
}

/**
Expand Down Expand Up @@ -1187,8 +1184,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");
SET_OUTPUT(E_MUX0_PIN);
SET_OUTPUT(E_MUX1_PIN);
SET_OUTPUT(E_MUX2_PIN);
Expand Down Expand Up @@ -1268,7 +1265,7 @@ void setup() {
SETUP_RUN(test_tmc_connection(true, true, true, true));
#endif

#if ENABLED(PRUSA_MMU2)
#if HAS_PRUSA_MMU2
SETUP_RUN(mmu2.init());
#endif

Expand Down
Loading

0 comments on commit c6a051d

Please sign in to comment.