Apply TERN to compact code (#17619)

This commit is contained in:
Scott Lahteine
2020-04-22 16:35:03 -05:00
committed by GitHub
parent 88bdd26c99
commit 6d90d1e1f5
162 changed files with 1493 additions and 3530 deletions

View File

@@ -313,9 +313,7 @@ void enable_e_steppers() {
}
void enable_all_steppers() {
#if ENABLED(AUTO_POWER_CONTROL)
powerManager.power_on();
#endif
TERN_(AUTO_POWER_CONTROL, powerManager.power_on());
ENABLE_AXIS_X();
ENABLE_AXIS_Y();
ENABLE_AXIS_Z();
@@ -359,9 +357,7 @@ void disable_all_steppers() {
}
void event_probe_recover() {
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR);
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR));
#ifdef ACTION_ON_G29_RECOVER
host_action(PSTR(ACTION_ON_G29_RECOVER));
#endif
@@ -394,12 +390,8 @@ bool printingIsPaused() {
void startOrResumeJob() {
if (!printingIsPaused()) {
#if ENABLED(CANCEL_OBJECTS)
cancelable.reset();
#endif
#if ENABLED(LCD_SHOW_E_TOTAL)
e_move_accumulator = 0;
#endif
TERN_(CANCEL_OBJECTS, cancelable.reset());
TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0);
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
ui.reset_remaining_time();
#endif
@@ -410,11 +402,7 @@ void startOrResumeJob() {
#if ENABLED(SDSUPPORT)
inline void abortSDPrinting() {
card.endFilePrint(
#if SD_RESORT
true
#endif
);
card.endFilePrint(TERN_(SD_RESORT, true));
queue.clear();
quickstop_stepper();
print_job_timer.stop();
@@ -427,9 +415,7 @@ void startOrResumeJob() {
cutter.kill(); // Full cutter shutdown including ISR control
#endif
wait_for_heatup = false;
#if ENABLED(POWER_LOSS_RECOVERY)
recovery.purge();
#endif
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
#ifdef EVENT_GCODE_SD_STOP
queue.inject_P(PSTR(EVENT_GCODE_SD_STOP));
#endif
@@ -534,13 +520,9 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
}
#endif
#if ENABLED(USE_CONTROLLER_FAN)
controllerFan.update(); // Check if fan should be turned on to cool stepper drivers down
#endif
TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
#if ENABLED(AUTO_POWER_CONTROL)
powerManager.check();
#endif
TERN_(AUTO_POWER_CONTROL, powerManager.check());
#if ENABLED(EXTRUDER_RUNOUT_PREVENT)
if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP
@@ -608,17 +590,11 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
}
#endif
#if ENABLED(TEMP_STAT_LEDS)
handle_status_leds();
#endif
TERN_(TEMP_STAT_LEDS, handle_status_leds());
#if ENABLED(MONITOR_DRIVER_STATUS)
monitor_tmc_drivers();
#endif
TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers());
#if ENABLED(MONITOR_L6470_DRIVER_STATUS)
L64xxManager.monitor_driver();
#endif
TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver());
// Limit check_axes_activity frequency to 10Hz
static millis_t next_check_axes_ms = 0;
@@ -669,17 +645,13 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
thermalManager.manage_heater();
// Max7219 heartbeat, animation, etc
#if ENABLED(MAX7219_DEBUG)
max7219.idle_tasks();
#endif
TERN_(MAX7219_DEBUG, max7219.idle_tasks());
// Return if setup() isn't completed
if (marlin_state == MF_INITIALIZING) return;
// Handle filament runout sensors
#if HAS_FILAMENT_SENSOR
runout.run();
#endif
TERN_(HAS_FILAMENT_SENSOR, runout.run());
// Run HAL idle tasks
#ifdef HAL_IDLETASK
@@ -700,29 +672,19 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
#endif
// Handle SD Card insert / remove
#if ENABLED(SDSUPPORT)
card.manage_media();
#endif
TERN_(SDSUPPORT, card.manage_media());
// Handle USB Flash Drive insert / remove
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
Sd2Card::idle();
#endif
TERN_(USB_FLASH_DRIVE_SUPPORT, Sd2Card::idle());
// Announce Host Keepalive state (if any)
#if ENABLED(HOST_KEEPALIVE_FEATURE)
gcode.host_keepalive();
#endif
TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive());
// Update the Print Job Timer state
#if ENABLED(PRINTCOUNTER)
print_job_timer.tick();
#endif
TERN_(PRINTCOUNTER, print_job_timer.tick());
// Update the Beeper queue
#if USE_BEEPER
buzzer.tick();
#endif
TERN_(USE_BEEPER, buzzer.tick());
// Read Buttons and Update the LCD
ui.update();
@@ -742,24 +704,16 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
// Auto-report Temperatures / SD Status
#if HAS_AUTO_REPORTING
if (!gcode.autoreport_paused) {
#if ENABLED(AUTO_REPORT_TEMPERATURES)
thermalManager.auto_report_temperatures();
#endif
#if ENABLED(AUTO_REPORT_SD_STATUS)
card.auto_report_sd_status();
#endif
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_report_temperatures());
TERN_(AUTO_REPORT_SD_STATUS, card.auto_report_sd_status());
}
#endif
// Update the Prusa MMU2
#if ENABLED(PRUSA_MMU2)
mmu2.mmu_loop();
#endif
TERN_(PRUSA_MMU2, mmu2.mmu_loop());
// Handle Joystick jogging
#if ENABLED(POLL_JOG)
joystick.inject_jog_moves();
#endif
TERN_(POLL_JOG, joystick.inject_jog_moves());
}
/**
@@ -769,9 +723,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
thermalManager.disable_all_heaters();
#if HAS_CUTTER
cutter.kill(); // Full cutter shutdown including ISR control
#endif
TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
SERIAL_ERROR_MSG(STR_ERR_KILLED);
@@ -802,20 +754,14 @@ void minkill(const bool steppers_off/*=false*/) {
// Reiterate heaters off
thermalManager.disable_all_heaters();
#if HAS_CUTTER
cutter.kill(); // Reiterate cutter shutdown
#endif
TERN_(HAS_CUTTER, cutter.kill()); // Reiterate cutter shutdown
// Power off all steppers (for M112) or just the E steppers
steppers_off ? disable_all_steppers() : disable_e_steppers();
#if ENABLED(PSU_CONTROL)
PSU_OFF();
#endif
TERN_(PSU_CONTROL, PSU_OFF());
#if HAS_SUICIDE
suicide();
#endif
TERN_(HAS_SUICIDE, suicide());
#if HAS_KILL
@@ -1016,9 +962,7 @@ void setup() {
SETUP_RUN(touch.init());
#endif
#if HAS_M206_COMMAND
current_position += home_offset; // Init current position based on home_offset
#endif
TERN_(HAS_M206_COMMAND, current_position += home_offset); // Init current position based on home_offset
sync_plan_position(); // Vital to init stepper/planner equivalent for current_position