Add multi-extruder condition

This commit is contained in:
Scott Lahteine
2020-09-20 18:29:08 -05:00
parent 8e0fac897b
commit 76d8d1742c
50 changed files with 127 additions and 144 deletions

View File

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

View File

@ -111,7 +111,7 @@ xyze_pos_t destination; // {0}
#endif
// The active extruder (tool). Set with T<extruder> command.
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
uint8_t active_extruder = 0; // = 0
#endif

View File

@ -98,7 +98,7 @@ extern feedRate_t feedrate_mm_s;
extern int16_t feedrate_percentage;
// The active extruder (tool). Set with T<extruder> command.
#if EXTRUDERS > 1
#if HAS_MULTI_EXTRUDER
extern uint8_t active_extruder;
#else
constexpr uint8_t active_extruder = 0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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