Skip to content

Commit

Permalink
Fix IDEX layer shift and DIR states (MarlinFirmware#19756)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
2 people authored and Speaka committed Oct 23, 2020
1 parent 4d92311 commit f459831
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 134 deletions.
21 changes: 6 additions & 15 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
const bool saved_ext_dup_mode = extruder_duplication_enabled;
active_extruder = DXC_ext;
extruder_duplication_enabled = false;
set_duplication_enabled(false, DXC_ext);
#endif

// Slow Load filament
Expand All @@ -245,9 +244,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
}

#if ENABLED(DUAL_X_CARRIAGE) // Tie the two extruders movement back together.
active_extruder = saved_ext;
extruder_duplication_enabled = saved_ext_dup_mode;
stepper.set_directions();
set_duplication_enabled(saved_ext_dup_mode, saved_ext);
#endif

#if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
Expand Down Expand Up @@ -439,17 +436,14 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
const bool saved_ext_dup_mode = extruder_duplication_enabled;
active_extruder = DXC_ext;
extruder_duplication_enabled = false;
set_duplication_enabled(false, DXC_ext);
#endif

if (unload_length) // Unload the filament
unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);

#if ENABLED(DUAL_X_CARRIAGE)
active_extruder = saved_ext;
extruder_duplication_enabled = saved_ext_dup_mode;
stepper.set_directions();
set_duplication_enabled(saved_ext_dup_mode, saved_ext);
#endif

return true;
Expand Down Expand Up @@ -495,8 +489,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
const bool saved_ext_dup_mode = extruder_duplication_enabled;
active_extruder = DXC_ext;
extruder_duplication_enabled = false;
set_duplication_enabled(false, DXC_ext);
#endif

// Wait for filament insert by user and press button
Expand Down Expand Up @@ -550,9 +543,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
idle_no_sleep();
}
#if ENABLED(DUAL_X_CARRIAGE)
active_extruder = saved_ext;
extruder_duplication_enabled = saved_ext_dup_mode;
stepper.set_directions();
set_duplication_enabled(saved_ext_dup_mode, saved_ext);
#endif
}

Expand Down
7 changes: 4 additions & 3 deletions Marlin/src/feature/pause.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float

void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS);

void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, const int8_t max_beep_count=0, int16_t targetTemp=0 DXC_PARAMS);
void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH,
const int8_t max_beep_count=0, int16_t targetTemp=0 DXC_PARAMS);

bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, const bool show_lcd=false,
const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);
bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0,
const bool show_lcd=false, const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);

bool unload_filament(const float &unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT
#if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/runout.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class FilamentSensorBase {
#if NUM_RUNOUT_SENSORS == 1
UNUSED(extruder);
#else
if ( !TERN0(DUAL_X_CARRIAGE, dxc_is_duplicating())
if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())
&& !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled)
) return TEST(runout_states, extruder); // A specific extruder ran out
#endif
Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/gcode/bedlevel/G35.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ void GcodeSuite::G35() {
tool_change(0, true);
#endif

#if HAS_DUPLICATION_MODE
extruder_duplication_enabled = false;
#endif
// Disable duplication mode on homing
TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));

// Home all before this procedure
home_all_axes();
Expand Down
28 changes: 12 additions & 16 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@

if (DEBUGGING(LEVELING)) DEBUG_POS("home_z_safely", destination);

// This causes the carriage on Dual X to unpark
TERN_(DUAL_X_CARRIAGE, active_extruder_parked = false);
// Free the active extruder for movement
TERN_(DUAL_X_CARRIAGE, idex_set_parked(false));

TERN_(SENSORLESS_HOMING, safe_delay(500)); // Short delay needed to settle

Expand Down Expand Up @@ -282,7 +282,7 @@ void GcodeSuite::G28() {
tool_change(0, true);
#endif

TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false);
TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));

remember_feedrate_scaling_off();

Expand Down Expand Up @@ -342,16 +342,14 @@ void GcodeSuite::G28() {
homeaxis(X_AXIS);

// Remember this extruder's position for later tool change
inactive_extruder_x_pos = current_position.x;
inactive_extruder_x = current_position.x;

// Home the 1st (left) extruder
active_extruder = 0;
homeaxis(X_AXIS);

// Consider the active extruder to be parked
raised_parked_position = current_position;
delayed_move_time = 0;
active_extruder_parked = true;
// Consider the active extruder to be in its "parked" position
idex_set_parked();

#else

Expand Down Expand Up @@ -392,7 +390,7 @@ void GcodeSuite::G28() {
*/
#if ENABLED(DUAL_X_CARRIAGE)

if (dxc_is_duplicating()) {
if (idex_is_duplicating()) {

TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing = begin_slow_homing());

Expand All @@ -401,19 +399,17 @@ void GcodeSuite::G28() {
homeaxis(X_AXIS);

// Remember this extruder's position for later tool change
inactive_extruder_x_pos = current_position.x;
inactive_extruder_x = current_position.x;

// Home the 1st (left) extruder
active_extruder = 0;
homeaxis(X_AXIS);

// Consider the active extruder to be parked
raised_parked_position = current_position;
delayed_move_time = 0;
active_extruder_parked = true;
extruder_duplication_enabled = IDEX_saved_duplication_state;
dual_x_carriage_mode = IDEX_saved_mode;
stepper.set_directions();
idex_set_parked();

dual_x_carriage_mode = IDEX_saved_mode;
set_duplication_enabled(IDEX_saved_duplication_state);

TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/G34_M422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void GcodeSuite::G34() {
tool_change(0, true);
#endif

TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false);
TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));

// In BLTOUCH HS mode, the probe travels in a deployed state.
// Users of G34 might have a badly misaligned bed, so raise Z by the
Expand Down
15 changes: 6 additions & 9 deletions Marlin/src/gcode/control/M605.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
const DualXMode previous_mode = dual_x_carriage_mode;

dual_x_carriage_mode = (DualXMode)parser.value_byte();
mirrored_duplication_mode = false;
idex_set_mirrored_mode(false);

if (dual_x_carriage_mode == DXC_MIRRORED_MODE) {
if (previous_mode != DXC_DUPLICATION_MODE) {
Expand All @@ -77,8 +77,7 @@
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
return;
}
mirrored_duplication_mode = true;
stepper.set_directions();
idex_set_mirrored_mode(true);
float x_jog = current_position.x - .1;
for (uint8_t i = 2; --i;) {
planner.buffer_line(x_jog, current_position.y, current_position.z, current_position.e, feedrate_mm_s, 0);
Expand All @@ -102,10 +101,8 @@
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
break;
}
active_extruder_parked = false;
extruder_duplication_enabled = false;
stepper.set_directions();
delayed_move_time = 0;
idex_set_parked(false);
set_duplication_enabled(false);
}
else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
Expand All @@ -125,7 +122,7 @@
if (!active_extruder_parked) DEBUG_ECHOPGM(" NOT ");
DEBUG_ECHOPGM(" parked.");
DEBUG_ECHOPAIR("\nactive_extruder_x_pos: ", current_position.x);
DEBUG_ECHOPAIR("\ninactive_extruder_x_pos: ", inactive_extruder_x_pos);
DEBUG_ECHOPAIR("\ninactive_extruder_x: ", inactive_extruder_x);
DEBUG_ECHOPAIR("\nextruder_duplication_enabled: ", int(extruder_duplication_enabled));
DEBUG_ECHOPAIR("\nduplicate_extruder_x_offset: ", duplicate_extruder_x_offset);
DEBUG_ECHOPAIR("\nduplicate_extruder_temp_offset: ", duplicate_extruder_temp_offset);
Expand Down Expand Up @@ -166,7 +163,7 @@
if (parser.seenval('P')) duplication_e_mask = parser.value_int(); // Set the mask directly
else if (parser.seenval('E')) duplication_e_mask = pow(2, parser.value_int() + 1) - 1; // Set the mask by E index
ena = (2 == parser.intval('S', extruder_duplication_enabled ? 2 : 0));
extruder_duplication_enabled = ena && (duplication_e_mask >= 3);
set_duplication_enabled(ena && (duplication_e_mask >= 3));
}
SERIAL_ECHO_START();
SERIAL_ECHOPGM(STR_DUPLICATION_MODE);
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/feature/pause/M600.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void GcodeSuite::M600() {
if (!parser.seen('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout.
// In this case, for duplicating modes set DXC_ext to the extruder that ran out.
#if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
if (dxc_is_duplicating())
if (idex_is_duplicating())
DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT_STATE) ? 1 : 0;
#else
DXC_ext = active_extruder;
Expand All @@ -108,7 +108,7 @@ void GcodeSuite::M600() {
#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()))
if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !idex_is_duplicating()))
tool_change(target_extruder, false);
#endif

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/temp/M104_M109.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void GcodeSuite::M104() {
thermalManager.setTargetHotend(temp, target_extruder);

#if ENABLED(DUAL_X_CARRIAGE)
if (dxc_is_duplicating() && target_extruder == 0)
if (idex_is_duplicating() && target_extruder == 0)
thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
#endif

Expand Down Expand Up @@ -172,7 +172,7 @@ void GcodeSuite::M109() {
thermalManager.setTargetHotend(temp, target_extruder);

#if ENABLED(DUAL_X_CARRIAGE)
if (dxc_is_duplicating() && target_extruder == 0)
if (idex_is_duplicating() && target_extruder == 0)
thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
#endif

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/libs/L64XX/L64XX_Marlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = {
INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR
, (INVERT_X_DIR) // X2
#if ENABLED(X_DUAL_STEPPER_DRIVERS)
^ (INVERT_X2_VS_X_DIR)
^ ENABLED(INVERT_X2_VS_X_DIR)
#endif
, (INVERT_Y_DIR) // Y2
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
^ (INVERT_Y2_VS_Y_DIR)
^ ENABLED(INVERT_Y2_VS_Y_DIR)
#endif
, INVERT_Z_DIR, INVERT_Z_DIR, INVERT_Z_DIR // Z2,Z3,Z4

Expand Down
Loading

0 comments on commit f459831

Please sign in to comment.