Implement printJobOngoing()

This makes the if statments a little bit more readable

Change in memory:
Flash: -88 bytes
SRAM: 0 bytes
This commit is contained in:
Guðni Már Gilbert 2023-03-18 12:15:44 +00:00
parent 561d8599d2
commit e40d8ebbcc
5 changed files with 20 additions and 15 deletions

View File

@ -113,8 +113,7 @@ void Filament_sensor::triggerFilamentInserted() {
&& (! MMU2::mmu2.Enabled() ) // quick and dirty hack to prevent spurious runouts while the MMU is in charge
&& !(
moves_planned() != 0
|| IS_SD_PRINTING
|| usb_timer.running()
|| printJobOngoing()
|| (lcd_commands_type == LcdCommands::Layer1Cal)
|| eeprom_read_byte((uint8_t *)EEPROM_WIZARD_ACTIVE)
)
@ -131,8 +130,7 @@ void Filament_sensor::triggerFilamentRemoved() {
&& !saved_printing
&& (
moves_planned() != 0
|| IS_SD_PRINTING
|| usb_timer.running()
|| printJobOngoing()
|| (lcd_commands_type == LcdCommands::Layer1Cal)
|| eeprom_read_byte((uint8_t *)EEPROM_WIZARD_ACTIVE)
)

View File

@ -354,7 +354,11 @@ extern LongTimer safetyTimer;
#define PRINT_PERCENT_DONE_INIT 0xff
extern bool printer_active();
// Returns true if there is a print running. It does not matter if
// the print is paused, that still counts as a "running" print.
bool printJobOngoing();
bool printer_active();
//! Beware - mcode_in_progress is set as soon as the command gets really processed,
//! which is not the same as posting the M600 command into the command queue

View File

@ -525,9 +525,12 @@ void servo_init()
#endif
}
bool __attribute__((noinline)) printJobOngoing() {
return (IS_SD_PRINTING || usb_timer.running());
}
bool __attribute__((noinline)) printer_active() {
return IS_SD_PRINTING
|| usb_timer.running()
return printJobOngoing()
|| isPrintPaused
|| (custom_message_type == CustomMsg::TempCal)
|| saved_printing
@ -539,7 +542,7 @@ bool __attribute__((noinline)) printer_active() {
// Currently only used in one place, allowed to be inlined
bool check_fsensor() {
return (IS_SD_PRINTING || usb_timer.running())
return printJobOngoing()
&& mcode_in_progress != 600
&& !saved_printing
&& e_active();
@ -548,7 +551,7 @@ bool check_fsensor() {
bool __attribute__((noinline)) babystep_allowed() {
return ( (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU)
&& !homing_flag && !mesh_bed_leveling_flag
&& ( blocks_queued() || lcd_commands_type == LcdCommands::Layer1Cal || ( !isPrintPaused && (IS_SD_PRINTING || usb_timer.running()) ))
&& ( blocks_queued() || lcd_commands_type == LcdCommands::Layer1Cal || ( !isPrintPaused && printJobOngoing() ))
);
}
@ -9574,7 +9577,7 @@ void ThermalStop(bool allow_recovery)
Stopped = true;
// Either pause or stop the print
if(allow_recovery && (IS_SD_PRINTING || usb_timer.running())) {
if(allow_recovery && printJobOngoing()) {
if (!isPrintPaused) {
lcd_setalertstatuspgm(_T(MSG_PAUSED_THERMAL_ERROR), LCD_STATUS_CRITICAL);

View File

@ -85,7 +85,7 @@ void fanSpeedError(unsigned char _fan) {
if (fan_check_error == EFCE_REPORTED) return;
fan_check_error = EFCE_REPORTED;
if (IS_SD_PRINTING || usb_timer.running()) {
if (printJobOngoing()) {
// A print is ongoing, pause the print normally
if(!isPrintPaused) {
if (usb_timer.running())

View File

@ -3495,7 +3495,7 @@ static void crash_mode_switch()
{
lcd_crash_detect_enable();
}
if (IS_SD_PRINTING || usb_timer.running() || (lcd_commands_type == LcdCommands::Layer1Cal)) menu_goto(lcd_tune_menu, 9, true, true);
if (printJobOngoing() || (lcd_commands_type == LcdCommands::Layer1Cal)) menu_goto(lcd_tune_menu, 9, true, true);
else menu_goto(lcd_settings_menu, 9, true, true);
}
#endif //TMC2130
@ -5371,7 +5371,7 @@ static void lcd_main_menu()
}
}
}
if((IS_SD_PRINTING || usb_timer.running() || isPrintPaused) && (custom_message_type != CustomMsg::MeshBedLeveling) && !processing_tcode) {
if((printJobOngoing() || isPrintPaused) && (custom_message_type != CustomMsg::MeshBedLeveling) && !processing_tcode) {
MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop);
}
#ifdef TEMP_MODEL
@ -5399,7 +5399,7 @@ static void lcd_main_menu()
}
#endif //SDSUPPORT
if(!isPrintPaused && !IS_SD_PRINTING && !usb_timer.running() && (lcd_commands_type != LcdCommands::Layer1Cal)) {
if(!isPrintPaused && !printJobOngoing() && (lcd_commands_type != LcdCommands::Layer1Cal)) {
if (!farm_mode) {
const int8_t sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet));
const int8_t nextSheet = eeprom_next_initialized_sheet(sheet);
@ -5409,7 +5409,7 @@ static void lcd_main_menu()
}
}
if ( ! ( IS_SD_PRINTING || usb_timer.running() || (lcd_commands_type == LcdCommands::Layer1Cal || Stopped) ) ) {
if ( ! ( printJobOngoing() || (lcd_commands_type == LcdCommands::Layer1Cal || Stopped) ) ) {
if (MMU2::mmu2.Enabled()) {
MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), mmu_load_filament_menu);
MENU_ITEM_SUBMENU_P(_i("Load to nozzle"), mmu_load_to_nozzle_menu);////MSG_LOAD_TO_NOZZLE c=18