|
@@ -129,29 +129,30 @@ const float homing_feedrate_mm_s[4] PROGMEM = {
|
129
|
129
|
// Cartesian conversion result goes here:
|
130
|
130
|
float cartes[XYZ];
|
131
|
131
|
|
132
|
|
-// Until kinematics.cpp is created, create this here
|
133
|
132
|
#if IS_KINEMATIC
|
134
|
133
|
float delta[ABC];
|
135
|
134
|
#endif
|
136
|
135
|
|
|
136
|
+#if HAS_SCARA_OFFSET
|
|
137
|
+ float scara_home_offset[ABC];
|
|
138
|
+#endif
|
|
139
|
+
|
137
|
140
|
/**
|
138
|
141
|
* The workspace can be offset by some commands, or
|
139
|
142
|
* these offsets may be omitted to save on computation.
|
140
|
143
|
*/
|
141
|
|
-#if HAS_WORKSPACE_OFFSET
|
142
|
|
- #if HAS_POSITION_SHIFT
|
143
|
|
- // The distance that XYZ has been offset by G92. Reset by G28.
|
144
|
|
- float position_shift[XYZ] = { 0 };
|
145
|
|
- #endif
|
146
|
|
- #if HAS_HOME_OFFSET
|
147
|
|
- // This offset is added to the configured home position.
|
148
|
|
- // Set by M206, M428, or menu item. Saved to EEPROM.
|
149
|
|
- float home_offset[XYZ] = { 0 };
|
150
|
|
- #endif
|
151
|
|
- #if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
|
152
|
|
- // The above two are combined to save on computes
|
153
|
|
- float workspace_offset[XYZ] = { 0 };
|
154
|
|
- #endif
|
|
144
|
+#if HAS_POSITION_SHIFT
|
|
145
|
+ // The distance that XYZ has been offset by G92. Reset by G28.
|
|
146
|
+ float position_shift[XYZ] = { 0 };
|
|
147
|
+#endif
|
|
148
|
+#if HAS_HOME_OFFSET
|
|
149
|
+ // This offset is added to the configured home position.
|
|
150
|
+ // Set by M206, M428, or menu item. Saved to EEPROM.
|
|
151
|
+ float home_offset[XYZ] = { 0 };
|
|
152
|
+#endif
|
|
153
|
+#if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
|
|
154
|
+ // The above two are combined to save on computes
|
|
155
|
+ float workspace_offset[XYZ] = { 0 };
|
155
|
156
|
#endif
|
156
|
157
|
|
157
|
158
|
#if OLDSCHOOL_ABL
|
|
@@ -454,15 +455,14 @@ void bracket_probe_move(const bool before) {
|
454
|
455
|
void setup_for_endstop_or_probe_move() { bracket_probe_move(true); }
|
455
|
456
|
void clean_up_after_endstop_or_probe_move() { bracket_probe_move(false); }
|
456
|
457
|
|
457
|
|
-// Software Endstops are based on the configured limits.
|
458
|
|
-float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
|
459
|
|
- soft_endstop_max[XYZ] = { X_MAX_BED, Y_MAX_BED, Z_MAX_POS };
|
460
|
|
-
|
461
|
458
|
#if HAS_SOFTWARE_ENDSTOPS
|
462
|
459
|
|
463
|
|
- // Software Endstops are based on the configured limits.
|
464
|
460
|
bool soft_endstops_enabled = true;
|
465
|
461
|
|
|
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 };
|
|
465
|
+
|
466
|
466
|
#if IS_KINEMATIC
|
467
|
467
|
float soft_endstop_radius, soft_endstop_radius_2;
|
468
|
468
|
#endif
|
|
@@ -504,6 +504,79 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
|
504
|
504
|
#endif
|
505
|
505
|
}
|
506
|
506
|
|
|
507
|
+ /**
|
|
508
|
+ * Software endstops can be used to monitor the open end of
|
|
509
|
+ * an axis that has a hardware endstop on the other end. Or
|
|
510
|
+ * they can prevent axes from moving past endstops and grinding.
|
|
511
|
+ *
|
|
512
|
+ * To keep doing their job as the coordinate system changes,
|
|
513
|
+ * the software endstop positions must be refreshed to remain
|
|
514
|
+ * at the same positions relative to the machine.
|
|
515
|
+ */
|
|
516
|
+ void update_software_endstops(const AxisEnum axis) {
|
|
517
|
+
|
|
518
|
+ #if ENABLED(DUAL_X_CARRIAGE)
|
|
519
|
+
|
|
520
|
+ if (axis == X_AXIS) {
|
|
521
|
+
|
|
522
|
+ // In Dual X mode hotend_offset[X] is T1's home position
|
|
523
|
+ const float dual_max_x = MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
|
|
524
|
+
|
|
525
|
+ if (active_extruder != 0) {
|
|
526
|
+ // T1 can move from X2_MIN_POS to X2_MAX_POS or X2 home position (whichever is larger)
|
|
527
|
+ soft_endstop_min[X_AXIS] = X2_MIN_POS;
|
|
528
|
+ soft_endstop_max[X_AXIS] = dual_max_x;
|
|
529
|
+ }
|
|
530
|
+ else if (dxc_is_duplicating()) {
|
|
531
|
+ // In Duplication Mode, T0 can move as far left as X1_MIN_POS
|
|
532
|
+ // but not so far to the right that T1 would move past the end
|
|
533
|
+ soft_endstop_min[X_AXIS] = X1_MIN_POS;
|
|
534
|
+ soft_endstop_max[X_AXIS] = MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset);
|
|
535
|
+ }
|
|
536
|
+ else {
|
|
537
|
+ // In other modes, T0 can move from X1_MIN_POS to X1_MAX_POS
|
|
538
|
+ soft_endstop_min[X_AXIS] = X1_MIN_POS;
|
|
539
|
+ soft_endstop_max[X_AXIS] = X1_MAX_POS;
|
|
540
|
+ }
|
|
541
|
+ }
|
|
542
|
+
|
|
543
|
+ #elif ENABLED(DELTA)
|
|
544
|
+
|
|
545
|
+ soft_endstop_min[axis] = base_min_pos(axis);
|
|
546
|
+ soft_endstop_max[axis] = (axis == Z_AXIS ? delta_height
|
|
547
|
+ #if HAS_BED_PROBE
|
|
548
|
+ - zprobe_zoffset + Z_PROBE_OFFSET_FROM_EXTRUDER
|
|
549
|
+ #endif
|
|
550
|
+ : base_max_pos(axis));
|
|
551
|
+
|
|
552
|
+ switch (axis) {
|
|
553
|
+ case X_AXIS:
|
|
554
|
+ case Y_AXIS:
|
|
555
|
+ // Get a minimum radius for clamping
|
|
556
|
+ 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]);
|
|
557
|
+ soft_endstop_radius_2 = sq(soft_endstop_radius);
|
|
558
|
+ break;
|
|
559
|
+ case Z_AXIS:
|
|
560
|
+ delta_clip_start_height = soft_endstop_max[axis] - delta_safe_distance_from_top();
|
|
561
|
+ default: break;
|
|
562
|
+ }
|
|
563
|
+
|
|
564
|
+ #else
|
|
565
|
+
|
|
566
|
+ soft_endstop_min[axis] = base_min_pos(axis);
|
|
567
|
+ soft_endstop_max[axis] = base_max_pos(axis);
|
|
568
|
+
|
|
569
|
+ #endif
|
|
570
|
+
|
|
571
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
572
|
+ if (DEBUGGING(LEVELING)) {
|
|
573
|
+ SERIAL_ECHOPAIR("For ", axis_codes[axis]);
|
|
574
|
+ SERIAL_ECHOPAIR(" axis:\n soft_endstop_min = ", soft_endstop_min[axis]);
|
|
575
|
+ SERIAL_ECHOLNPAIR("\n soft_endstop_max = ", soft_endstop_max[axis]);
|
|
576
|
+ }
|
|
577
|
+ #endif
|
|
578
|
+ }
|
|
579
|
+
|
507
|
580
|
#endif
|
508
|
581
|
|
509
|
582
|
#if !UBL_SEGMENTED
|
|
@@ -1156,7 +1229,7 @@ void set_axis_is_at_home(const AxisEnum axis) {
|
1156
|
1229
|
|
1157
|
1230
|
#if HAS_POSITION_SHIFT
|
1158
|
1231
|
position_shift[axis] = 0;
|
1159
|
|
- update_software_endstops(axis);
|
|
1232
|
+ update_workspace_offset(axis);
|
1160
|
1233
|
#endif
|
1161
|
1234
|
|
1162
|
1235
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
@@ -1506,89 +1579,18 @@ void homeaxis(const AxisEnum axis) {
|
1506
|
1579
|
#endif
|
1507
|
1580
|
} // homeaxis()
|
1508
|
1581
|
|
1509
|
|
-#if HAS_WORKSPACE_OFFSET || ENABLED(DUAL_X_CARRIAGE) || ENABLED(DELTA)
|
1510
|
|
-
|
1511
|
|
- /**
|
1512
|
|
- * Software endstops can be used to monitor the open end of
|
1513
|
|
- * an axis that has a hardware endstop on the other end. Or
|
1514
|
|
- * they can prevent axes from moving past endstops and grinding.
|
1515
|
|
- *
|
1516
|
|
- * To keep doing their job as the coordinate system changes,
|
1517
|
|
- * the software endstop positions must be refreshed to remain
|
1518
|
|
- * at the same positions relative to the machine.
|
1519
|
|
- */
|
1520
|
|
- void update_software_endstops(const AxisEnum axis) {
|
1521
|
|
- #if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
|
1522
|
|
- workspace_offset[axis] = home_offset[axis] + position_shift[axis];
|
1523
|
|
- #endif
|
1524
|
|
-
|
1525
|
|
- #if ENABLED(DUAL_X_CARRIAGE)
|
1526
|
|
- if (axis == X_AXIS) {
|
1527
|
|
-
|
1528
|
|
- // In Dual X mode hotend_offset[X] is T1's home position
|
1529
|
|
- const float dual_max_x = MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
|
1530
|
|
-
|
1531
|
|
- if (active_extruder != 0) {
|
1532
|
|
- // T1 can move from X2_MIN_POS to X2_MAX_POS or X2 home position (whichever is larger)
|
1533
|
|
- soft_endstop_min[X_AXIS] = X2_MIN_POS;
|
1534
|
|
- soft_endstop_max[X_AXIS] = dual_max_x;
|
1535
|
|
- }
|
1536
|
|
- else if (dxc_is_duplicating()) {
|
1537
|
|
- // In Duplication Mode, T0 can move as far left as X1_MIN_POS
|
1538
|
|
- // but not so far to the right that T1 would move past the end
|
1539
|
|
- soft_endstop_min[X_AXIS] = X1_MIN_POS;
|
1540
|
|
- soft_endstop_max[X_AXIS] = MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset);
|
1541
|
|
- }
|
1542
|
|
- else {
|
1543
|
|
- // In other modes, T0 can move from X1_MIN_POS to X1_MAX_POS
|
1544
|
|
- soft_endstop_min[X_AXIS] = X1_MIN_POS;
|
1545
|
|
- soft_endstop_max[X_AXIS] = X1_MAX_POS;
|
1546
|
|
- }
|
1547
|
|
- }
|
1548
|
|
- #elif ENABLED(DELTA)
|
1549
|
|
- soft_endstop_min[axis] = base_min_pos(axis);
|
1550
|
|
- soft_endstop_max[axis] = (axis == Z_AXIS ? delta_height
|
1551
|
|
- #if HAS_BED_PROBE
|
1552
|
|
- - zprobe_zoffset + Z_PROBE_OFFSET_FROM_EXTRUDER
|
1553
|
|
- #endif
|
1554
|
|
- : base_max_pos(axis));
|
1555
|
|
- #else
|
1556
|
|
- soft_endstop_min[axis] = base_min_pos(axis);
|
1557
|
|
- soft_endstop_max[axis] = base_max_pos(axis);
|
1558
|
|
- #endif
|
1559
|
|
-
|
|
1582
|
+#if HAS_WORKSPACE_OFFSET
|
|
1583
|
+ void update_workspace_offset(const AxisEnum axis) {
|
|
1584
|
+ workspace_offset[axis] = home_offset[axis] + position_shift[axis];
|
1560
|
1585
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
1561
|
1586
|
if (DEBUGGING(LEVELING)) {
|
1562
|
1587
|
SERIAL_ECHOPAIR("For ", axis_codes[axis]);
|
1563
|
|
- #if HAS_HOME_OFFSET
|
1564
|
|
- SERIAL_ECHOPAIR(" axis:\n home_offset = ", home_offset[axis]);
|
1565
|
|
- #endif
|
1566
|
|
- #if HAS_POSITION_SHIFT
|
1567
|
|
- SERIAL_ECHOPAIR("\n position_shift = ", position_shift[axis]);
|
1568
|
|
- #endif
|
1569
|
|
- SERIAL_ECHOPAIR("\n soft_endstop_min = ", soft_endstop_min[axis]);
|
1570
|
|
- SERIAL_ECHOLNPAIR("\n soft_endstop_max = ", soft_endstop_max[axis]);
|
1571
|
|
- }
|
1572
|
|
- #endif
|
1573
|
|
-
|
1574
|
|
- #if ENABLED(DELTA)
|
1575
|
|
- switch (axis) {
|
1576
|
|
- #if HAS_SOFTWARE_ENDSTOPS
|
1577
|
|
- case X_AXIS:
|
1578
|
|
- case Y_AXIS:
|
1579
|
|
- // Get a minimum radius for clamping
|
1580
|
|
- 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]);
|
1581
|
|
- soft_endstop_radius_2 = sq(soft_endstop_radius);
|
1582
|
|
- break;
|
1583
|
|
- #endif
|
1584
|
|
- case Z_AXIS:
|
1585
|
|
- delta_clip_start_height = soft_endstop_max[axis] - delta_safe_distance_from_top();
|
1586
|
|
- default: break;
|
|
1588
|
+ SERIAL_ECHOPAIR(" axis:\n home_offset = ", home_offset[axis]);
|
|
1589
|
+ SERIAL_ECHOLNPAIR("\n position_shift = ", position_shift[axis]);
|
1587
|
1590
|
}
|
1588
|
1591
|
#endif
|
1589
|
1592
|
}
|
1590
|
|
-
|
1591
|
|
-#endif // HAS_WORKSPACE_OFFSET || DUAL_X_CARRIAGE || DELTA
|
|
1593
|
+#endif
|
1592
|
1594
|
|
1593
|
1595
|
#if HAS_M206_COMMAND
|
1594
|
1596
|
/**
|
|
@@ -1597,6 +1599,6 @@ void homeaxis(const AxisEnum axis) {
|
1597
|
1599
|
*/
|
1598
|
1600
|
void set_home_offset(const AxisEnum axis, const float v) {
|
1599
|
1601
|
home_offset[axis] = v;
|
1600
|
|
- update_software_endstops(axis);
|
|
1602
|
+ update_workspace_offset(axis);
|
1601
|
1603
|
}
|
1602
|
1604
|
#endif // HAS_M206_COMMAND
|