From 5bb36546b4049f8a45ca5b64379629b592dbef74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 27 Aug 2022 09:13:05 +0000 Subject: [PATCH] PFW-1386 Implement changes to M701 --- Firmware/Marlin_main.cpp | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 2d4a141eb..bd9e2b7ea 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8547,22 +8547,42 @@ Sigma_Exit: /*! ### M701 - Load filament M701: Load filament + Load filament into the active extruder. #### Usage - M701 [ E | T ] + M701 [ P | T | L | Z ] #### Parameters - - `E` - ID of filament to load, ranges from 0 to 4 - - `T` - Alias of `E`. Used for compatibility with Marlin + - `P` - n index of MMU slot (zero based, so 0-4 like T0 and T4) + - `T` - Alias of `P`. Used for compatibility with Marlin + - `L` - Extrude distance for insertion (positive value)(manual reload) + - `Z` - Move the Z axis by this distance. Default value MIN_Z_FOR_LOAD */ - case 701: - { + case 701: + { uint8_t mmuSlotIndex = 0xffU; - if (MMU2::mmu2.Enabled() && code_seen('E')) - mmuSlotIndex = code_value_uint8(); - gcode_M701(mmuSlotIndex); - } - break; + if( MMU2::mmu2.Enabled() ) + { + if( code_seen('P') || code_seen('T') ) { + mmuSlotIndex = code_value_uint8(); + } + } + + // TODO: Implement L parameter + + enable_z(); + if (code_seen('Z')) + { + float z_target = code_value(); + raise_z_above(z_target, false); + } else { + raise_z_above(MIN_Z_FOR_LOAD, false); + } + disable_z(); + + gcode_M701(mmuSlotIndex); + } + break; /*! ### M702 - Unload filament G32: Undock Z Probe sled