Simplify filament_presence_check usage

Pull all checks needed into the function such that the caller
only needs to check the return value

Also added description for the filament_presence_check function
This commit is contained in:
gudnimg 2024-07-26 15:53:42 +00:00
parent 75c980c4e7
commit 40d3830e6d
3 changed files with 40 additions and 28 deletions

View File

@ -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
if (!filament_presence_check()) {
// Print was aborted
break;
}
}
if (!card.get_sdpos())
{
@ -5866,17 +5859,10 @@ 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
if (!filament_presence_check()) {
// Print was aborted
break;
}
}
print_job_timer.start();
break;

View File

@ -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) {

View File

@ -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);