From fee68b0f0d42c33144fab95d005c090ba7c94099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 18 Dec 2022 05:46:01 +0000 Subject: [PATCH 1/2] PFW-1457 Do not unload at start of First Layer Cal Fixes issue where First Layer Cal. triggers an unload before any filament is loaded The purpose of this if() statement is to handle the case where a user or developer is sending T-codes to the printer directly via Serial. Such as when one first sends T0 and then T4. And unload must be triggered in-between, we can do this automatically if FINDA detect filament. Change in memory: Flash: -10 bytes SRAM: 0 bytes --- Firmware/Marlin.h | 1 + Firmware/mmu2.cpp | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index a90079ac5..3381c0ad7 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -22,6 +22,7 @@ #include "pins.h" #include "Timer.h" #include "mmu2.h" +#include "cardreader.h" // for IS_SD_PRINTING extern uint8_t mbl_z_probe_nr; #ifndef AT90USB diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 7c8a443ae..d526af313 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -14,7 +14,6 @@ #include "strlen_cx.h" #include "temperature.h" #include "ultralcd.h" -#include "cardreader.h" // for IS_SD_PRINTING #include "SpoolJoin.h" // As of FW 3.12 we only support building the FW with only one extruder, all the multi-extruder infrastructure will be removed. @@ -384,9 +383,9 @@ bool MMU2::tool_change(uint8_t slot) { return false; if (slot != extruder) { - if (!IS_SD_PRINTING && !usb_timer.running()) { + if (FindaDetectsFilament()) { // If Tcodes are used manually through the serial - // we need to unload manually as well + // we need to unload manually as well -- but only if FINDA detects filament unload(); } From 4c32e8b40381180ac89daffca5e8268fb249d5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 18 Dec 2022 12:23:20 +0000 Subject: [PATCH 2/2] PFW-1457 make CHECK_FSENSOR into a function --- Firmware/Marlin.h | 3 +-- Firmware/Marlin_main.cpp | 8 ++++++++ Firmware/mmu2.cpp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 3381c0ad7..da613c383 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -22,7 +22,6 @@ #include "pins.h" #include "Timer.h" #include "mmu2.h" -#include "cardreader.h" // for IS_SD_PRINTING extern uint8_t mbl_z_probe_nr; #ifndef AT90USB @@ -364,7 +363,7 @@ extern bool printer_active(); //! Instead, the fsensor uses another state variable :( , which is set to true, when the M600 command is enqued //! and is reset to false when the fsensor returns into its filament runout finished handler //! I'd normally change this macro, but who knows what would happen in the MMU :) -#define CHECK_FSENSOR ((IS_SD_PRINTING || usb_timer.running()) && (mcode_in_progress != 600) && !saved_printing && e_active()) +bool check_fsensor(); extern void calculate_extruder_multipliers(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index eeb9608db..f5bc62f94 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -563,6 +563,14 @@ bool __attribute__((noinline)) printer_active() { || mesh_bed_leveling_flag; } +// Currently only used in one place, allowed to be inlined +bool check_fsensor() { + return (IS_SD_PRINTING || usb_timer.running()) + && mcode_in_progress != 600 + && !saved_printing + && e_active(); +} + bool fans_check_enabled = true; #ifdef TMC2130 diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index d526af313..5c402cbae 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -245,7 +245,7 @@ void __attribute__((noinline)) MMU2::mmu_loop_inner(bool reportErrors) { void MMU2::CheckFINDARunout() { // Check for FINDA filament runout - if (!FindaDetectsFilament() && CHECK_FSENSOR) { + if (!FindaDetectsFilament() && check_fsensor()) { SERIAL_ECHOLNPGM("FINDA filament runout!"); stop_and_save_print_to_ram(0, 0); restore_print_from_ram_and_continue(0);