|
@@ -1416,6 +1416,7 @@ static void set_home_offset(AxisEnum axis, float v) {
|
1416
|
1416
|
* current_position to home, because neither X nor Y is at home until
|
1417
|
1417
|
* both are at home. Z can however be homed individually.
|
1418
|
1418
|
*
|
|
1419
|
+ * Callers must sync the planner position after calling this!
|
1419
|
1420
|
*/
|
1420
|
1421
|
static void set_axis_is_at_home(AxisEnum axis) {
|
1421
|
1422
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -3246,10 +3247,12 @@ inline void gcode_G4() {
|
3246
|
3247
|
#endif
|
3247
|
3248
|
)
|
3248
|
3249
|
) {
|
|
3250
|
+
|
3249
|
3251
|
#if HOMING_Z_WITH_PROBE
|
3250
|
3252
|
destination[X_AXIS] -= X_PROBE_OFFSET_FROM_EXTRUDER;
|
3251
|
3253
|
destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
|
3252
|
3254
|
#endif
|
|
3255
|
+
|
3253
|
3256
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3254
|
3257
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
|
3255
|
3258
|
#endif
|
|
@@ -3407,20 +3410,31 @@ inline void gcode_G28() {
|
3407
|
3410
|
|
3408
|
3411
|
// Home X
|
3409
|
3412
|
if (home_all_axis || homeX) {
|
|
3413
|
+
|
3410
|
3414
|
#if ENABLED(DUAL_X_CARRIAGE)
|
3411
|
|
- int tmp_extruder = active_extruder;
|
3412
|
|
- active_extruder = !active_extruder;
|
|
3415
|
+
|
|
3416
|
+ // Always home the 2nd (right) extruder first
|
|
3417
|
+ active_extruder = 1;
|
3413
|
3418
|
HOMEAXIS(X);
|
|
3419
|
+
|
|
3420
|
+ // Remember this extruder's position for later tool change
|
3414
|
3421
|
inactive_extruder_x_pos = RAW_X_POSITION(current_position[X_AXIS]);
|
3415
|
|
- active_extruder = tmp_extruder;
|
|
3422
|
+
|
|
3423
|
+ // Home the 1st (left) extruder
|
|
3424
|
+ active_extruder = 0;
|
3416
|
3425
|
HOMEAXIS(X);
|
3417
|
|
- // reset state used by the different modes
|
|
3426
|
+
|
|
3427
|
+ // Consider the active extruder to be parked
|
3418
|
3428
|
memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
|
3419
|
3429
|
delayed_move_time = 0;
|
3420
|
3430
|
active_extruder_parked = true;
|
|
3431
|
+
|
3421
|
3432
|
#else
|
|
3433
|
+
|
3422
|
3434
|
HOMEAXIS(X);
|
|
3435
|
+
|
3423
|
3436
|
#endif
|
|
3437
|
+
|
3424
|
3438
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3425
|
3439
|
if (DEBUGGING(LEVELING)) DEBUG_POS("> homeX", current_position);
|
3426
|
3440
|
#endif
|
|
@@ -7446,10 +7460,8 @@ inline void invalid_extruder_error(const uint8_t &e) {
|
7446
|
7460
|
void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {
|
7447
|
7461
|
#if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
|
7448
|
7462
|
|
7449
|
|
- if (tmp_extruder >= MIXING_VIRTUAL_TOOLS) {
|
7450
|
|
- invalid_extruder_error(tmp_extruder);
|
7451
|
|
- return;
|
7452
|
|
- }
|
|
7463
|
+ if (tmp_extruder >= MIXING_VIRTUAL_TOOLS)
|
|
7464
|
+ return invalid_extruder_error(tmp_extruder);
|
7453
|
7465
|
|
7454
|
7466
|
// T0-Tnnn: Switch virtual tool by changing the mix
|
7455
|
7467
|
for (uint8_t j = 0; j < MIXING_STEPPERS; j++)
|
|
@@ -7459,10 +7471,8 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
7459
|
7471
|
|
7460
|
7472
|
#if HOTENDS > 1
|
7461
|
7473
|
|
7462
|
|
- if (tmp_extruder >= EXTRUDERS) {
|
7463
|
|
- invalid_extruder_error(tmp_extruder);
|
7464
|
|
- return;
|
7465
|
|
- }
|
|
7474
|
+ if (tmp_extruder >= EXTRUDERS)
|
|
7475
|
+ return invalid_extruder_error(tmp_extruder);
|
7466
|
7476
|
|
7467
|
7477
|
float old_feedrate_mm_s = feedrate_mm_s;
|
7468
|
7478
|
|
|
@@ -7490,22 +7500,28 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
7490
|
7500
|
}
|
7491
|
7501
|
#endif
|
7492
|
7502
|
|
7493
|
|
- if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && IsRunning() &&
|
7494
|
|
- (delayed_move_time || current_position[X_AXIS] != x_home_pos(active_extruder))
|
|
7503
|
+ const float xhome = x_home_pos(active_extruder);
|
|
7504
|
+ if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
|
|
7505
|
+ && IsRunning()
|
|
7506
|
+ && (delayed_move_time || current_position[X_AXIS] != xhome)
|
7495
|
7507
|
) {
|
|
7508
|
+ float raised_z = current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT;
|
|
7509
|
+ #if ENABLED(max_software_endstops)
|
|
7510
|
+ NOMORE(raised_z, soft_endstop_max[Z_AXIS]);
|
|
7511
|
+ #endif
|
7496
|
7512
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
7497
|
7513
|
if (DEBUGGING(LEVELING)) {
|
7498
|
|
- SERIAL_ECHOPAIR("Raise to ", current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT); SERIAL_EOL;
|
7499
|
|
- SERIAL_ECHOPAIR("MoveX to ", x_home_pos(active_extruder)); SERIAL_EOL;
|
7500
|
|
- SERIAL_ECHOPAIR("Lower to ", current_position[Z_AXIS]); SERIAL_EOL;
|
|
7514
|
+ SERIAL_ECHOLNPAIR("Raise to ", raised_z);
|
|
7515
|
+ SERIAL_ECHOLNPAIR("MoveX to ", xhome);
|
|
7516
|
+ SERIAL_ECHOLNPAIR("Lower to ", current_position[Z_AXIS]);
|
7501
|
7517
|
}
|
7502
|
7518
|
#endif
|
7503
|
7519
|
// Park old head: 1) raise 2) move to park position 3) lower
|
7504
|
7520
|
for (uint8_t i = 0; i < 3; i++)
|
7505
|
7521
|
planner.buffer_line(
|
7506
|
|
- i == 0 ? current_position[X_AXIS] : x_home_pos(active_extruder),
|
|
7522
|
+ i == 0 ? current_position[X_AXIS] : xhome,
|
7507
|
7523
|
current_position[Y_AXIS],
|
7508
|
|
- current_position[Z_AXIS] + (i == 2 ? 0 : TOOLCHANGE_PARK_ZLIFT),
|
|
7524
|
+ i == 2 ? current_position[Z_AXIS] : raised_z,
|
7509
|
7525
|
current_position[E_AXIS],
|
7510
|
7526
|
planner.max_feedrate_mm_s[i == 1 ? X_AXIS : Z_AXIS],
|
7511
|
7527
|
active_extruder
|
|
@@ -7513,9 +7529,11 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
7513
|
7529
|
stepper.synchronize();
|
7514
|
7530
|
}
|
7515
|
7531
|
|
7516
|
|
- // apply Y & Z extruder offset (x offset is already used in determining home pos)
|
|
7532
|
+ // Apply Y & Z extruder offset (X offset is used as home pos with Dual X)
|
7517
|
7533
|
current_position[Y_AXIS] -= hotend_offset[Y_AXIS][active_extruder] - hotend_offset[Y_AXIS][tmp_extruder];
|
7518
|
7534
|
current_position[Z_AXIS] -= hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
|
7535
|
+
|
|
7536
|
+ // Activate the new extruder
|
7519
|
7537
|
active_extruder = tmp_extruder;
|
7520
|
7538
|
|
7521
|
7539
|
// This function resets the max/min values - the current position may be overwritten below.
|
|
@@ -7530,7 +7548,9 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
7530
|
7548
|
|
7531
|
7549
|
switch (dual_x_carriage_mode) {
|
7532
|
7550
|
case DXC_FULL_CONTROL_MODE:
|
|
7551
|
+ // New current position is the position of the activated extruder
|
7533
|
7552
|
current_position[X_AXIS] = LOGICAL_X_POSITION(inactive_extruder_x_pos);
|
|
7553
|
+ // Save the inactive extruder's position (from the old current_position)
|
7534
|
7554
|
inactive_extruder_x_pos = RAW_X_POSITION(destination[X_AXIS]);
|
7535
|
7555
|
break;
|
7536
|
7556
|
case DXC_AUTO_PARK_MODE:
|
|
@@ -7544,7 +7564,10 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
7544
|
7564
|
delayed_move_time = 0;
|
7545
|
7565
|
break;
|
7546
|
7566
|
case DXC_DUPLICATION_MODE:
|
7547
|
|
- active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
|
|
7567
|
+ // If the new extruder is the left one, set it "parked"
|
|
7568
|
+ // This triggers the second extruder to move into the duplication position
|
|
7569
|
+ active_extruder_parked = (active_extruder == 0);
|
|
7570
|
+
|
7548
|
7571
|
if (active_extruder_parked)
|
7549
|
7572
|
current_position[X_AXIS] = LOGICAL_X_POSITION(inactive_extruder_x_pos);
|
7550
|
7573
|
else
|
|
@@ -7569,9 +7592,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
7569
|
7592
|
float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
|
7570
|
7593
|
z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
|
7571
|
7594
|
|
7572
|
|
- set_destination_to_current();
|
7573
|
|
-
|
7574
|
|
- // Always raise by some amount
|
|
7595
|
+ // Always raise by some amount (destination copied from current_position earlier)
|
7575
|
7596
|
destination[Z_AXIS] += z_raise;
|
7576
|
7597
|
planner.buffer_line_kinematic(destination, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
7577
|
7598
|
stepper.synchronize();
|
|
@@ -9260,8 +9281,11 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
9260
|
9281
|
current_position[Z_AXIS],
|
9261
|
9282
|
current_position[E_AXIS]
|
9262
|
9283
|
);
|
9263
|
|
- planner.buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset,
|
9264
|
|
- current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.max_feedrate_mm_s[X_AXIS], 1);
|
|
9284
|
+ planner.buffer_line(
|
|
9285
|
+ current_position[X_AXIS] + duplicate_extruder_x_offset,
|
|
9286
|
+ current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS],
|
|
9287
|
+ planner.max_feedrate_mm_s[X_AXIS], 1
|
|
9288
|
+ );
|
9265
|
9289
|
SYNC_PLAN_POSITION_KINEMATIC();
|
9266
|
9290
|
stepper.synchronize();
|
9267
|
9291
|
extruder_duplication_enabled = true;
|