From 78614f5670bde11ab0c691f2ceaed525719bacf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Mon, 24 Apr 2023 09:09:43 +0000 Subject: [PATCH 1/4] M701/M702: Set default Z value to 0 Set default Z value to 0 to maintain backwards compatibility with older gcodes. --- Firmware/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index ce66afc25..fdf8dca6d 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8399,13 +8399,13 @@ Sigma_Exit: - `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 + - `Z` - Move the Z axis by this distance. Default value is 0 to maintain backwards compatibility with older gcodes. */ case 701: { uint8_t mmuSlotIndex = 0xffU; float fastLoadLength = FILAMENTCHANGE_FIRSTFEED; // Only used without MMU - float z_target = MIN_Z_FOR_LOAD; + float z_target = 0; if( MMU2::mmu2.Enabled() ) { if( code_seen('P') || code_seen('T') ) { @@ -8437,11 +8437,11 @@ Sigma_Exit: #### Parameters - `U` - Retract distance for removal (manual reload). Default value is 0. - - `Z` - Move the Z axis by this distance. Default value MIN_Z_FOR_UNLOAD. + - `Z` - Move the Z axis by this distance. Default value is 0 to maintain backwards compatibility with older gcodes. */ case 702: { - float z_target = MIN_Z_FOR_UNLOAD; + float z_target = 0; float unloadLength = FILAMENTCHANGE_FINALRETRACT; if (code_seen('U')) unloadLength = code_value(); From 26369ac540d6ef2a92198c0d4c48e5b2e775bc2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 29 Apr 2023 16:22:28 +0000 Subject: [PATCH 2/4] Restore old M701/M702 behavior If the new Z parameter is not given, assume that the old Z-lift behavior is desired. Change in memory: Flash: -28 bytes SRAM: 0 bytes --- Firmware/Marlin_main.cpp | 2 ++ Firmware/first_lay_cal.cpp | 4 ++-- Firmware/messages.cpp | 4 ++-- Firmware/messages.h | 4 ++-- Firmware/ultralcd.cpp | 11 +++++------ 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index fdf8dca6d..35caf0e90 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8417,6 +8417,7 @@ Sigma_Exit: // Z lift. For safety only allow positive values if (code_seen('Z')) z_target = fabs(code_value()); + else raise_z_above(MIN_Z_FOR_LOAD); // backwards compatibility for 3.12 and older FW // Raise the Z axis float delta = raise_z(z_target); @@ -8447,6 +8448,7 @@ Sigma_Exit: // For safety only allow positive values if (code_seen('Z')) z_target = fabs(code_value()); + else raise_z_above(MIN_Z_FOR_UNLOAD); // backwards compatibility for 3.12 and older FW // Raise the Z axis float delta = raise_z(z_target); diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 0ad7ca5c9..65ceaf678 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -81,7 +81,7 @@ bool lay1cal_load_filament(uint8_t filament) return false; } else if( currentTool != (uint8_t)MMU2::FILAMENT_UNKNOWN){ // some other slot is loaded, perform an unload first - enquecommand_P(MSG_M702_NO_LIFT); + enquecommand_P(MSG_M702); } // perform a toolchange enquecommandf_P(PSTR("T%d"), filament); @@ -245,6 +245,6 @@ void lay1cal_finish(bool mmu_enabled) lay1cal_common_enqueue_loop(cmd_cal_finish, (sizeof(cmd_cal_finish)/sizeof(cmd_cal_finish[0]))); - if (mmu_enabled) enquecommand_P(MSG_M702_NO_LIFT); //unload from nozzle + if (mmu_enabled) enquecommand_P(MSG_M702); //unload from nozzle enquecommand_P(MSG_M84);// disable motors } diff --git a/Firmware/messages.cpp b/Firmware/messages.cpp index 3702feb10..f50e03bdb 100644 --- a/Firmware/messages.cpp +++ b/Firmware/messages.cpp @@ -240,5 +240,5 @@ const char MSG_M107[] PROGMEM_N1 = "M107"; const char MSG_M220[] PROGMEM_N1 = "M220 S%d"; const char MSG_M500[] PROGMEM_N1 = "M500"; const char MSG_M600[] PROGMEM_N1 = "M600"; -const char MSG_M701_NO_LIFT[] PROGMEM_N1 = "M701 Z0"; -const char MSG_M702_NO_LIFT[] PROGMEM_N1 = "M702 Z0"; +const char MSG_M701[] PROGMEM_N1 = "M701"; +const char MSG_M702[] PROGMEM_N1 = "M702"; diff --git a/Firmware/messages.h b/Firmware/messages.h index d7a1bc997..f074351d9 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -246,8 +246,8 @@ extern const char MSG_M107[]; extern const char MSG_M220[]; extern const char MSG_M500[]; extern const char MSG_M600[]; -extern const char MSG_M701_NO_LIFT[]; -extern const char MSG_M702_NO_LIFT[]; +extern const char MSG_M701[]; +extern const char MSG_M702[]; #if defined(__cplusplus) } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a2bfd7bd6..715f3d6c1 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1805,10 +1805,10 @@ switch(eFilamentAction) // FALLTHRU case FilamentAction::Load: loading_flag=true; - enquecommand_P(MSG_M701_NO_LIFT); // load filament + enquecommand_P(MSG_M701); // load filament break; case FilamentAction::UnLoad: - enquecommand_P(MSG_M702_NO_LIFT); // unload filament + enquecommand_P(MSG_M702); // unload filament break; case FilamentAction::MmuLoad: case FilamentAction::MmuLoadingTest: @@ -1868,11 +1868,11 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) if ((eFilamentAction == FilamentAction::Load) || (eFilamentAction == FilamentAction::AutoLoad)) { loading_flag = true; - enquecommand_P(MSG_M701_NO_LIFT); // load filament + enquecommand_P(MSG_M701); // load filament if (eFilamentAction == FilamentAction::AutoLoad) eFilamentAction = FilamentAction::None; // i.e. non-autoLoad } if (eFilamentAction == FilamentAction::UnLoad) - enquecommand_P(MSG_M702_NO_LIFT); // unload filament + enquecommand_P(MSG_M702); // unload filament } break; case FilamentAction::MmuLoad: @@ -3717,8 +3717,7 @@ static void lcd_wizard_load() { lcd_puts_at_P(0, 2, _T(MSG_LOADING_FILAMENT)); loading_flag = true; } - gcode_M701(FILAMENTCHANGE_FIRSTFEED, 0); - //enquecommand_P(MSG_M701_NO_LIFT); // is enqueuecommand_P safe here? + enquecommand_P(MSG_M701); } static void wizard_lay1cal_message(bool cold) From 9cf1f7871eafe7edca63eaff9e5cd76b38d8c4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Tue, 2 May 2023 22:32:18 +0000 Subject: [PATCH 3/4] Minor fix to M701 when MMU slot is out of range If MMU slot is outside of range, then we rather the printer not do anything. Currently it would accidentally assume the MMU is disabled. This may have undesireable results. No change in memory --- Firmware/Marlin_main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 35caf0e90..5c8df63f8 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3575,8 +3575,10 @@ void gcode_M701(float fastLoadLength, uint8_t mmuSlotIndex){ prusa_statistics(22); - if (MMU2::mmu2.Enabled() && mmuSlotIndex < MMU_FILAMENT_COUNT) { - MMU2::mmu2.load_filament_to_nozzle(mmuSlotIndex); + if (MMU2::mmu2.Enabled()) { + if (mmuSlotIndex < MMU_FILAMENT_COUNT) { + MMU2::mmu2.load_filament_to_nozzle(mmuSlotIndex); + } // else do nothing } else { custom_message_type = CustomMsg::FilamentLoading; lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); From fc15f5a6ef33a19f2f6c91e205ee98ce6059db6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Tue, 2 May 2023 22:38:54 +0000 Subject: [PATCH 4/4] Select correct MMU slot in lcd_wizard_load Change in memory: Flash: +8 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 715f3d6c1..91707eb8f 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3717,7 +3717,9 @@ static void lcd_wizard_load() { lcd_puts_at_P(0, 2, _T(MSG_LOADING_FILAMENT)); loading_flag = true; } - enquecommand_P(MSG_M701); + + // When MMU is disabled P parameter is ignored + enquecommand_P(PSTR("M701 P0")); } static void wizard_lay1cal_message(bool cold)