Extract PRINTER_ACTIVE into a noinline function

Having the original PRINTER_ACTIVE macro copied at multiple spots doesn't make sense.
Refactoring it into a non-inline function saved ~400 bytes of code.
It should be safe in terms of performance, all occurrences are at non-time critical spots.
This commit is contained in:
D.R.racer 2022-09-13 06:27:23 +02:00 committed by DRracer
parent 16d666302b
commit 996f9943a1
4 changed files with 18 additions and 12 deletions

View file

@ -562,9 +562,16 @@ void servo_init()
#endif
}
bool printer_active()
{
return PRINTER_ACTIVE;
bool __attribute__((noinline)) printer_active() {
return IS_SD_PRINTING
|| usb_timer.running()
|| isPrintPaused
|| (custom_message_type == CustomMsg::TempCal)
|| saved_printing
|| (lcd_commands_type == LcdCommands::Layer1Cal)
|| mmu_print_saved
|| homing_flag
|| mesh_bed_leveling_flag;
}
bool fans_check_enabled = true;
@ -9373,7 +9380,7 @@ static void handleSafetyTimer()
#if (EXTRUDERS > 1)
#error Implemented only for one extruder.
#endif //(EXTRUDERS > 1)
if ((PRINTER_ACTIVE) || (!degTargetBed() && !degTargetHotend(0)) || (!safetytimer_inactive_time))
if (printer_active() || (!degTargetBed() && !degTargetHotend(0)) || (!safetytimer_inactive_time))
{
safetyTimer.stop();
}
@ -9427,7 +9434,7 @@ static uint16_t nFSCheckCount=0;
if (mmu_enabled == false)
{
//-// if (mcode_in_progress != 600) //M600 not in progress
if (!PRINTER_ACTIVE) bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); //Block Filament sensor actions if PRINTER is not active and Support::SensorInfo menu active
if (!printer_active()) bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); //Block Filament sensor actions if PRINTER is not active and Support::SensorInfo menu active
#ifdef IR_SENSOR_ANALOG
bInhibitFlag=bInhibitFlag||bMenuFSDetect; // Block Filament sensor actions if Settings::HWsetup::FSdetect menu active
#endif // IR_SENSOR_ANALOG
@ -10933,7 +10940,7 @@ ISR(INT4_vect) {
EIMSK &= ~(1 << 4); //disable INT4 interrupt to make sure that this code will be executed just once
SERIAL_ECHOLNPGM("INT4");
//fire normal uvlo only in case where EEPROM_UVLO is 0 or if IS_SD_PRINTING is 1.
if(PRINTER_ACTIVE && (!(eeprom_read_byte((uint8_t*)EEPROM_UVLO)))) uvlo_();
if(printer_active() && (!(eeprom_read_byte((uint8_t*)EEPROM_UVLO)))) uvlo_();
if(eeprom_read_byte((uint8_t*)EEPROM_UVLO)) uvlo_tiny();
}