|
@@ -1713,27 +1713,37 @@ static void clean_up_after_endstop_or_probe_move() {
|
1713
|
1713
|
z_dest -= zprobe_zoffset;
|
1714
|
1714
|
|
1715
|
1715
|
if (z_dest > current_position[Z_AXIS]) {
|
1716
|
|
- float old_feedrate = feedrate;
|
1717
|
|
- feedrate = homing_feedrate[Z_AXIS];
|
1718
|
1716
|
do_blocking_move_to_z(z_dest);
|
1719
|
|
- feedrate = old_feedrate;
|
1720
|
1717
|
}
|
1721
|
1718
|
}
|
1722
|
1719
|
|
1723
|
1720
|
#endif //HAS_BED_PROBE
|
1724
|
1721
|
|
1725
|
1722
|
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE
|
1726
|
|
- static void axis_unhomed_error(bool xyz=false) {
|
1727
|
|
- if (xyz) {
|
1728
|
|
- LCD_MESSAGEPGM(MSG_XYZ_UNHOMED);
|
1729
|
|
- SERIAL_ECHO_START;
|
1730
|
|
- SERIAL_ECHOLNPGM(MSG_XYZ_UNHOMED);
|
1731
|
|
- }
|
1732
|
|
- else {
|
1733
|
|
- LCD_MESSAGEPGM(MSG_YX_UNHOMED);
|
|
1723
|
+ static bool axis_unhomed_error(const bool x, const bool y, const bool z) {
|
|
1724
|
+ const bool xx = x && !axis_homed[X_AXIS],
|
|
1725
|
+ yy = y && !axis_homed[Y_AXIS],
|
|
1726
|
+ zz = z && !axis_homed[Z_AXIS];
|
|
1727
|
+ if (xx || yy || zz) {
|
1734
|
1728
|
SERIAL_ECHO_START;
|
1735
|
|
- SERIAL_ECHOLNPGM(MSG_YX_UNHOMED);
|
|
1729
|
+ SERIAL_ECHOPGM(MSG_HOME " ");
|
|
1730
|
+ if (xx) SERIAL_ECHOPGM(MSG_X);
|
|
1731
|
+ if (yy) SERIAL_ECHOPGM(MSG_Y);
|
|
1732
|
+ if (zz) SERIAL_ECHOPGM(MSG_Z);
|
|
1733
|
+ SERIAL_ECHOLNPGM(" " MSG_FIRST);
|
|
1734
|
+
|
|
1735
|
+ #if ENABLED(ULTRA_LCD)
|
|
1736
|
+ char message[3 * (LCD_WIDTH) + 1] = ""; // worst case is kana.utf with up to 3*LCD_WIDTH+1
|
|
1737
|
+ strcat_P(message, PSTR(MSG_HOME " "));
|
|
1738
|
+ if (xx) strcat_P(message, PSTR(MSG_X));
|
|
1739
|
+ if (yy) strcat_P(message, PSTR(MSG_Y));
|
|
1740
|
+ if (zz) strcat_P(message, PSTR(MSG_Z));
|
|
1741
|
+ strcat_P(message, PSTR(" " MSG_FIRST));
|
|
1742
|
+ lcd_setstatus(message);
|
|
1743
|
+ #endif
|
|
1744
|
+ return true;
|
1736
|
1745
|
}
|
|
1746
|
+ return false;
|
1737
|
1747
|
}
|
1738
|
1748
|
#endif
|
1739
|
1749
|
|
|
@@ -1746,45 +1756,27 @@ static void clean_up_after_endstop_or_probe_move() {
|
1746
|
1756
|
/**
|
1747
|
1757
|
* Method to dock/undock a sled designed by Charles Bell.
|
1748
|
1758
|
*
|
1749
|
|
- * dock[in] If true, move to MAX_X and engage the electromagnet
|
1750
|
|
- * offset[in] The additional distance to move to adjust docking location
|
|
1759
|
+ * stow[in] If false, move to MAX_X and engage the solenoid
|
|
1760
|
+ * If true, move to MAX_X and release the solenoid
|
1751
|
1761
|
*/
|
1752
|
|
- static void dock_sled(bool dock, int offset = 0) {
|
|
1762
|
+ static void dock_sled(bool stow) {
|
1753
|
1763
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
1754
|
1764
|
if (DEBUGGING(LEVELING)) {
|
1755
|
|
- SERIAL_ECHOPAIR("dock_sled(", dock);
|
|
1765
|
+ SERIAL_ECHOPAIR("dock_sled(", stow);
|
1756
|
1766
|
SERIAL_ECHOLNPGM(")");
|
1757
|
1767
|
}
|
1758
|
1768
|
#endif
|
1759
|
1769
|
|
1760
|
|
- if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
|
1761
|
|
- axis_unhomed_error(true);
|
1762
|
|
- return;
|
1763
|
|
- }
|
1764
|
|
-
|
1765
|
|
- if (endstops.z_probe_enabled == !dock) return; // already docked/undocked?
|
|
1770
|
+ if (axis_unhomed_error(true, false, false)) return;
|
1766
|
1771
|
|
1767
|
1772
|
float oldXpos = current_position[X_AXIS]; // save x position
|
1768
|
|
- float old_feedrate = feedrate;
|
1769
|
|
- if (dock) {
|
1770
|
|
- #if _Z_RAISE_PROBE_DEPLOY_STOW > 0
|
1771
|
|
- do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
1772
|
|
- #endif
|
1773
|
|
- // Dock sled a bit closer to ensure proper capturing
|
1774
|
|
- feedrate = XY_PROBE_FEEDRATE;
|
1775
|
|
- do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
|
1776
|
|
- digitalWrite(SLED_PIN, LOW); // turn off magnet
|
1777
|
|
- }
|
1778
|
|
- else {
|
1779
|
|
- feedrate = XY_PROBE_FEEDRATE;
|
1780
|
|
- float z_loc = current_position[Z_AXIS];
|
1781
|
|
- if (z_loc < _Z_RAISE_PROBE_DEPLOY_STOW + 5) z_loc = _Z_RAISE_PROBE_DEPLOY_STOW;
|
1782
|
|
- do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
|
1783
|
|
- digitalWrite(SLED_PIN, HIGH); // turn on magnet
|
1784
|
|
- }
|
|
1773
|
+
|
|
1774
|
+ // Dock sled a bit closer to ensure proper capturing
|
|
1775
|
+ do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET - ((stow) ? 1 : 0));
|
|
1776
|
+ digitalWrite(SLED_PIN, !stow); // switch solenoid
|
|
1777
|
+
|
1785
|
1778
|
do_blocking_move_to_x(oldXpos); // return to position before docking
|
1786
|
1779
|
|
1787
|
|
- feedrate = old_feedrate;
|
1788
|
1780
|
}
|
1789
|
1781
|
|
1790
|
1782
|
#endif // Z_PROBE_SLED
|
|
@@ -1800,9 +1792,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
1800
|
1792
|
if (endstops.z_probe_enabled) return;
|
1801
|
1793
|
|
1802
|
1794
|
// Make room for probe
|
1803
|
|
- #if _Z_RAISE_PROBE_DEPLOY_STOW > 0
|
1804
|
|
- do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
1805
|
|
- #endif
|
|
1795
|
+ do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
1806
|
1796
|
|
1807
|
1797
|
#if ENABLED(Z_PROBE_SLED)
|
1808
|
1798
|
|
|
@@ -1904,9 +1894,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
1904
|
1894
|
if (!endstops.z_probe_enabled) return;
|
1905
|
1895
|
|
1906
|
1896
|
// Make more room for the servo
|
1907
|
|
- #if _Z_RAISE_PROBE_DEPLOY_STOW > 0
|
1908
|
|
- do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
1909
|
|
- #endif
|
|
1897
|
+ do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW);
|
1910
|
1898
|
|
1911
|
1899
|
#if ENABLED(Z_PROBE_SLED)
|
1912
|
1900
|
|
|
@@ -2844,28 +2832,33 @@ inline void gcode_G28() {
|
2844
|
2832
|
|
2845
|
2833
|
#elif defined(MIN_Z_HEIGHT_FOR_HOMING) && MIN_Z_HEIGHT_FOR_HOMING > 0
|
2846
|
2834
|
|
2847
|
|
- // Raise Z before homing any other axes and z is not already high enough (never lower z)
|
2848
|
|
- if (current_position[Z_AXIS] <= MIN_Z_HEIGHT_FOR_HOMING) {
|
2849
|
|
- destination[Z_AXIS] = MIN_Z_HEIGHT_FOR_HOMING;
|
2850
|
|
- feedrate = planner.max_feedrate[Z_AXIS] * 60; // feedrate (mm/m) = max_feedrate (mm/s)
|
2851
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2852
|
|
- if (DEBUGGING(LEVELING)) {
|
2853
|
|
- SERIAL_ECHOPAIR("Raise Z (before homing) to ", (MIN_Z_HEIGHT_FOR_HOMING));
|
2854
|
|
- SERIAL_EOL;
|
2855
|
|
- DEBUG_POS("> (home_all_axis || homeZ)", current_position);
|
2856
|
|
- DEBUG_POS("> (home_all_axis || homeZ)", destination);
|
2857
|
|
- }
|
2858
|
|
- #endif
|
2859
|
|
- line_to_destination();
|
2860
|
|
- stepper.synchronize();
|
|
2835
|
+ #if HAS_BED_PROBE
|
|
2836
|
+ do_probe_raise(MIN_Z_HEIGHT_FOR_HOMING);
|
|
2837
|
+ destination[Z_AXIS] = current_position[Z_AXIS];
|
|
2838
|
+ #else
|
|
2839
|
+ // Raise Z before homing any other axes and z is not already high enough (never lower z)
|
|
2840
|
+ if (current_position[Z_AXIS] <= MIN_Z_HEIGHT_FOR_HOMING) {
|
|
2841
|
+ destination[Z_AXIS] = MIN_Z_HEIGHT_FOR_HOMING;
|
|
2842
|
+ feedrate = planner.max_feedrate[Z_AXIS] * 60; // feedrate (mm/m) = max_feedrate (mm/s)
|
|
2843
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2844
|
+ if (DEBUGGING(LEVELING)) {
|
|
2845
|
+ SERIAL_ECHOPAIR("Raise Z (before homing) to ", (MIN_Z_HEIGHT_FOR_HOMING));
|
|
2846
|
+ SERIAL_EOL;
|
|
2847
|
+ DEBUG_POS("> (home_all_axis || homeZ)", current_position);
|
|
2848
|
+ DEBUG_POS("> (home_all_axis || homeZ)", destination);
|
|
2849
|
+ }
|
|
2850
|
+ #endif
|
|
2851
|
+ line_to_destination();
|
|
2852
|
+ stepper.synchronize();
|
2861
|
2853
|
|
2862
|
|
- /**
|
2863
|
|
- * Update the current Z position even if it currently not real from
|
2864
|
|
- * Z-home otherwise each call to line_to_destination() will want to
|
2865
|
|
- * move Z-axis by MIN_Z_HEIGHT_FOR_HOMING.
|
2866
|
|
- */
|
2867
|
|
- current_position[Z_AXIS] = destination[Z_AXIS];
|
2868
|
|
- }
|
|
2854
|
+ /**
|
|
2855
|
+ * Update the current Z position even if it currently not real from
|
|
2856
|
+ * Z-home otherwise each call to line_to_destination() will want to
|
|
2857
|
+ * move Z-axis by MIN_Z_HEIGHT_FOR_HOMING.
|
|
2858
|
+ */
|
|
2859
|
+ current_position[Z_AXIS] = destination[Z_AXIS];
|
|
2860
|
+ }
|
|
2861
|
+ #endif
|
2869
|
2862
|
#endif
|
2870
|
2863
|
|
2871
|
2864
|
#if ENABLED(QUICK_HOME)
|
|
@@ -2922,7 +2915,12 @@ inline void gcode_G28() {
|
2922
|
2915
|
|
2923
|
2916
|
#if ENABLED(HOME_Y_BEFORE_X)
|
2924
|
2917
|
// Home Y
|
2925
|
|
- if (home_all_axis || homeY) HOMEAXIS(Y);
|
|
2918
|
+ if (home_all_axis || homeY) {
|
|
2919
|
+ HOMEAXIS(Y);
|
|
2920
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2921
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS("> homeY", current_position);
|
|
2922
|
+ #endif
|
|
2923
|
+ }
|
2926
|
2924
|
#endif
|
2927
|
2925
|
|
2928
|
2926
|
// Home X
|
|
@@ -3015,32 +3013,27 @@ inline void gcode_G28() {
|
3015
|
3013
|
else if (homeZ) { // Don't need to Home Z twice
|
3016
|
3014
|
|
3017
|
3015
|
// Let's see if X and Y are homed
|
3018
|
|
- if (axis_homed[X_AXIS] && axis_homed[Y_AXIS]) {
|
3019
|
|
-
|
3020
|
|
- /**
|
3021
|
|
- * Make sure the Z probe is within the physical limits
|
3022
|
|
- * NOTE: This doesn't necessarily ensure the Z probe is also
|
3023
|
|
- * within the bed!
|
3024
|
|
- */
|
3025
|
|
- float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS];
|
3026
|
|
- if ( cpx >= X_MIN_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
|
3027
|
|
- && cpx <= X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
|
3028
|
|
- && cpy >= Y_MIN_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)
|
3029
|
|
- && cpy <= Y_MAX_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)) {
|
3030
|
|
-
|
3031
|
|
- // Home the Z axis
|
3032
|
|
- HOMEAXIS(Z);
|
3033
|
|
- }
|
3034
|
|
- else {
|
3035
|
|
- LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
|
3036
|
|
- SERIAL_ECHO_START;
|
3037
|
|
- SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT);
|
3038
|
|
- }
|
|
3016
|
+ if (axis_unhomed_error(true, true, false)) return;
|
|
3017
|
+
|
|
3018
|
+ /**
|
|
3019
|
+ * Make sure the Z probe is within the physical limits
|
|
3020
|
+ * NOTE: This doesn't necessarily ensure the Z probe is also
|
|
3021
|
+ * within the bed!
|
|
3022
|
+ */
|
|
3023
|
+ float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS];
|
|
3024
|
+ if ( cpx >= X_MIN_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
|
|
3025
|
+ && cpx <= X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
|
|
3026
|
+ && cpy >= Y_MIN_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)
|
|
3027
|
+ && cpy <= Y_MAX_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)) {
|
|
3028
|
+
|
|
3029
|
+ // Home the Z axis
|
|
3030
|
+ HOMEAXIS(Z);
|
3039
|
3031
|
}
|
3040
|
3032
|
else {
|
3041
|
|
- axis_unhomed_error();
|
|
3033
|
+ LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
|
|
3034
|
+ SERIAL_ECHO_START;
|
|
3035
|
+ SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT);
|
3042
|
3036
|
}
|
3043
|
|
-
|
3044
|
3037
|
} // !home_all_axes && homeZ
|
3045
|
3038
|
|
3046
|
3039
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -3381,10 +3374,7 @@ inline void gcode_G28() {
|
3381
|
3374
|
#endif
|
3382
|
3375
|
|
3383
|
3376
|
// Don't allow auto-leveling without homing first
|
3384
|
|
- if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
|
3385
|
|
- axis_unhomed_error(true);
|
3386
|
|
- return;
|
3387
|
|
- }
|
|
3377
|
+ if (axis_unhomed_error(true, true, true)) return;
|
3388
|
3378
|
|
3389
|
3379
|
int verbose_level = code_seen('V') ? code_value_int() : 1;
|
3390
|
3380
|
if (verbose_level < 0 || verbose_level > 4) {
|
|
@@ -3394,7 +3384,7 @@ inline void gcode_G28() {
|
3394
|
3384
|
|
3395
|
3385
|
bool dryrun = code_seen('D');
|
3396
|
3386
|
|
3397
|
|
- #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
|
|
3387
|
+ #if ENABLED(Z_PROBE_ALLEN_KEY)
|
3398
|
3388
|
const bool stow_probe_after_each = false;
|
3399
|
3389
|
#else
|
3400
|
3390
|
bool stow_probe_after_each = code_seen('E');
|
|
@@ -4136,10 +4126,7 @@ inline void gcode_M42() {
|
4136
|
4126
|
*/
|
4137
|
4127
|
inline void gcode_M48() {
|
4138
|
4128
|
|
4139
|
|
- if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
|
4140
|
|
- axis_unhomed_error(true);
|
4141
|
|
- return;
|
4142
|
|
- }
|
|
4129
|
+ if (axis_unhomed_error(true, true, true)) return;
|
4143
|
4130
|
|
4144
|
4131
|
int8_t verbose_level = code_seen('V') ? code_value_byte() : 1;
|
4145
|
4132
|
if (verbose_level < 0 || verbose_level > 4) {
|
|
@@ -4159,7 +4146,7 @@ inline void gcode_M42() {
|
4159
|
4146
|
float X_current = current_position[X_AXIS],
|
4160
|
4147
|
Y_current = current_position[Y_AXIS];
|
4161
|
4148
|
|
4162
|
|
- #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
|
|
4149
|
+ #if ENABLED(Z_PROBE_ALLEN_KEY)
|
4163
|
4150
|
const bool stow_probe_after_each = false;
|
4164
|
4151
|
#else
|
4165
|
4152
|
bool stow_probe_after_each = code_seen('E');
|