|
@@ -149,13 +149,13 @@ float cartes[XYZ];
|
149
|
149
|
#endif
|
150
|
150
|
|
151
|
151
|
#if HAS_SOFTWARE_ENDSTOPS
|
152
|
|
- float soft_endstop_radius, soft_endstop_radius_2;
|
|
152
|
+ float delta_max_radius, delta_max_radius_2;
|
153
|
153
|
#elif IS_SCARA
|
154
|
|
- constexpr float soft_endstop_radius = SCARA_PRINTABLE_RADIUS,
|
155
|
|
- soft_endstop_radius_2 = sq(SCARA_PRINTABLE_RADIUS);
|
|
154
|
+ constexpr float delta_max_radius = SCARA_PRINTABLE_RADIUS,
|
|
155
|
+ delta_max_radius_2 = sq(SCARA_PRINTABLE_RADIUS);
|
156
|
156
|
#else // DELTA
|
157
|
|
- constexpr float soft_endstop_radius = DELTA_PRINTABLE_RADIUS,
|
158
|
|
- soft_endstop_radius_2 = sq(DELTA_PRINTABLE_RADIUS);
|
|
157
|
+ constexpr float delta_max_radius = DELTA_PRINTABLE_RADIUS,
|
|
158
|
+ delta_max_radius_2 = sq(DELTA_PRINTABLE_RADIUS);
|
159
|
159
|
#endif
|
160
|
160
|
|
161
|
161
|
#endif
|
|
@@ -460,8 +460,7 @@ void clean_up_after_endstop_or_probe_move() {
|
460
|
460
|
bool soft_endstops_enabled = true;
|
461
|
461
|
|
462
|
462
|
// Software Endstops are based on the configured limits.
|
463
|
|
- float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
|
464
|
|
- soft_endstop_max[XYZ] = { X_MAX_BED, Y_MAX_BED, Z_MAX_POS };
|
|
463
|
+ axis_limits_t soft_endstop[XYZ] = { { X_MIN_BED, X_MAX_BED }, { Y_MIN_BED, Y_MAX_BED }, { Z_MIN_POS, Z_MAX_POS } };
|
465
|
464
|
|
466
|
465
|
/**
|
467
|
466
|
* Software endstops can be used to monitor the open end of
|
|
@@ -487,26 +486,27 @@ void clean_up_after_endstop_or_probe_move() {
|
487
|
486
|
|
488
|
487
|
if (new_tool_index != 0) {
|
489
|
488
|
// T1 can move from X2_MIN_POS to X2_MAX_POS or X2 home position (whichever is larger)
|
490
|
|
- soft_endstop_min[X_AXIS] = X2_MIN_POS;
|
491
|
|
- soft_endstop_max[X_AXIS] = dual_max_x;
|
|
489
|
+ soft_endstop[X_AXIS].min = X2_MIN_POS;
|
|
490
|
+ soft_endstop[X_AXIS].max = dual_max_x;
|
492
|
491
|
}
|
493
|
492
|
else if (dxc_is_duplicating()) {
|
494
|
493
|
// In Duplication Mode, T0 can move as far left as X1_MIN_POS
|
495
|
494
|
// but not so far to the right that T1 would move past the end
|
496
|
|
- soft_endstop_min[X_AXIS] = X1_MIN_POS;
|
497
|
|
- soft_endstop_max[X_AXIS] = MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset);
|
|
495
|
+ soft_endstop[X_AXIS].min = X1_MIN_POS;
|
|
496
|
+ soft_endstop[X_AXIS].max = MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset);
|
498
|
497
|
}
|
499
|
498
|
else {
|
500
|
499
|
// In other modes, T0 can move from X1_MIN_POS to X1_MAX_POS
|
501
|
|
- soft_endstop_min[X_AXIS] = X1_MIN_POS;
|
502
|
|
- soft_endstop_max[X_AXIS] = X1_MAX_POS;
|
|
500
|
+ soft_endstop[X_AXIS].min = X1_MIN_POS;
|
|
501
|
+ soft_endstop[X_AXIS].max = X1_MAX_POS;
|
503
|
502
|
}
|
|
503
|
+
|
504
|
504
|
}
|
505
|
505
|
|
506
|
506
|
#elif ENABLED(DELTA)
|
507
|
507
|
|
508
|
|
- soft_endstop_min[axis] = base_min_pos(axis);
|
509
|
|
- soft_endstop_max[axis] = (axis == Z_AXIS ? delta_height
|
|
508
|
+ soft_endstop[axis].min = base_min_pos(axis);
|
|
509
|
+ soft_endstop[axis].max = (axis == Z_AXIS ? delta_height
|
510
|
510
|
#if HAS_BED_PROBE
|
511
|
511
|
- zprobe_zoffset
|
512
|
512
|
#endif
|
|
@@ -516,11 +516,11 @@ void clean_up_after_endstop_or_probe_move() {
|
516
|
516
|
case X_AXIS:
|
517
|
517
|
case Y_AXIS:
|
518
|
518
|
// Get a minimum radius for clamping
|
519
|
|
- soft_endstop_radius = MIN(ABS(MAX(soft_endstop_min[X_AXIS], soft_endstop_min[Y_AXIS])), soft_endstop_max[X_AXIS], soft_endstop_max[Y_AXIS]);
|
520
|
|
- soft_endstop_radius_2 = sq(soft_endstop_radius);
|
|
519
|
+ delta_max_radius = MIN(ABS(MAX(soft_endstop[X_AXIS].min, soft_endstop[Y_AXIS].min)), soft_endstop[X_AXIS].max, soft_endstop[Y_AXIS].max);
|
|
520
|
+ delta_max_radius_2 = sq(delta_max_radius);
|
521
|
521
|
break;
|
522
|
522
|
case Z_AXIS:
|
523
|
|
- delta_clip_start_height = soft_endstop_max[axis] - delta_safe_distance_from_top();
|
|
523
|
+ delta_clip_start_height = soft_endstop[axis].max - delta_safe_distance_from_top();
|
524
|
524
|
default: break;
|
525
|
525
|
}
|
526
|
526
|
|
|
@@ -531,84 +531,81 @@ void clean_up_after_endstop_or_probe_move() {
|
531
|
531
|
// retain the same physical limit when other tools are selected.
|
532
|
532
|
if (old_tool_index != new_tool_index) {
|
533
|
533
|
const float offs = hotend_offset[axis][new_tool_index] - hotend_offset[axis][old_tool_index];
|
534
|
|
- soft_endstop_min[axis] += offs;
|
535
|
|
- soft_endstop_max[axis] += offs;
|
|
534
|
+ soft_endstop[axis].min += offs;
|
|
535
|
+ soft_endstop[axis].max += offs;
|
536
|
536
|
}
|
537
|
537
|
else {
|
538
|
538
|
const float offs = hotend_offset[axis][active_extruder];
|
539
|
|
- soft_endstop_min[axis] = base_min_pos(axis) + offs;
|
540
|
|
- soft_endstop_max[axis] = base_max_pos(axis) + offs;
|
|
539
|
+ soft_endstop[axis].min = base_min_pos(axis) + offs;
|
|
540
|
+ soft_endstop[axis].max = base_max_pos(axis) + offs;
|
541
|
541
|
}
|
542
|
542
|
|
543
|
543
|
#else
|
544
|
544
|
|
545
|
|
- soft_endstop_min[axis] = base_min_pos(axis);
|
546
|
|
- soft_endstop_max[axis] = base_max_pos(axis);
|
|
545
|
+ soft_endstop[axis].min = base_min_pos(axis);
|
|
546
|
+ soft_endstop[axis].max = base_max_pos(axis);
|
547
|
547
|
|
548
|
548
|
#endif
|
549
|
549
|
|
550
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
551
|
|
- if (DEBUGGING(LEVELING)) {
|
552
|
|
- SERIAL_ECHOPAIR("For ", axis_codes[axis]);
|
553
|
|
- SERIAL_ECHOPAIR(" axis:\n soft_endstop_min = ", soft_endstop_min[axis]);
|
554
|
|
- SERIAL_ECHOLNPAIR("\n soft_endstop_max = ", soft_endstop_max[axis]);
|
555
|
|
- }
|
556
|
|
- #endif
|
557
|
|
- }
|
|
550
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
551
|
+ if (DEBUGGING(LEVELING))
|
|
552
|
+ SERIAL_ECHOLNPAIR("Axis ", axis_codes[axis], " min:", soft_endstop[axis].min, " max:", soft_endstop[axis].max);
|
|
553
|
+ #endif
|
|
554
|
+}
|
558
|
555
|
|
559
|
|
-#endif // HAS_SOFTWARE_ENDSTOPS
|
|
556
|
+ /**
|
|
557
|
+ * Constrain the given coordinates to the software endstops.
|
|
558
|
+ *
|
|
559
|
+ * For DELTA/SCARA the XY constraint is based on the smallest
|
|
560
|
+ * radius within the set software endstops.
|
|
561
|
+ */
|
|
562
|
+ void apply_motion_limits(float target[XYZ]) {
|
560
|
563
|
|
561
|
|
-/**
|
562
|
|
- * Constrain the given coordinates to the software endstops.
|
563
|
|
- *
|
564
|
|
- * For DELTA/SCARA the XY constraint is based on the smallest
|
565
|
|
- * radius within the set software endstops.
|
566
|
|
- */
|
567
|
|
-void clamp_to_software_endstops(float target[XYZ]) {
|
|
564
|
+ if (!soft_endstops_enabled) return;
|
568
|
565
|
|
569
|
|
- if (!soft_endstops_enabled) return;
|
|
566
|
+ #if IS_KINEMATIC
|
|
567
|
+
|
|
568
|
+ #if HAS_HOTEND_OFFSET && ENABLED(DELTA)
|
|
569
|
+ // The effector center position will be the target minus the hotend offset.
|
|
570
|
+ const float offx = hotend_offset[X_AXIS][active_extruder], offy = hotend_offset[Y_AXIS][active_extruder];
|
|
571
|
+ #else
|
|
572
|
+ // SCARA needs to consider the angle of the arm through the entire move, so for now use no tool offset.
|
|
573
|
+ constexpr float offx = 0, offy = 0;
|
|
574
|
+ #endif
|
570
|
575
|
|
571
|
|
- #if IS_KINEMATIC
|
|
576
|
+ const float dist_2 = HYPOT2(target[X_AXIS] - offx, target[Y_AXIS] - offy);
|
|
577
|
+ if (dist_2 > delta_max_radius_2) {
|
|
578
|
+ const float ratio = (delta_max_radius) / SQRT(dist_2); // 200 / 300 = 0.66
|
|
579
|
+ target[X_AXIS] *= ratio;
|
|
580
|
+ target[Y_AXIS] *= ratio;
|
|
581
|
+ }
|
572
|
582
|
|
573
|
|
- #if HAS_HOTEND_OFFSET && ENABLED(DELTA)
|
574
|
|
- // The effector center position will be the target minus the hotend offset.
|
575
|
|
- const float offx = hotend_offset[X_AXIS][active_extruder], offy = hotend_offset[Y_AXIS][active_extruder];
|
576
|
583
|
#else
|
577
|
|
- // SCARA needs to consider the angle of the arm through the entire move, so for now use no tool offset.
|
578
|
|
- constexpr float offx = 0, offy = 0;
|
579
|
|
- #endif
|
580
|
|
-
|
581
|
|
- const float dist_2 = HYPOT2(target[X_AXIS] - offx, target[Y_AXIS] - offy);
|
582
|
|
- if (dist_2 > soft_endstop_radius_2) {
|
583
|
|
- const float ratio = (soft_endstop_radius) / SQRT(dist_2); // 200 / 300 = 0.66
|
584
|
|
- target[X_AXIS] *= ratio;
|
585
|
|
- target[Y_AXIS] *= ratio;
|
586
|
|
- }
|
587
|
584
|
|
588
|
|
- #else
|
|
585
|
+ #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_X)
|
|
586
|
+ NOLESS(target[X_AXIS], soft_endstop[X_AXIS].min);
|
|
587
|
+ #endif
|
|
588
|
+ #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_X)
|
|
589
|
+ NOMORE(target[X_AXIS], soft_endstop[X_AXIS].max);
|
|
590
|
+ #endif
|
|
591
|
+ #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
|
|
592
|
+ NOLESS(target[Y_AXIS], soft_endstop[Y_AXIS].min);
|
|
593
|
+ #endif
|
|
594
|
+ #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
|
|
595
|
+ NOMORE(target[Y_AXIS], soft_endstop[Y_AXIS].max);
|
|
596
|
+ #endif
|
589
|
597
|
|
590
|
|
- #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_X)
|
591
|
|
- NOLESS(target[X_AXIS], soft_endstop_min[X_AXIS]);
|
592
|
598
|
#endif
|
593
|
|
- #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_X)
|
594
|
|
- NOMORE(target[X_AXIS], soft_endstop_max[X_AXIS]);
|
595
|
|
- #endif
|
596
|
|
- #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
|
597
|
|
- NOLESS(target[Y_AXIS], soft_endstop_min[Y_AXIS]);
|
|
599
|
+
|
|
600
|
+ #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
|
|
601
|
+ NOLESS(target[Z_AXIS], soft_endstop[Z_AXIS].min);
|
598
|
602
|
#endif
|
599
|
|
- #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
|
600
|
|
- NOMORE(target[Y_AXIS], soft_endstop_max[Y_AXIS]);
|
|
603
|
+ #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
|
|
604
|
+ NOMORE(target[Z_AXIS], soft_endstop[Z_AXIS].max);
|
601
|
605
|
#endif
|
|
606
|
+ }
|
602
|
607
|
|
603
|
|
- #endif
|
604
|
|
-
|
605
|
|
- #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
|
606
|
|
- NOLESS(target[Z_AXIS], soft_endstop_min[Z_AXIS]);
|
607
|
|
- #endif
|
608
|
|
- #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
|
609
|
|
- NOMORE(target[Z_AXIS], soft_endstop_max[Z_AXIS]);
|
610
|
|
- #endif
|
611
|
|
-}
|
|
608
|
+#endif // HAS_SOFTWARE_ENDSTOPS
|
612
|
609
|
|
613
|
610
|
#if !UBL_SEGMENTED
|
614
|
611
|
#if IS_KINEMATIC
|
|
@@ -995,7 +992,7 @@ void clamp_to_software_endstops(float target[XYZ]) {
|
995
|
992
|
* before calling or cold/lengthy extrusion may get missed.
|
996
|
993
|
*/
|
997
|
994
|
void prepare_move_to_destination() {
|
998
|
|
- clamp_to_software_endstops(destination);
|
|
995
|
+ apply_motion_limits(destination);
|
999
|
996
|
|
1000
|
997
|
#if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
1001
|
998
|
|