From 76d8d1742c1d4a1efe0fd6c0645d3fc656bfd0b2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 20 Sep 2020 18:29:08 -0500 Subject: [PATCH] Add multi-extruder condition --- Marlin/Configuration_adv.h | 4 ++-- Marlin/src/HAL/DUE/HAL_SPI.cpp | 2 +- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 10 +++++----- Marlin/src/feature/dac/dac_dac084s085.cpp | 6 +++--- Marlin/src/feature/fwretract.cpp | 16 +++++++--------- Marlin/src/feature/fwretract.h | 4 ++-- Marlin/src/feature/powerloss.cpp | 10 +++++----- Marlin/src/feature/powerloss.h | 2 +- Marlin/src/gcode/config/M217.cpp | 4 ++-- Marlin/src/gcode/control/T.cpp | 2 +- Marlin/src/gcode/feature/fwretract/G10_G11.cpp | 4 ++-- Marlin/src/gcode/feature/pause/M600.cpp | 6 +++--- Marlin/src/gcode/feature/pause/M603.cpp | 2 +- Marlin/src/gcode/feature/pause/M701_M702.cpp | 12 ++++++------ Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 4 +--- Marlin/src/inc/Conditionals_LCD.h | 2 ++ Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 4 ++-- .../screens/endstop_state_screen.cpp | 2 +- .../screens/linear_advance_screen.cpp | 4 ++-- .../screens/max_velocity_screen.cpp | 2 +- .../screens/move_axis_screen.cpp | 4 ++-- .../screens/nudge_nozzle_screen.cpp | 12 ++++++------ .../lib/ftdi_eve_touch_ui/screens/screen_data.h | 2 +- .../screens/stepper_current_screen.cpp | 4 ++-- .../ftdi_eve_touch_ui/screens/steps_screen.cpp | 4 ++-- .../screens/stress_test_screen.cpp | 4 +--- .../lcd/extui/lib/mks_ui/draw_change_speed.cpp | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/draw_extrusion.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 4 ++-- .../src/lcd/extui/lib/mks_ui/draw_printing.cpp | 12 +++++++----- Marlin/src/lcd/extui/ui_api.cpp | 17 ++++++----------- Marlin/src/lcd/menu/menu_advanced.cpp | 12 ++++++------ Marlin/src/lcd/menu/menu_configuration.cpp | 10 +++++----- Marlin/src/lcd/menu/menu_tune.cpp | 4 ++-- Marlin/src/lcd/ultralcd.cpp | 6 ++---- Marlin/src/module/endstops.cpp | 2 +- Marlin/src/module/motion.cpp | 2 +- Marlin/src/module/motion.h | 2 +- Marlin/src/module/planner.cpp | 4 ++-- Marlin/src/module/planner.h | 2 +- Marlin/src/module/settings.cpp | 12 ++++++------ Marlin/src/module/stepper.cpp | 12 ++++++------ Marlin/src/module/stepper.h | 13 ++++--------- Marlin/src/module/tool_change.cpp | 6 +++--- Marlin/src/module/tool_change.h | 2 +- Marlin/src/pins/sensitive_pins.h | 4 ++-- .../PlatformIO/scripts/common-dependencies.h | 3 --- 50 files changed, 127 insertions(+), 144 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a010856d1..23d39b4d0 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1979,7 +1979,7 @@ * Universal tool change settings. * Applies to all types of extruders except where explicitly noted. */ -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER // Z raise distance for tool-change, as needed for some extruders #define TOOLCHANGE_ZRAISE 2 // (mm) //#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled) @@ -2043,7 +2043,7 @@ //#define TOOLCHANGE_PARK_X_ONLY // X axis only move //#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move #endif -#endif // EXTRUDERS > 1 +#endif // HAS_MULTI_EXTRUDER /** * Advanced Pause diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp index 6d8f7ef81..97d69f0d7 100644 --- a/Marlin/src/HAL/DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp @@ -595,7 +595,7 @@ SPI_Enable(SPI0); SET_OUTPUT(DAC0_SYNC); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SET_OUTPUT(DAC1_SYNC); WRITE(DAC1_SYNC, HIGH); #endif diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index caec347bf..3fc1dd801 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -141,7 +141,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "Serial port pins (2) conflict with probe pin!" #elif IS_TX2(X_ENABLE_PIN) || IS_RX2(X_DIR_PIN) || IS_TX2(Y_ENABLE_PIN) || IS_RX2(Y_DIR_PIN) #error "Serial port pins (2) conflict with X/Y stepper pins!" - #elif EXTRUDERS > 1 && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN))) + #elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN))) #error "Serial port pins (2) conflict with E1 stepper pins!" #elif EXTRUDERS && (IS_RX2(E0_DIR_PIN) || IS_RX2(E0_STEP_PIN)) #error "Serial port pins (2) conflict with E stepper pins!" @@ -168,7 +168,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "Serial port pins (3) conflict with Z3 pins!" #elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP) #error "Serial port pins (3) conflict with Z4 pins!" - #elif EXTRUDERS > 1 && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP)) + #elif HAS_MULTI_EXTRUDER && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP)) #error "Serial port pins (3) conflict with E1 pins!" #endif #undef PIN_IS_TX3 @@ -214,7 +214,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals." #elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP) #error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals." - #elif EXTRUDERS > 1 && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP)) + #elif HAS_MULTI_EXTRUDER && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP)) #error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals." #endif #undef PIN_IS_SDA1 @@ -240,9 +240,9 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals." #elif PIN_IS_SDA2(Z4_ENABLE) #error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals." - #elif EXTRUDERS > 1 && PIN_IS_SDA2(E1_ENABLE) + #elif HAS_MULTI_EXTRUDER && PIN_IS_SDA2(E1_ENABLE) #error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals." - #elif EXTRUDERS > 1 && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS) + #elif HAS_MULTI_EXTRUDER && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS) #error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals." #elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR)) #error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals." diff --git a/Marlin/src/feature/dac/dac_dac084s085.cpp b/Marlin/src/feature/dac/dac_dac084s085.cpp index a07dc071d..82d17fa28 100644 --- a/Marlin/src/feature/dac/dac_dac084s085.cpp +++ b/Marlin/src/feature/dac/dac_dac084s085.cpp @@ -21,7 +21,7 @@ void dac084s085::begin() { // All SPI chip-select HIGH SET_OUTPUT(DAC0_SYNC); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SET_OUTPUT(DAC1_SYNC); #endif cshigh(); @@ -38,7 +38,7 @@ void dac084s085::begin() { spiSend(SPI_CHAN_DAC, externalDac_buf, COUNT(externalDac_buf)); WRITE(DAC0_SYNC, HIGH); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER //init Piggy DAC DELAY_US(2); WRITE(DAC1_SYNC, LOW); @@ -86,7 +86,7 @@ void dac084s085::setValue(const uint8_t channel, const uint8_t value) { void dac084s085::cshigh() { WRITE(DAC0_SYNC, HIGH); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER WRITE(DAC1_SYNC, HIGH); #endif WRITE(SPI_EEPROM1_CS, HIGH); diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index c0e4db0a4..e5c52562a 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -42,7 +42,7 @@ FWRetract fwretract; // Single instance - this calls the constructor // private: -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER bool FWRetract::retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted #endif @@ -73,9 +73,7 @@ void FWRetract::reset() { LOOP_L_N(i, EXTRUDERS) { retracted[i] = false; - #if EXTRUDERS > 1 - retracted_swap[i] = false; - #endif + TERN_(HAS_MULTI_EXTRUDER, retracted_swap[i] = false); current_retract[i] = 0.0; } } @@ -92,7 +90,7 @@ void FWRetract::reset() { * included in the G-code. Use M207 Z0 to to prevent double hop. */ void FWRetract::retract(const bool retracting - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER , bool swapping/*=false*/ #endif ) { @@ -100,7 +98,7 @@ void FWRetract::retract(const bool retracting if (retracted[active_extruder] == retracting) return; // Prevent two swap-retract or recovers in a row - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER // Allow G10 S1 only after G11 if (swapping && retracted_swap[active_extruder] == retracting) return; // G11 priority to recover the long retract if activated @@ -117,7 +115,7 @@ void FWRetract::retract(const bool retracting ); LOOP_L_N(i, EXTRUDERS) { SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); #endif } @@ -180,7 +178,7 @@ void FWRetract::retract(const bool retracting retracted[active_extruder] = retracting; // Active extruder now retracted / recovered // If swap retract/recover update the retracted_swap flag too - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER if (swapping) retracted_swap[active_extruder] = retracting; #endif @@ -190,7 +188,7 @@ void FWRetract::retract(const bool retracting SERIAL_ECHOLNPAIR("active_extruder ", active_extruder); LOOP_L_N(i, EXTRUDERS) { SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); #endif } diff --git a/Marlin/src/feature/fwretract.h b/Marlin/src/feature/fwretract.h index 3d6873642..134851965 100644 --- a/Marlin/src/feature/fwretract.h +++ b/Marlin/src/feature/fwretract.h @@ -42,7 +42,7 @@ typedef struct { class FWRetract { private: - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER static bool retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted #endif @@ -75,7 +75,7 @@ public: } static void retract(const bool retracting - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER , bool swapping = false #endif ); diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 06296dd21..ed3a4b9fa 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -186,13 +186,13 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/ TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift); info.feedrate = uint16_t(feedrate_mm_s * 60.0f); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER info.active_extruder = active_extruder; #endif #if DISABLED(NO_VOLUMETRICS) info.volumetric_enabled = parser.volumetric_enabled; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e]; #else if (parser.volumetric_enabled) info.filament_size[0] = planner.filament_size[active_extruder]; @@ -369,7 +369,7 @@ void PrintJobRecovery::resume() { // Recover volumetric extrusion state #if DISABLED(NO_VOLUMETRICS) - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER for (int8_t e = 0; e < EXTRUDERS; e++) { sprintf_P(cmd, PSTR("M200 T%i D%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1)); gcode.process_subcommands_now(cmd); @@ -411,7 +411,7 @@ void PrintJobRecovery::resume() { #endif // Select the previously active tool (with no_move) - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER sprintf_P(cmd, PSTR("T%i S"), info.active_extruder); gcode.process_subcommands_now(cmd); #endif @@ -543,7 +543,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOLNPAIR("feedrate: ", info.feedrate); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER DEBUG_ECHOLNPAIR("active_extruder: ", int(info.active_extruder)); #endif diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 10653493a..1943175b0 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -58,7 +58,7 @@ typedef struct { uint16_t feedrate; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER uint8_t active_extruder; #endif diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 0d049ede1..b57dec31f 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfigPre.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../gcode.h" #include "../../module/tool_change.h" @@ -170,4 +170,4 @@ void GcodeSuite::M217() { M217_report(); } -#endif // EXTRUDERS > 1 +#endif // HAS_MULTI_EXTRUDER diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index 46cdfebf1..729f7f222 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -23,7 +23,7 @@ #include "../gcode.h" #include "../../module/tool_change.h" -#if ENABLED(DEBUG_LEVELING_FEATURE) || EXTRUDERS > 1 +#if EITHER(HAS_MULTI_EXTRUDER, DEBUG_LEVELING_FEATURE) #include "../../module/motion.h" #endif diff --git a/Marlin/src/gcode/feature/fwretract/G10_G11.cpp b/Marlin/src/gcode/feature/fwretract/G10_G11.cpp index 05f015036..219502f28 100644 --- a/Marlin/src/gcode/feature/fwretract/G10_G11.cpp +++ b/Marlin/src/gcode/feature/fwretract/G10_G11.cpp @@ -33,11 +33,11 @@ * TODO: Handle 'G10 P' for tool settings and 'G10 L' for workspace settings */ void GcodeSuite::G10() { - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER const bool rs = parser.boolval('S'); #endif fwretract.retract(true - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER , rs #endif ); diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index fe1d90109..7c9be54b2 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -29,7 +29,7 @@ #include "../../../module/motion.h" #include "../../../module/printcounter.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../../module/tool_change.h" #endif @@ -105,7 +105,7 @@ void GcodeSuite::M600() { if (!all_axes_known()) home_all_axes(); #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER // Change toolhead if specified const uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !dxc_is_duplicating())) @@ -163,7 +163,7 @@ void GcodeSuite::M600() { #endif } - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) tool_change(active_extruder_before_filament_change, false); diff --git a/Marlin/src/gcode/feature/pause/M603.cpp b/Marlin/src/gcode/feature/pause/M603.cpp index a62b5cd46..c40f3ae6e 100644 --- a/Marlin/src/gcode/feature/pause/M603.cpp +++ b/Marlin/src/gcode/feature/pause/M603.cpp @@ -29,7 +29,7 @@ #include "../../../module/motion.h" #include "../../../module/printcounter.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../../module/tool_change.h" #endif diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index a02f2368e..c1f722314 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -30,7 +30,7 @@ #include "../../../module/temperature.h" #include "../../../feature/pause.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../../module/tool_change.h" #endif @@ -86,7 +86,7 @@ void GcodeSuite::M701() { // Show initial "wait for load" message TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_LOAD, PAUSE_MODE_LOAD_FILAMENT, target_extruder)); - #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) @@ -121,7 +121,7 @@ void GcodeSuite::M701() { if (park_point.z > 0) do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); - #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) tool_change(active_extruder_before_filament_change, false); @@ -186,7 +186,7 @@ void GcodeSuite::M702() { // Show initial "wait for unload" message TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, PAUSE_MODE_UNLOAD_FILAMENT, target_extruder)); - #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) @@ -201,7 +201,7 @@ void GcodeSuite::M702() { #if ENABLED(PRUSA_MMU2) mmu2.unload(); #else - #if EXTRUDERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS) + #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_UNLOAD_ALL_EXTRUDERS) if (!parser.seenval('T')) { HOTEND_LOOP() { if (e != active_extruder) tool_change(e, false); @@ -227,7 +227,7 @@ void GcodeSuite::M702() { if (park_point.z > 0) do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); - #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) tool_change(active_extruder_before_filament_change, false); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index c1b6deead..39276bc72 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -614,7 +614,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 211: M211(); break; // M211: Enable, Disable, and/or Report software endstops #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 217: M217(); break; // M217: Set filament swap parameters #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 242730126..085f6b361 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -661,9 +661,7 @@ private: static void M211(); - #if EXTRUDERS > 1 - static void M217(); - #endif + TERN_(HAS_MULTI_EXTRUDER, static void M217()); TERN_(HAS_HOTEND_OFFSET, static void M218()); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index d5ef62b62..95c93beb9 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -501,6 +501,8 @@ #undef MK2_MULTIPLEXER #undef PRUSA_MMU2 #undef HOTEND_IDLE_TIMEOUT +#elif EXTRUDERS > 1 + #define HAS_MULTI_EXTRUDER 1 #endif #if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 2b232623a..2ae4f4e39 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2334,7 +2334,7 @@ #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0 #endif -#if EXTRUDERS > 1 && !defined(TOOLCHANGE_FS_EXTRA_PRIME) +#if HAS_MULTI_EXTRUDER && !defined(TOOLCHANGE_FS_EXTRA_PRIME) #define TOOLCHANGE_FS_EXTRA_PRIME 0 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 9f15d7e5e..8d68b33ec 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -865,7 +865,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Options only for EXTRUDERS > 1 */ -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #if EXTRUDERS > 8 #error "Marlin supports a maximum of 8 EXTRUDERS." @@ -987,7 +987,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Mixing Extruder requirements */ #if ENABLED(MIXING_EXTRUDER) - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER #error "For MIXING_EXTRUDER set MIXING_STEPPERS > 1 instead of EXTRUDERS > 1." #elif MIXING_STEPPERS < 2 #error "You must set MIXING_STEPPERS >= 2 for a mixing extruder." diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp index 6044d0a95..7f3f507fd 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp @@ -96,7 +96,7 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { #else PIN_DISABLED(1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT) #endif - #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2) && EXTRUDERS > 1 + #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2) PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, FIL_RUNOUT_STATE) #else PIN_DISABLED(3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.cpp index fb90ae113..8a5c675fa 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.cpp @@ -34,7 +34,7 @@ void LinearAdvanceScreen::onRedraw(draw_mode_t what) { widgets_t w(what); w.precision(2, DEFAULT_LOWEST).color(e_axis); w.heading( GET_TEXT_F(MSG_LINEAR_ADVANCE)); - #if EXTRUDERS == 1 + #if !HAS_MULTI_EXTRUDER w.adjuster( 2, GET_TEXT_F(MSG_LINEAR_ADVANCE_K), getLinearAdvance_mm_mm_s(E0) ); #else w.adjuster( 2, GET_TEXT_F(MSG_LINEAR_ADVANCE_K1), getLinearAdvance_mm_mm_s(E0) ); @@ -55,7 +55,7 @@ bool LinearAdvanceScreen::onTouchHeld(uint8_t tag) { switch (tag) { case 2: UI_DECREMENT(LinearAdvance_mm_mm_s, E0); break; case 3: UI_INCREMENT(LinearAdvance_mm_mm_s, E0); break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 4: UI_DECREMENT(LinearAdvance_mm_mm_s, E1); break; case 5: UI_INCREMENT(LinearAdvance_mm_mm_s, E1); break; #if EXTRUDERS > 2 diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp index 95e29c197..2316f93ee 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp @@ -41,7 +41,7 @@ void MaxVelocityScreen::onRedraw(draw_mode_t what) { w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_VMAX_Z), getAxisMaxFeedrate_mm_s(Z) ); #if EXTRUDERS == 1 || DISABLED(DISTINCT_E_FACTORS) w.color(e_axis) .adjuster( 8, GET_TEXT_F(MSG_VMAX_E), getAxisMaxFeedrate_mm_s(E0) ); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER w.heading(GET_TEXT_F(MSG_VMAX_E)); w.color(e_axis) .adjuster( 8, F(LCD_STR_E0), getAxisMaxFeedrate_mm_s(E0) ); w.color(e_axis) .adjuster( 10, F(LCD_STR_E1), getAxisMaxFeedrate_mm_s(E1) ); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp index 14ca6fe29..5dd317482 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp @@ -55,7 +55,7 @@ void MoveAxisScreen::onRedraw(draw_mode_t what) { w.color(Theme::e_axis); #if EXTRUDERS == 1 w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E), screen_data.MoveAxisScreen.e_rel[0], canMove(E0)); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), screen_data.MoveAxisScreen.e_rel[0], canMove(E0)); w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), screen_data.MoveAxisScreen.e_rel[1], canMove(E1)); #if EXTRUDERS > 2 @@ -82,7 +82,7 @@ bool MoveAxisScreen::onTouchHeld(uint8_t tag) { // For extruders, also update relative distances. case 8: UI_DECREMENT_AXIS(E0); screen_data.MoveAxisScreen.e_rel[0] -= increment; break; case 9: UI_INCREMENT_AXIS(E0); screen_data.MoveAxisScreen.e_rel[0] += increment; break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 10: UI_DECREMENT_AXIS(E1); screen_data.MoveAxisScreen.e_rel[1] -= increment; break; case 11: UI_INCREMENT_AXIS(E1); screen_data.MoveAxisScreen.e_rel[1] += increment; break; #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp index 091ad8f12..ed3c8d999 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp @@ -33,7 +33,7 @@ using namespace ExtUI; void NudgeNozzleScreen::onEntry() { screen_data.NudgeNozzleScreen.show_offsets = false; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER screen_data.NudgeNozzleScreen.link_nozzles = true; #endif screen_data.NudgeNozzleScreen.rel.reset(); @@ -52,11 +52,11 @@ void NudgeNozzleScreen::onRedraw(draw_mode_t what) { #endif w.color(z_axis).adjuster(6, GET_TEXT_F(MSG_AXIS_Z), screen_data.NudgeNozzleScreen.rel.z / getAxisSteps_per_mm(Z)); w.increments(); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER w.toggle(8, GET_TEXT_F(MSG_ADJUST_BOTH_NOZZLES), screen_data.NudgeNozzleScreen.link_nozzles); #endif - #if EXTRUDERS > 1 || HAS_BED_PROBE + #if HAS_MULTI_EXTRUDER || HAS_BED_PROBE w.toggle(9, GET_TEXT_F(MSG_SHOW_OFFSETS), screen_data.NudgeNozzleScreen.show_offsets); if (screen_data.NudgeNozzleScreen.show_offsets) { @@ -82,7 +82,7 @@ void NudgeNozzleScreen::onRedraw(draw_mode_t what) { bool NudgeNozzleScreen::onTouchHeld(uint8_t tag) { const float inc = getIncrement(); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER const bool link = screen_data.NudgeNozzleScreen.link_nozzles; #else constexpr bool link = true; @@ -95,13 +95,13 @@ bool NudgeNozzleScreen::onTouchHeld(uint8_t tag) { case 5: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps( steps, Y, link); screen_data.NudgeNozzleScreen.rel.y += steps; break; case 6: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps(-steps, Z, link); screen_data.NudgeNozzleScreen.rel.z -= steps; break; case 7: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps( steps, Z, link); screen_data.NudgeNozzleScreen.rel.z += steps; break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 8: screen_data.NudgeNozzleScreen.link_nozzles = !link; break; #endif case 9: screen_data.NudgeNozzleScreen.show_offsets = !screen_data.NudgeNozzleScreen.show_offsets; break; default: return false; } - #if EXTRUDERS > 1 || HAS_BED_PROBE + #if HAS_MULTI_EXTRUDER || HAS_BED_PROBE SaveSettingsDialogBox::settingsChanged(); #endif return true; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h index a274fef9e..dc38890a0 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h @@ -86,7 +86,7 @@ union screen_data_t { struct { struct base_numeric_adjustment_t placeholder; xyz_int_t rel; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER bool link_nozzles; #endif bool show_offsets; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp index a8e948a9c..e89bbd202 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp @@ -40,7 +40,7 @@ void StepperCurrentScreen::onRedraw(draw_mode_t what) { w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getAxisCurrent_mA(Z) ); #if EXTRUDERS == 1 w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AXIS_E), getAxisCurrent_mA(E0) ); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), getAxisCurrent_mA(E0) ); w.color(e_axis).adjuster(10, GET_TEXT_F(MSG_AXIS_E2), getAxisCurrent_mA(E1) ); #if EXTRUDERS > 2 @@ -64,7 +64,7 @@ bool StepperCurrentScreen::onTouchHeld(uint8_t tag) { case 7: UI_INCREMENT(AxisCurrent_mA, Z ); break; case 8: UI_DECREMENT(AxisCurrent_mA, E0); break; case 9: UI_INCREMENT(AxisCurrent_mA, E0); break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 10: UI_DECREMENT(AxisCurrent_mA, E1); break; case 11: UI_INCREMENT(AxisCurrent_mA, E1); break; #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.cpp index f3957c017..92035d1b1 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.cpp @@ -40,7 +40,7 @@ void StepsScreen::onRedraw(draw_mode_t what) { w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getAxisSteps_per_mm(Z) ); #if EXTRUDERS == 1 || DISABLED(DISTINCT_E_FACTORS) w.color(e_axis) .adjuster( 8, GET_TEXT_F(MSG_AXIS_E), getAxisSteps_per_mm(E0) ); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER w.color(e_axis) .adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), getAxisSteps_per_mm(E0) ); w.color(e_axis) .adjuster(10, GET_TEXT_F(MSG_AXIS_E2), getAxisSteps_per_mm(E1) ); #if EXTRUDERS > 2 @@ -64,7 +64,7 @@ bool StepsScreen::onTouchHeld(uint8_t tag) { case 7: UI_INCREMENT(AxisSteps_per_mm, Z); break; case 8: UI_DECREMENT(AxisSteps_per_mm, E0); break; case 9: UI_INCREMENT(AxisSteps_per_mm, E0); break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 10: UI_DECREMENT(AxisSteps_per_mm, E1); break; case 11: UI_INCREMENT(AxisSteps_per_mm, E1); break; #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp index 321c608ab..0f1fdacea 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp @@ -127,9 +127,7 @@ void StressTestScreen::onIdle() { injectCommands_P(PSTR( "G0 X100 Y100 Z100 F6000\n" "T0\nG4 S1" - #if EXTRUDERS > 1 - "\nT1\nG4 S1" - #endif + TERN_(HAS_MULTI_EXTRUDER, "\nT1\nG4 S1") "\nG0 X150 Y150 Z150" )); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp index 264d528c0..3589b96d6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp @@ -70,7 +70,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { //planner.flow_percentage[1] = planner.flow_percentage[0]; //planner.e_factor[1]= planner.flow_percentage[1]*0.01; planner.refresh_e_factor(0); - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER planner.flow_percentage[1] = planner.flow_percentage[0]; planner.refresh_e_factor(1); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index aad5e4362..3b4fc8d20 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -95,7 +95,7 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { //saved_feedrate_percentage = feedrate_percentage; planner.flow_percentage[0] = 100; planner.e_factor[0] = planner.flow_percentage[0] * 0.01f; - #if EXTRUDERS == 2 + #if HAS_MULTI_EXTRUDER planner.flow_percentage[1] = 100; planner.e_factor[1] = planner.flow_percentage[1] * 0.01f; #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index ca84b4b5e..95d0a15be 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -90,7 +90,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - if (EXTRUDERS == 2) { + if (ENABLED(HAS_MULTI_EXTRUDER)) { if (uiCfg.curSprayerChoose == 0) { uiCfg.curSprayerChoose = 1; queue.inject_P(PSTR("T1")); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp index 801114e6b..196522b8d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -61,7 +61,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); } } - #if !defined(SINGLENOZZLE) && EXTRUDERS >= 2 + #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); @@ -117,7 +117,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { if (uiCfg.curTempType == 0) { - if (EXTRUDERS == 2) { + if (ENABLED(HAS_MULTI_EXTRUDER)) { if (uiCfg.curSprayerChoose == 0) { uiCfg.curSprayerChoose = 1; } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index 2079ed824..e5a7bb18d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -242,8 +242,10 @@ void lv_draw_printing(void) { #endif // if 1 lv_obj_set_pos(buttonExt1, 205, 136); - if (EXTRUDERS == 2) + + #if HAS_MULTI_EXTRUDER lv_obj_set_pos(buttonExt2, 350, 136); + #endif #if HAS_HEATED_BED lv_obj_set_pos(buttonBedstate, 205, 186); @@ -275,11 +277,11 @@ void lv_draw_printing(void) { lv_obj_set_style(labelExt1, &tft_style_label_rel); lv_obj_set_pos(labelExt1, 250, 146); - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER labelExt2 = lv_label_create(scr, NULL); lv_obj_set_style(labelExt2, &tft_style_label_rel); lv_obj_set_pos(labelExt2, 395, 146); - } + #endif #if HAS_HEATED_BED labelBed = lv_label_create(scr, NULL); @@ -344,11 +346,11 @@ void disp_ext_temp() { sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); lv_label_set_text(labelExt1, public_buf_l); - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER ZERO(public_buf_l); sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target); lv_label_set_text(labelExt2, public_buf_l); - } + #endif } void disp_bed_temp() { diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 1637d3287..afc9c6692 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -61,7 +61,7 @@ #include "../../libs/numtostr.h" #endif -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../module/tool_change.h" #endif @@ -348,7 +348,7 @@ namespace ExtUI { } void setActiveTool(const extruder_t extruder, bool no_move) { - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER const uint8_t e = extruder - E0; if (e != active_extruder) tool_change(e, no_move); active_extruder = e; @@ -699,21 +699,17 @@ namespace ExtUI { */ void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles) { const float mm = steps * planner.steps_to_mm[axis]; + UNUSED(mm); if (!babystepAxis_steps(steps, axis)) return; #if ENABLED(BABYSTEP_ZPROBE_OFFSET) // Make it so babystepping in Z adjusts the Z probe offset. - if (axis == Z - #if EXTRUDERS > 1 - && (linked_nozzles || active_extruder == 0) - #endif - ) probe.offset.z += mm; - #else - UNUSED(mm); + if (axis == Z && TERN1(HAS_MULTI_EXTRUDER, linked_nozzles || active_extruder == 0)) + probe.offset.z += mm; #endif - #if EXTRUDERS > 1 && HAS_HOTEND_OFFSET + #if HAS_MULTI_EXTRUDER && HAS_HOTEND_OFFSET /** * When linked_nozzles is false, as an axis is babystepped * adjust the hotend offsets so that the other nozzles are @@ -730,7 +726,6 @@ namespace ExtUI { } #else UNUSED(linked_nozzles); - UNUSED(mm); #endif } diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 9978bc7ea..5bca89141 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -111,7 +111,7 @@ void menu_backlash(); #if ENABLED(LIN_ADVANCE) #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); #endif @@ -122,7 +122,7 @@ void menu_backlash(); #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) EDIT_ITEM_FAST(float42_52, MSG_VOLUMETRIC_LIMIT, &planner.volumetric_extruder_limit[active_extruder], 0.0f, 20.0f, planner.calculate_volumetric_extruder_limits); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_FAST_N(float42_52, n, MSG_VOLUMETRIC_LIMIT_E, &planner.volumetric_extruder_limit[n], 0.0f, 20.00f, planner.calculate_volumetric_extruder_limits); #endif @@ -130,7 +130,7 @@ void menu_backlash(); if (parser.volumetric_enabled) { EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); #endif @@ -141,13 +141,13 @@ void menu_backlash(); constexpr float extrude_maxlength = TERN(PREVENT_LENGTHY_EXTRUDE, EXTRUDE_MAXLENGTH, 999); EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength); #endif EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength); #endif @@ -583,7 +583,7 @@ void menu_advanced_settings() { #elif ENABLED(LIN_ADVANCE) #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER LOOP_L_N(n, E_STEPPERS) EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); #endif diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index a77e9a735..2953b3b46 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -94,7 +94,7 @@ void menu_advanced_settings(); #endif -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../module/tool_change.h" @@ -280,17 +280,17 @@ void menu_advanced_settings(); EDIT_ITEM(bool, MSG_AUTORETRACT, &fwretract.autoretract_enabled, fwretract.refresh_autoretract); #endif EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT, &fwretract.settings.retract_length, 0, 100); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_SWAP, &fwretract.settings.swap_retract_length, 0, 100); #endif EDIT_ITEM(float3, MSG_CONTROL_RETRACTF, &fwretract.settings.retract_feedrate_mm_s, 1, 999); EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_ZHOP, &fwretract.settings.retract_zraise, 0, 999); EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_RECOVER, &fwretract.settings.retract_recover_extra, -100, 100); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_RECOVER_SWAP, &fwretract.settings.swap_retract_recover_extra, -100, 100); #endif EDIT_ITEM(float3, MSG_CONTROL_RETRACT_RECOVERF, &fwretract.settings.retract_recover_feedrate_mm_s, 1, 999); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER EDIT_ITEM(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &fwretract.settings.swap_retract_recover_feedrate_mm_s, 1, 999); #endif END_MENU(); @@ -380,7 +380,7 @@ void menu_configuration() { // // Set single nozzle filament retract and prime length // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SUBMENU(MSG_TOOL_CHANGE, menu_tool_change); #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) SUBMENU(MSG_TOOL_MIGRATION, menu_toolchange_migration); diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index c02906f7f..758d75c8e 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -215,7 +215,7 @@ void menu_tune() { #if EXTRUDERS EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); }); // Flow En: - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); #endif @@ -227,7 +227,7 @@ void menu_tune() { #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS) #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); #endif diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index b30f6e49c..fc55c3c2f 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -695,7 +695,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #if IS_KINEMATIC - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER const int8_t old_extruder = active_extruder; if (axis == E_AXIS) active_extruder = e_index; #endif @@ -716,9 +716,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { prepare_internal_move_to_destination(fr_mm_s); // will set current_position from destination processing = false; - #if EXTRUDERS > 1 - active_extruder = old_extruder; - #endif + TERN_(HAS_MULTI_EXTRUDER, active_extruder = old_extruder); #else diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 1169ede2d..a3a89736e 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -505,7 +505,7 @@ void Endstops::update() { // With Dual X, endstops are only checked in the homing direction for the active extruder #if ENABLED(DUAL_X_CARRIAGE) - #define E0_ACTIVE stepper.movement_extruder() == 0 + #define E0_ACTIVE stepper.last_moved_extruder == 0 #define X_MIN_TEST() ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE)) #define X_MAX_TEST() ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE)) #else diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 2f12302e5..b90430901 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -111,7 +111,7 @@ xyze_pos_t destination; // {0} #endif // The active extruder (tool). Set with T command. -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER uint8_t active_extruder = 0; // = 0 #endif diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 052e3180c..2b108b053 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -98,7 +98,7 @@ extern feedRate_t feedrate_mm_s; extern int16_t feedrate_percentage; // The active extruder (tool). Set with T command. -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER extern uint8_t active_extruder; #else constexpr uint8_t active_extruder = 0; diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 82c62ed57..30e1ffb0c 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1992,7 +1992,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->e_to_p_pressure = baricuda_e_to_p_pressure; #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER block->extruder = extruder; #endif @@ -2843,7 +2843,7 @@ bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, con FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER block->extruder = extruder; #endif diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index f3a3a0e0f..660d9ad5a 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -164,7 +164,7 @@ typedef struct block_t { }; uint32_t step_event_count; // The number of step events required to complete this block - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER uint8_t extruder; // The extruder to move (if E move) #else static constexpr uint8_t extruder = 0; diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 3cb88da4e..6608b4033 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -115,7 +115,7 @@ extern float other_extruder_advance_K[EXTRUDERS]; #endif -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "tool_change.h" void M217_report(const bool eeprom); #endif @@ -388,7 +388,7 @@ typedef struct SettingsDataStruct { // // Tool-change settings // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER toolchange_settings_t toolchange_settings; // M217 S P R #endif @@ -1320,7 +1320,7 @@ void MarlinSettings::postprocess() { // Multiple Extruders // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER _FIELD_TEST(toolchange_settings); EEPROM_WRITE(toolchange_settings); #endif @@ -2167,7 +2167,7 @@ void MarlinSettings::postprocess() { // // Tool-change settings // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER _FIELD_TEST(toolchange_settings); EEPROM_READ(toolchange_settings); #endif @@ -2488,7 +2488,7 @@ void MarlinSettings::reset() { // Tool-change Settings // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) toolchange_settings.swap_length = TOOLCHANGE_FS_LENGTH; toolchange_settings.extra_resume = TOOLCHANGE_FS_EXTRA_RESUME_LENGTH; @@ -3719,7 +3719,7 @@ void MarlinSettings::reset() { #endif #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER CONFIG_ECHO_HEADING("Tool-changing:"); CONFIG_ECHO_START(); M217_report(true); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index fab1a6154..56a75d1b4 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -155,7 +155,7 @@ uint8_t Stepper::last_direction_bits, // = 0 bool Stepper::abort_current_block; -#if DISABLED(MIXING_EXTRUDER) && EXTRUDERS > 1 +#if DISABLED(MIXING_EXTRUDER) && HAS_MULTI_EXTRUDER uint8_t Stepper::last_moved_extruder = 0xFF; #endif @@ -191,7 +191,7 @@ uint32_t Stepper::advance_divisor = 0, Stepper::decelerate_after, // The count at which to start decelerating Stepper::step_event_count; // The total event count for the current block -#if EXTRUDERS > 1 || ENABLED(MIXING_EXTRUDER) +#if EITHER(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER) uint8_t Stepper::stepper_extruder; #else constexpr uint8_t Stepper::stepper_extruder; @@ -357,11 +357,11 @@ xyze_int8_t Stepper::count_direction{0}; #elif ENABLED(DUAL_X_CARRIAGE) #define X_APPLY_DIR(v,ALWAYS) do{ \ if (extruder_duplication_enabled || ALWAYS) { X_DIR_WRITE(v); X2_DIR_WRITE(mirrored_duplication_mode ? !(v) : v); } \ - else if (movement_extruder()) X2_DIR_WRITE(v); else X_DIR_WRITE(v); \ + else if (last_moved_extruder) X2_DIR_WRITE(v); else X_DIR_WRITE(v); \ }while(0) #define X_APPLY_STEP(v,ALWAYS) do{ \ if (extruder_duplication_enabled || ALWAYS) { X_STEP_WRITE(v); X2_STEP_WRITE(v); } \ - else if (movement_extruder()) X2_STEP_WRITE(v); else X_STEP_WRITE(v); \ + else if (last_moved_extruder) X2_STEP_WRITE(v); else X_STEP_WRITE(v); \ }while(0) #else #define X_APPLY_DIR(v,Q) X_DIR_WRITE(v) @@ -2131,7 +2131,7 @@ uint32_t Stepper::block_phase_isr() { MIXER_STEPPER_SETUP(); #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER stepper_extruder = current_block->extruder; #endif @@ -2156,7 +2156,7 @@ uint32_t Stepper::block_phase_isr() { || TERN(MIXING_EXTRUDER, false, stepper_extruder != last_moved_extruder) ) { last_direction_bits = current_block->direction_bits; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER last_moved_extruder = stepper_extruder; #endif diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 3b6855368..f83142444 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -263,10 +263,10 @@ class Stepper { static bool abort_current_block; // Signals to the stepper that current block should be aborted // Last-moved extruder, as set when the last movement was fetched from planner - #if EXTRUDERS < 2 - static constexpr uint8_t last_moved_extruder = 0; - #elif DISABLED(MIXING_EXTRUDER) + #if HAS_MULTI_EXTRUDER static uint8_t last_moved_extruder; + #else + static constexpr uint8_t last_moved_extruder = 0; #endif #if ENABLED(X_DUAL_ENDSTOPS) @@ -304,7 +304,7 @@ class Stepper { decelerate_after, // The point from where we need to start decelerating step_event_count; // The total event count for the current block - #if EXTRUDERS > 1 || ENABLED(MIXING_EXTRUDER) + #if EITHER(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER) static uint8_t stepper_extruder; #else static constexpr uint8_t stepper_extruder = 0; @@ -451,11 +451,6 @@ class Stepper { // The last movement direction was not null on the specified axis. Note that motor direction is not necessarily the same. FORCE_INLINE static bool axis_is_moving(const AxisEnum axis) { return TEST(axis_did_move, axis); } - // The extruder associated to the last movement - FORCE_INLINE static uint8_t movement_extruder() { - return (EXTRUDERS > 1 && DISABLED(MIXING_EXTRUDER)) ? last_moved_extruder : 0; - } - // Handle a triggered endstop static void endstop_triggered(const AxisEnum axis); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 855756026..0f823cfbd 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -36,7 +36,7 @@ #define DEBUG_OUT ENABLED(DEBUG_TOOL_CHANGE) #include "../core/debug_out.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER toolchange_settings_t toolchange_settings; // Initialized by settings.load() #endif @@ -870,7 +870,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (new_tool) invalid_extruder_error(new_tool); return; - #else // EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER planner.synchronize(); @@ -1197,7 +1197,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(active_extruder)); - #endif // EXTRUDERS > 1 + #endif // HAS_MULTI_EXTRUDER } #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index d0cb57841..38347191d 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -24,7 +24,7 @@ #include "../inc/MarlinConfigPre.h" #include "../core/types.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER typedef struct { #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index 5f61389cf..169f74b43 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -354,7 +354,7 @@ #endif #endif -#elif EXTRUDERS > 1 || ENABLED(MIXING_EXTRUDER) +#elif EITHER(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER) #undef _E1_PINS #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, _E1_CS _E1_MS1 _E1_MS2 _E1_MS3 @@ -383,7 +383,7 @@ #endif // EXTRUDERS > 3 || MIXING_EXTRUDER > 3 #endif // EXTRUDERS > 2 || MIXING_EXTRUDER > 2 -#endif // EXTRUDERS > 1 || MIXING_EXTRUDER +#endif // HAS_MULTI_EXTRUDER || MIXING_EXTRUDER // // Heaters, Fans, Temp Sensors diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index e27e628b9..e88e74e81 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -91,9 +91,6 @@ #if EXTRUDERS #define HAS_EXTRUDERS - #if EXTRUDERS > 1 - #define HAS_MULTI_EXTRUDER - #endif #endif #if HAS_LCD_MENU