|
@@ -2344,135 +2344,134 @@ static void clean_up_after_endstop_or_probe_move() {
|
2344
|
2344
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
2345
|
2345
|
|
2346
|
2346
|
static void homeaxis(AxisEnum axis) {
|
|
2347
|
+ #define HOMEAXIS_DO(LETTER) \
|
|
2348
|
+ ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
|
2349
|
+
|
|
2350
|
+ if (!(axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0)) return;
|
|
2351
|
+
|
2347
|
2352
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2348
|
2353
|
if (DEBUGGING(LEVELING)) {
|
2349
|
2354
|
SERIAL_ECHOPAIR(">>> homeaxis(", axis);
|
2350
|
2355
|
SERIAL_ECHOLNPGM(")");
|
2351
|
2356
|
}
|
2352
|
2357
|
#endif
|
2353
|
|
- #define HOMEAXIS_DO(LETTER) \
|
2354
|
|
- ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
2355
|
2358
|
|
2356
|
|
- if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) {
|
|
2359
|
+ int axis_home_dir =
|
|
2360
|
+ #if ENABLED(DUAL_X_CARRIAGE)
|
|
2361
|
+ (axis == X_AXIS) ? x_home_dir(active_extruder) :
|
|
2362
|
+ #endif
|
|
2363
|
+ home_dir(axis);
|
2357
|
2364
|
|
2358
|
|
- int axis_home_dir =
|
2359
|
|
- #if ENABLED(DUAL_X_CARRIAGE)
|
2360
|
|
- (axis == X_AXIS) ? x_home_dir(active_extruder) :
|
|
2365
|
+ // Homing Z towards the bed? Deploy the Z probe or endstop.
|
|
2366
|
+ #if HAS_BED_PROBE
|
|
2367
|
+ if (axis == Z_AXIS && axis_home_dir < 0) {
|
|
2368
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2369
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2361
|
2370
|
#endif
|
2362
|
|
- home_dir(axis);
|
2363
|
|
-
|
2364
|
|
- // Homing Z towards the bed? Deploy the Z probe or endstop.
|
2365
|
|
- #if HAS_BED_PROBE
|
2366
|
|
- if (axis == Z_AXIS && axis_home_dir < 0) {
|
2367
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2368
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2369
|
|
- #endif
|
2370
|
|
- if (DEPLOY_PROBE()) return;
|
2371
|
|
- }
|
2372
|
|
- #endif
|
|
2371
|
+ if (DEPLOY_PROBE()) return;
|
|
2372
|
+ }
|
|
2373
|
+ #endif
|
2373
|
2374
|
|
2374
|
|
- // Set the axis position as setup for the move
|
2375
|
|
- current_position[axis] = 0;
|
2376
|
|
- sync_plan_position();
|
|
2375
|
+ // Set the axis position as setup for the move
|
|
2376
|
+ current_position[axis] = 0;
|
|
2377
|
+ sync_plan_position();
|
2377
|
2378
|
|
2378
|
|
- // Set a flag for Z motor locking
|
2379
|
|
- #if ENABLED(Z_DUAL_ENDSTOPS)
|
2380
|
|
- if (axis == Z_AXIS) stepper.set_homing_flag(true);
|
2381
|
|
- #endif
|
|
2379
|
+ // Set a flag for Z motor locking
|
|
2380
|
+ #if ENABLED(Z_DUAL_ENDSTOPS)
|
|
2381
|
+ if (axis == Z_AXIS) stepper.set_homing_flag(true);
|
|
2382
|
+ #endif
|
2382
|
2383
|
|
2383
|
|
- // Move towards the endstop until an endstop is triggered
|
2384
|
|
- destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
|
2385
|
|
- feedrate = homing_feedrate[axis];
|
2386
|
|
- line_to_destination();
|
2387
|
|
- stepper.synchronize();
|
|
2384
|
+ // Move towards the endstop until an endstop is triggered
|
|
2385
|
+ destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
|
|
2386
|
+ feedrate = homing_feedrate[axis];
|
|
2387
|
+ line_to_destination();
|
|
2388
|
+ stepper.synchronize();
|
2388
|
2389
|
|
2389
|
|
- // Set the axis position as setup for the move
|
2390
|
|
- current_position[axis] = 0;
|
2391
|
|
- sync_plan_position();
|
|
2390
|
+ // Set the axis position as setup for the move
|
|
2391
|
+ current_position[axis] = 0;
|
|
2392
|
+ sync_plan_position();
|
2392
|
2393
|
|
2393
|
|
- // Move away from the endstop by the axis HOME_BUMP_MM
|
2394
|
|
- destination[axis] = -home_bump_mm(axis) * axis_home_dir;
|
2395
|
|
- line_to_destination();
|
2396
|
|
- stepper.synchronize();
|
|
2394
|
+ // Move away from the endstop by the axis HOME_BUMP_MM
|
|
2395
|
+ destination[axis] = -home_bump_mm(axis) * axis_home_dir;
|
|
2396
|
+ line_to_destination();
|
|
2397
|
+ stepper.synchronize();
|
2397
|
2398
|
|
2398
|
|
- // Slow down the feedrate for the next move
|
2399
|
|
- set_homing_bump_feedrate(axis);
|
|
2399
|
+ // Slow down the feedrate for the next move
|
|
2400
|
+ set_homing_bump_feedrate(axis);
|
2400
|
2401
|
|
2401
|
|
- // Move slowly towards the endstop until triggered
|
2402
|
|
- destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir;
|
2403
|
|
- line_to_destination();
|
2404
|
|
- stepper.synchronize();
|
|
2402
|
+ // Move slowly towards the endstop until triggered
|
|
2403
|
+ destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir;
|
|
2404
|
+ line_to_destination();
|
|
2405
|
+ stepper.synchronize();
|
2405
|
2406
|
|
2406
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2407
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
|
2408
|
|
- #endif
|
|
2407
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2408
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
|
|
2409
|
+ #endif
|
2409
|
2410
|
|
2410
|
|
- #if ENABLED(Z_DUAL_ENDSTOPS)
|
2411
|
|
- if (axis == Z_AXIS) {
|
2412
|
|
- float adj = fabs(z_endstop_adj);
|
2413
|
|
- bool lockZ1;
|
2414
|
|
- if (axis_home_dir > 0) {
|
2415
|
|
- adj = -adj;
|
2416
|
|
- lockZ1 = (z_endstop_adj > 0);
|
2417
|
|
- }
|
2418
|
|
- else
|
2419
|
|
- lockZ1 = (z_endstop_adj < 0);
|
|
2411
|
+ #if ENABLED(Z_DUAL_ENDSTOPS)
|
|
2412
|
+ if (axis == Z_AXIS) {
|
|
2413
|
+ float adj = fabs(z_endstop_adj);
|
|
2414
|
+ bool lockZ1;
|
|
2415
|
+ if (axis_home_dir > 0) {
|
|
2416
|
+ adj = -adj;
|
|
2417
|
+ lockZ1 = (z_endstop_adj > 0);
|
|
2418
|
+ }
|
|
2419
|
+ else
|
|
2420
|
+ lockZ1 = (z_endstop_adj < 0);
|
2420
|
2421
|
|
2421
|
|
- if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
|
2422
|
|
- sync_plan_position();
|
|
2422
|
+ if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
|
|
2423
|
+ sync_plan_position();
|
2423
|
2424
|
|
2424
|
|
- // Move to the adjusted endstop height
|
2425
|
|
- feedrate = homing_feedrate[axis];
|
2426
|
|
- destination[Z_AXIS] = adj;
|
2427
|
|
- line_to_destination();
|
2428
|
|
- stepper.synchronize();
|
2429
|
|
-
|
2430
|
|
- if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
|
2431
|
|
- stepper.set_homing_flag(false);
|
2432
|
|
- } // Z_AXIS
|
2433
|
|
- #endif
|
|
2425
|
+ // Move to the adjusted endstop height
|
|
2426
|
+ feedrate = homing_feedrate[axis];
|
|
2427
|
+ destination[Z_AXIS] = adj;
|
|
2428
|
+ line_to_destination();
|
|
2429
|
+ stepper.synchronize();
|
2434
|
2430
|
|
2435
|
|
- #if ENABLED(DELTA)
|
2436
|
|
- // retrace by the amount specified in endstop_adj
|
2437
|
|
- if (endstop_adj[axis] * axis_home_dir < 0) {
|
2438
|
|
- sync_plan_position();
|
2439
|
|
- destination[axis] = endstop_adj[axis];
|
2440
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2441
|
|
- if (DEBUGGING(LEVELING)) {
|
2442
|
|
- SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
|
2443
|
|
- DEBUG_POS("", destination);
|
2444
|
|
- }
|
2445
|
|
- #endif
|
2446
|
|
- line_to_destination();
|
2447
|
|
- stepper.synchronize();
|
2448
|
|
- }
|
2449
|
|
- #endif
|
|
2431
|
+ if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
|
|
2432
|
+ stepper.set_homing_flag(false);
|
|
2433
|
+ } // Z_AXIS
|
|
2434
|
+ #endif
|
2450
|
2435
|
|
2451
|
|
- // Set the axis position to its home position (plus home offsets)
|
2452
|
|
- set_axis_is_at_home(axis);
|
|
2436
|
+ #if ENABLED(DELTA)
|
|
2437
|
+ // retrace by the amount specified in endstop_adj
|
|
2438
|
+ if (endstop_adj[axis] * axis_home_dir < 0) {
|
|
2439
|
+ sync_plan_position();
|
|
2440
|
+ destination[axis] = endstop_adj[axis];
|
|
2441
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2442
|
+ if (DEBUGGING(LEVELING)) {
|
|
2443
|
+ SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
|
|
2444
|
+ DEBUG_POS("", destination);
|
|
2445
|
+ }
|
|
2446
|
+ #endif
|
|
2447
|
+ line_to_destination();
|
|
2448
|
+ stepper.synchronize();
|
|
2449
|
+ }
|
|
2450
|
+ #endif
|
2453
|
2451
|
|
2454
|
|
- SYNC_PLAN_POSITION_KINEMATIC();
|
|
2452
|
+ // Set the axis position to its home position (plus home offsets)
|
|
2453
|
+ set_axis_is_at_home(axis);
|
2455
|
2454
|
|
2456
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2457
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
|
2458
|
|
- #endif
|
|
2455
|
+ SYNC_PLAN_POSITION_KINEMATIC();
|
2459
|
2456
|
|
2460
|
|
- destination[axis] = current_position[axis];
|
2461
|
|
- endstops.hit_on_purpose(); // clear endstop hit flags
|
2462
|
|
- axis_known_position[axis] = true;
|
2463
|
|
- axis_homed[axis] = true;
|
|
2457
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2458
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
|
|
2459
|
+ #endif
|
2464
|
2460
|
|
2465
|
|
- // Put away the Z probe
|
2466
|
|
- #if HAS_BED_PROBE
|
2467
|
|
- if (axis == Z_AXIS && axis_home_dir < 0) {
|
2468
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2469
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
2470
|
|
- #endif
|
2471
|
|
- if (STOW_PROBE()) return;
|
2472
|
|
- }
|
2473
|
|
- #endif
|
|
2461
|
+ destination[axis] = current_position[axis];
|
|
2462
|
+ endstops.hit_on_purpose(); // clear endstop hit flags
|
|
2463
|
+ axis_known_position[axis] = true;
|
|
2464
|
+ axis_homed[axis] = true;
|
2474
|
2465
|
|
2475
|
|
- }
|
|
2466
|
+ // Put away the Z probe
|
|
2467
|
+ #if HAS_BED_PROBE
|
|
2468
|
+ if (axis == Z_AXIS && axis_home_dir < 0) {
|
|
2469
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2470
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> ");
|
|
2471
|
+ #endif
|
|
2472
|
+ if (STOW_PROBE()) return;
|
|
2473
|
+ }
|
|
2474
|
+ #endif
|
2476
|
2475
|
|
2477
|
2476
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2478
|
2477
|
if (DEBUGGING(LEVELING)) {
|