diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 858b19f1e..b86059895 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5224,17 +5224,10 @@ void process_commands() lcd_resume_print(); else { - if (!MMU2::mmu2.Enabled()) { - // Check if the filament is present before starting a print. - // When MMU is enabled, this is not necessary and the G-code file - // should always tell the MMU which filament to load. - filament_presence_check(); - - if (lcd_commands_type == LcdCommands::StopPrint) { - // Print job was canceled - break; - } - } + if (!filament_presence_check()) { + // Print was aborted + break; + } if (!card.get_sdpos()) { @@ -5866,16 +5859,9 @@ Sigma_Exit: */ case 75: { - if (!MMU2::mmu2.Enabled()) { - // Check if the filament is present before starting a host print. - // When MMU is enabled, this is not necessary and the G-code file - // should always tell the MMU which filament to load. - filament_presence_check(); - - if (lcd_commands_type == LcdCommands::StopPrint) { - // Print job was canceled - break; - } + if (!filament_presence_check()) { + // Print was aborted + break; } print_job_timer.start(); diff --git a/Firmware/util.cpp b/Firmware/util.cpp index ca8a55d24..8fa3f7d41 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -371,19 +371,32 @@ void fw_version_check(const char *pVersion) { ); } -void filament_presence_check() { - if (fsensor.isEnabled() && !fsensor.getFilamentPresent()) - { - if (oCheckFilament == ClCheckMode::_None) - return; +bool filament_presence_check() { + // When MMU is enabled, this is not necessary and the G-code file + // should always tell the MMU which filament to load. + if (MMU2::mmu2.Enabled()) { + goto done; + } + + if (fsensor.isEnabled() && !fsensor.getFilamentPresent()) { + if (oCheckFilament == ClCheckMode::_None) { + goto done; + } render_M862_warnings( _T(MSG_MISSING_FILAMENT_CONTINUE) ,_T(MSG_MISSING_FILAMENT_CANCELLED) ,(uint8_t)oCheckFilament ); + + if (lcd_commands_type == LcdCommands::StopPrint) { + // Print job was canceled + return false; + } } - + +done: + return true; } void gcode_level_check(uint16_t nGcodeLevel) { diff --git a/Firmware/util.h b/Firmware/util.h index 3bb3025d1..93d5a0945 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -115,9 +115,22 @@ void nozzle_diameter_check(uint16_t nDiameter); void printer_model_check(uint16_t nPrinterModel, uint16_t actualPrinterModel); void printer_smodel_check(const char *pStrPos, const char *actualPrinterSModel); void fw_version_check(const char *pVersion); -void filament_presence_check(); void gcode_level_check(uint16_t nGcodeLevel); +/// Check if the filament is present before starting a print job. +/// Depending on the check level set in the menus the printer will: +/// - None: not issue any warning about missing filament +/// - Warning (default): The user is warned about missing filament +/// and is prompted to continue with Yes/No. If No is selected, +/// the print is aborted. If no user input is given (e.g. from +/// host printing) then the warning will expire in 30 seconds and +/// the printer assumes the Yes option was selected. +/// - Strict: If the filament is not detected when a print is started, +/// it is immediately canceled with a message saying the filament is +/// missing. +/// @returns false if the print is canceled, true otherwise +bool filament_presence_check(); + uint16_t nPrinterType(bool bMMu); const char *sPrinterType(bool bMMu);