|
@@ -205,6 +205,7 @@
|
205
|
205
|
* M208 - Set Recover (unretract) Additional (!) Length: S<length> and Feedrate: F<units/min>
|
206
|
206
|
* M209 - Turn Automatic Retract Detection on/off: S<bool> (For slicers that don't support G10/11).
|
207
|
207
|
Every normal extrude-only move will be classified as retract depending on the direction.
|
|
208
|
+ * M211 - Enable, Disable, and/or Report software endstops: [S<bool>]
|
208
|
209
|
* M218 - Set a tool offset: T<index> X<offset> Y<offset>
|
209
|
210
|
* M220 - Set Feedrate Percentage: S<percent> ("FR" on your LCD)
|
210
|
211
|
* M221 - Set Flow Percentage: S<percent>
|
|
@@ -332,9 +333,12 @@ float position_shift[3] = { 0 };
|
332
|
333
|
// Set by M206, M428, or menu item. Saved to EEPROM.
|
333
|
334
|
float home_offset[3] = { 0 };
|
334
|
335
|
|
335
|
|
-// Software Endstops. Default to configured limits.
|
336
|
|
-float sw_endstop_min[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
|
337
|
|
-float sw_endstop_max[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
|
|
336
|
+// Software Endstops are based on the configured limits.
|
|
337
|
+#if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)
|
|
338
|
+ bool soft_endstops_enabled = true;
|
|
339
|
+#endif
|
|
340
|
+float soft_endstop_min[XYZ] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS },
|
|
341
|
+ soft_endstop_max[XYZ] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
|
338
|
342
|
|
339
|
343
|
#if FAN_COUNT > 0
|
340
|
344
|
int fanSpeeds[FAN_COUNT] = { 0 };
|
|
@@ -1477,21 +1481,21 @@ void update_software_endstops(AxisEnum axis) {
|
1477
|
1481
|
if (axis == X_AXIS) {
|
1478
|
1482
|
float dual_max_x = max(hotend_offset[X_AXIS][1], X2_MAX_POS);
|
1479
|
1483
|
if (active_extruder != 0) {
|
1480
|
|
- sw_endstop_min[X_AXIS] = X2_MIN_POS + offs;
|
1481
|
|
- sw_endstop_max[X_AXIS] = dual_max_x + offs;
|
|
1484
|
+ soft_endstop_min[X_AXIS] = X2_MIN_POS + offs;
|
|
1485
|
+ soft_endstop_max[X_AXIS] = dual_max_x + offs;
|
1482
|
1486
|
return;
|
1483
|
1487
|
}
|
1484
|
1488
|
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
|
1485
|
|
- sw_endstop_min[X_AXIS] = base_min_pos(X_AXIS) + offs;
|
1486
|
|
- sw_endstop_max[X_AXIS] = min(base_max_pos(X_AXIS), dual_max_x - duplicate_extruder_x_offset) + offs;
|
|
1489
|
+ soft_endstop_min[X_AXIS] = base_min_pos(X_AXIS) + offs;
|
|
1490
|
+ soft_endstop_max[X_AXIS] = min(base_max_pos(X_AXIS), dual_max_x - duplicate_extruder_x_offset) + offs;
|
1487
|
1491
|
return;
|
1488
|
1492
|
}
|
1489
|
1493
|
}
|
1490
|
1494
|
else
|
1491
|
1495
|
#endif
|
1492
|
1496
|
{
|
1493
|
|
- sw_endstop_min[axis] = base_min_pos(axis) + offs;
|
1494
|
|
- sw_endstop_max[axis] = base_max_pos(axis) + offs;
|
|
1497
|
+ soft_endstop_min[axis] = base_min_pos(axis) + offs;
|
|
1498
|
+ soft_endstop_max[axis] = base_max_pos(axis) + offs;
|
1495
|
1499
|
}
|
1496
|
1500
|
|
1497
|
1501
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -1499,16 +1503,15 @@ void update_software_endstops(AxisEnum axis) {
|
1499
|
1503
|
SERIAL_ECHOPAIR("For ", axis_codes[axis]);
|
1500
|
1504
|
SERIAL_ECHOPAIR(" axis:\n home_offset = ", home_offset[axis]);
|
1501
|
1505
|
SERIAL_ECHOPAIR("\n position_shift = ", position_shift[axis]);
|
1502
|
|
- SERIAL_ECHOPAIR("\n sw_endstop_min = ", sw_endstop_min[axis]);
|
1503
|
|
- SERIAL_ECHOPAIR("\n sw_endstop_max = ", sw_endstop_max[axis]);
|
|
1506
|
+ SERIAL_ECHOPAIR("\n soft_endstop_min = ", soft_endstop_min[axis]);
|
|
1507
|
+ SERIAL_ECHOPAIR("\n soft_endstop_max = ", soft_endstop_max[axis]);
|
1504
|
1508
|
SERIAL_EOL;
|
1505
|
1509
|
}
|
1506
|
1510
|
#endif
|
1507
|
1511
|
|
1508
|
1512
|
#if ENABLED(DELTA)
|
1509
|
|
- if (axis == Z_AXIS) {
|
1510
|
|
- delta_clip_start_height = sw_endstop_max[axis] - delta_safe_distance_from_top();
|
1511
|
|
- }
|
|
1513
|
+ if (axis == Z_AXIS)
|
|
1514
|
+ delta_clip_start_height = soft_endstop_max[axis] - delta_safe_distance_from_top();
|
1512
|
1515
|
#endif
|
1513
|
1516
|
|
1514
|
1517
|
}
|
|
@@ -1574,8 +1577,8 @@ static void set_axis_is_at_home(AxisEnum axis) {
|
1574
|
1577
|
* SCARA home positions are based on configuration since the actual
|
1575
|
1578
|
* limits are determined by the inverse kinematic transform.
|
1576
|
1579
|
*/
|
1577
|
|
- sw_endstop_min[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis));
|
1578
|
|
- sw_endstop_max[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis));
|
|
1580
|
+ soft_endstop_min[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis));
|
|
1581
|
+ soft_endstop_max[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis));
|
1579
|
1582
|
}
|
1580
|
1583
|
else
|
1581
|
1584
|
#endif
|
|
@@ -5572,6 +5575,33 @@ inline void gcode_M206() {
|
5572
|
5575
|
|
5573
|
5576
|
#endif // FWRETRACT
|
5574
|
5577
|
|
|
5578
|
+/**
|
|
5579
|
+ * M211: Enable, Disable, and/or Report software endstops
|
|
5580
|
+ *
|
|
5581
|
+ * Usage: M211 S1 to enable, M211 S0 to disable, M211 alone for report
|
|
5582
|
+ */
|
|
5583
|
+inline void gcode_M211() {
|
|
5584
|
+ SERIAL_ECHO_START;
|
|
5585
|
+ #if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)
|
|
5586
|
+ if (code_seen('S')) soft_endstops_enabled = code_value_bool();
|
|
5587
|
+ #endif
|
|
5588
|
+ #if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)
|
|
5589
|
+ SERIAL_ECHOPGM(MSG_SOFT_ENDSTOPS ": ");
|
|
5590
|
+ serialprintPGM(soft_endstops_enabled ? PSTR(MSG_ON) : PSTR(MSG_OFF));
|
|
5591
|
+ #else
|
|
5592
|
+ SERIAL_ECHOPGM(MSG_SOFT_ENDSTOPS ": " MSG_OFF);
|
|
5593
|
+ #endif
|
|
5594
|
+ SERIAL_ECHOPGM(" " MSG_SOFT_MIN ": ");
|
|
5595
|
+ SERIAL_ECHOPAIR( MSG_X, soft_endstop_min[X_AXIS]);
|
|
5596
|
+ SERIAL_ECHOPAIR(" " MSG_Y, soft_endstop_min[Y_AXIS]);
|
|
5597
|
+ SERIAL_ECHOPAIR(" " MSG_Z, soft_endstop_min[Z_AXIS]);
|
|
5598
|
+ SERIAL_ECHOPGM(" " MSG_SOFT_MAX ": ");
|
|
5599
|
+ SERIAL_ECHOPAIR( MSG_X, soft_endstop_max[X_AXIS]);
|
|
5600
|
+ SERIAL_ECHOPAIR(" " MSG_Y, soft_endstop_max[Y_AXIS]);
|
|
5601
|
+ SERIAL_ECHOPAIR(" " MSG_Z, soft_endstop_max[Z_AXIS]);
|
|
5602
|
+ SERIAL_EOL;
|
|
5603
|
+}
|
|
5604
|
+
|
5575
|
5605
|
#if HOTENDS > 1
|
5576
|
5606
|
|
5577
|
5607
|
/**
|
|
@@ -6175,7 +6205,7 @@ inline void gcode_M428() {
|
6175
|
6205
|
bool err = false;
|
6176
|
6206
|
LOOP_XYZ(i) {
|
6177
|
6207
|
if (axis_homed[i]) {
|
6178
|
|
- float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) * 0.5) ? base_home_pos(i) : 0,
|
|
6208
|
+ float base = (current_position[i] > (soft_endstop_min[i] + soft_endstop_max[i]) * 0.5) ? base_home_pos(i) : 0,
|
6179
|
6209
|
diff = current_position[i] - LOGICAL_POSITION(base, i);
|
6180
|
6210
|
if (diff > -20 && diff < 20) {
|
6181
|
6211
|
set_home_offset((AxisEnum)i, home_offset[i] - diff);
|
|
@@ -7495,6 +7525,10 @@ void process_next_command() {
|
7495
|
7525
|
break;
|
7496
|
7526
|
#endif // FWRETRACT
|
7497
|
7527
|
|
|
7528
|
+ case 211: // M211 - Enable, Disable, and/or Report software endstops
|
|
7529
|
+ gcode_M211();
|
|
7530
|
+ break;
|
|
7531
|
+
|
7498
|
7532
|
#if HOTENDS > 1
|
7499
|
7533
|
case 218: // M218 - Set a tool offset: T<index> X<offset> Y<offset>
|
7500
|
7534
|
gcode_M218();
|
|
@@ -7749,18 +7783,22 @@ void ok_to_send() {
|
7749
|
7783
|
SERIAL_EOL;
|
7750
|
7784
|
}
|
7751
|
7785
|
|
7752
|
|
-void clamp_to_software_endstops(float target[3]) {
|
7753
|
|
- if (min_software_endstops) {
|
7754
|
|
- NOLESS(target[X_AXIS], sw_endstop_min[X_AXIS]);
|
7755
|
|
- NOLESS(target[Y_AXIS], sw_endstop_min[Y_AXIS]);
|
7756
|
|
- NOLESS(target[Z_AXIS], sw_endstop_min[Z_AXIS]);
|
7757
|
|
- }
|
7758
|
|
- if (max_software_endstops) {
|
7759
|
|
- NOMORE(target[X_AXIS], sw_endstop_max[X_AXIS]);
|
7760
|
|
- NOMORE(target[Y_AXIS], sw_endstop_max[Y_AXIS]);
|
7761
|
|
- NOMORE(target[Z_AXIS], sw_endstop_max[Z_AXIS]);
|
|
7786
|
+#if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)
|
|
7787
|
+
|
|
7788
|
+ void clamp_to_software_endstops(float target[XYZ]) {
|
|
7789
|
+ #if ENABLED(min_software_endstops)
|
|
7790
|
+ NOLESS(target[X_AXIS], soft_endstop_min[X_AXIS]);
|
|
7791
|
+ NOLESS(target[Y_AXIS], soft_endstop_min[Y_AXIS]);
|
|
7792
|
+ NOLESS(target[Z_AXIS], soft_endstop_min[Z_AXIS]);
|
|
7793
|
+ #endif
|
|
7794
|
+ #if ENABLED(max_software_endstops)
|
|
7795
|
+ NOMORE(target[X_AXIS], soft_endstop_max[X_AXIS]);
|
|
7796
|
+ NOMORE(target[Y_AXIS], soft_endstop_max[Y_AXIS]);
|
|
7797
|
+ NOMORE(target[Z_AXIS], soft_endstop_max[Z_AXIS]);
|
|
7798
|
+ #endif
|
7762
|
7799
|
}
|
7763
|
|
-}
|
|
7800
|
+
|
|
7801
|
+#endif
|
7764
|
7802
|
|
7765
|
7803
|
#if ENABLED(DELTA)
|
7766
|
7804
|
|