瀏覽代碼

Mark axes not-homed with HOME_AFTER_DEACTIVATE (#18907)

swissnorp 3 年之前
父節點
當前提交
a12ac5e175
沒有連結到貢獻者的電子郵件帳戶。

+ 3
- 2
Marlin/src/feature/babystep.cpp 查看文件

@@ -26,7 +26,8 @@
26 26
 
27 27
 #include "babystep.h"
28 28
 #include "../MarlinCore.h"
29
-#include "../module/planner.h"
29
+#include "../module/motion.h"   // for axes_should_home()
30
+#include "../module/planner.h"  // for axis_steps_per_mm[]
30 31
 #include "../module/stepper.h"
31 32
 
32 33
 #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
@@ -54,7 +55,7 @@ void Babystep::add_mm(const AxisEnum axis, const float &mm) {
54 55
 }
55 56
 
56 57
 void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
57
-  if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return;
58
+  if (DISABLED(BABYSTEP_WITHOUT_HOMING) && axes_should_home(_BV(axis))) return;
58 59
 
59 60
   accum += distance; // Count up babysteps for the UI
60 61
   steps[BS_AXIS_IND(axis)] += distance;

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp 查看文件

@@ -321,7 +321,7 @@
321 321
     // Check for commands that require the printer to be homed
322 322
     if (may_move) {
323 323
       planner.synchronize();
324
-      if (axes_need_homing()) gcode.home_all_axes();
324
+      if (axes_should_home()) gcode.home_all_axes();
325 325
       TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
326 326
     }
327 327
 

+ 1
- 1
Marlin/src/feature/pause.cpp 查看文件

@@ -413,7 +413,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
413 413
     unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
414 414
 
415 415
   // Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos)
416
-  if (!axes_need_homing())
416
+  if (!axes_should_home())
417 417
     nozzle.park(0, park_point);
418 418
 
419 419
   #if ENABLED(DUAL_X_CARRIAGE)

+ 1
- 1
Marlin/src/gcode/bedlevel/G26.cpp 查看文件

@@ -490,7 +490,7 @@ void GcodeSuite::G26() {
490 490
 
491 491
   // Don't allow Mesh Validation without homing first,
492 492
   // or if the parameter parsing did not go OK, abort
493
-  if (axis_unhomed_error()) return;
493
+  if (homing_needed_error()) return;
494 494
 
495 495
   // Change the tool first, if specified
496 496
   if (parser.seenval('T')) tool_change(parser.value_int());

+ 1
- 1
Marlin/src/gcode/bedlevel/abl/G29.cpp 查看文件

@@ -183,7 +183,7 @@ G29_TYPE GcodeSuite::G29() {
183 183
               faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
184 184
 
185 185
   // Don't allow auto-leveling without homing first
186
-  if (axis_unhomed_error()) G29_RETURN(false);
186
+  if (homing_needed_error()) G29_RETURN(false);
187 187
 
188 188
   if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
189 189
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip");

+ 3
- 3
Marlin/src/gcode/calibrate/G28.cpp 查看文件

@@ -118,7 +118,7 @@
118 118
     DEBUG_SECTION(log_G28, "home_z_safely", DEBUGGING(LEVELING));
119 119
 
120 120
     // Disallow Z homing if X or Y homing is needed
121
-    if (axis_unhomed_error(_BV(X_AXIS) | _BV(Y_AXIS))) return;
121
+    if (homing_needed_error(_BV(X_AXIS) | _BV(Y_AXIS))) return;
122 122
 
123 123
     sync_plan_position();
124 124
 
@@ -299,8 +299,8 @@ void GcodeSuite::G28() {
299 299
   #else // NOT DELTA
300 300
 
301 301
     const bool homeZ = parser.seen('Z'),
302
-               needX = homeZ && TERN0(Z_SAFE_HOMING, axes_need_homing(_BV(X_AXIS))),
303
-               needY = homeZ && TERN0(Z_SAFE_HOMING, axes_need_homing(_BV(Y_AXIS))),
302
+               needX = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(X_AXIS))),
303
+               needY = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(Y_AXIS))),
304 304
                homeX = needX || parser.seen('X'), homeY = needY || parser.seen('Y'),
305 305
                home_all = homeX == homeY && homeX == homeZ, // All or None
306 306
                doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ;

+ 1
- 1
Marlin/src/gcode/calibrate/G425.cpp 查看文件

@@ -584,7 +584,7 @@ void GcodeSuite::G425() {
584 584
   TEMPORARY_SOFT_ENDSTOP_STATE(false);
585 585
   TEMPORARY_BED_LEVELING_STATE(false);
586 586
 
587
-  if (axis_unhomed_error()) return;
587
+  if (homing_needed_error()) return;
588 588
 
589 589
   measurements_t m;
590 590
 

+ 1
- 1
Marlin/src/gcode/calibrate/M48.cpp 查看文件

@@ -55,7 +55,7 @@ extern const char SP_Y_STR[];
55 55
 
56 56
 void GcodeSuite::M48() {
57 57
 
58
-  if (axis_unhomed_error()) return;
58
+  if (homing_needed_error()) return;
59 59
 
60 60
   const int8_t verbose_level = parser.byteval('V', 1);
61 61
   if (!WITHIN(verbose_level, 0, 4)) {

+ 1
- 1
Marlin/src/gcode/feature/camera/M240.cpp 查看文件

@@ -126,7 +126,7 @@ void GcodeSuite::M240() {
126 126
 
127 127
   #ifdef PHOTO_POSITION
128 128
 
129
-    if (axis_unhomed_error()) return;
129
+    if (homing_needed_error()) return;
130 130
 
131 131
     const xyz_pos_t old_pos = {
132 132
       current_position.x + parser.linearval('A'),

+ 1
- 1
Marlin/src/gcode/feature/clean/G12.cpp 查看文件

@@ -45,7 +45,7 @@
45 45
  */
46 46
 void GcodeSuite::G12() {
47 47
   // Don't allow nozzle cleaning without homing first
48
-  if (axis_unhomed_error()) return;
48
+  if (homing_needed_error()) return;
49 49
 
50 50
   #ifdef WIPE_SEQUENCE_COMMANDS
51 51
     if (!parser.seen_any()) {

+ 1
- 1
Marlin/src/gcode/feature/pause/G27.cpp 查看文件

@@ -34,7 +34,7 @@
34 34
  */
35 35
 void GcodeSuite::G27() {
36 36
   // Don't allow nozzle parking without homing first
37
-  if (axis_unhomed_error()) return;
37
+  if (homing_needed_error()) return;
38 38
   nozzle.park(parser.ushortval('P'));
39 39
 }
40 40
 

+ 2
- 2
Marlin/src/gcode/feature/pause/M701_M702.cpp 查看文件

@@ -61,7 +61,7 @@ void GcodeSuite::M701() {
61 61
 
62 62
   #if ENABLED(NO_MOTION_BEFORE_HOMING)
63 63
     // Don't raise Z if the machine isn't homed
64
-    if (axes_need_homing()) park_point.z = 0;
64
+    if (axes_should_home()) park_point.z = 0;
65 65
   #endif
66 66
 
67 67
   #if ENABLED(MIXING_EXTRUDER)
@@ -149,7 +149,7 @@ void GcodeSuite::M702() {
149 149
 
150 150
   #if ENABLED(NO_MOTION_BEFORE_HOMING)
151 151
     // Don't raise Z if the machine isn't homed
152
-    if (axes_need_homing()) park_point.z = 0;
152
+    if (axes_should_home()) park_point.z = 0;
153 153
   #endif
154 154
 
155 155
   #if ENABLED(MIXING_EXTRUDER)

+ 1
- 1
Marlin/src/gcode/geometry/M206_M428.cpp 查看文件

@@ -61,7 +61,7 @@ void GcodeSuite::M206() {
61 61
  *       Use M206 to set these values directly.
62 62
  */
63 63
 void GcodeSuite::M428() {
64
-  if (axis_unhomed_error()) return;
64
+  if (homing_needed_error()) return;
65 65
 
66 66
   xyz_float_t diff;
67 67
   LOOP_XYZ(i) {

+ 1
- 1
Marlin/src/gcode/motion/G0_G1.cpp 查看文件

@@ -52,7 +52,7 @@ void GcodeSuite::G0_G1(
52 52
 
53 53
   if (IsRunning()
54 54
     #if ENABLED(NO_MOTION_BEFORE_HOMING)
55
-      && !axis_unhomed_error(
55
+      && !homing_needed_error(
56 56
           (parser.seen('X') ? _BV(X_AXIS) : 0)
57 57
         | (parser.seen('Y') ? _BV(Y_AXIS) : 0)
58 58
         | (parser.seen('Z') ? _BV(Z_AXIS) : 0) )

+ 1
- 1
Marlin/src/lcd/menu/menu_configuration.cpp 查看文件

@@ -181,7 +181,7 @@ void menu_advanced_settings();
181 181
 #if ENABLED(DUAL_X_CARRIAGE)
182 182
 
183 183
   void menu_idex() {
184
-    const bool need_g28 = !(TEST(axis_known_position, Y_AXIS) && TEST(axis_known_position, Z_AXIS));
184
+    const bool need_g28 = axes_should_home(_BV(Y_AXIS)|_BV(Z_AXIS));
185 185
 
186 186
     START_MENU();
187 187
     BACK_ITEM(MSG_CONFIGURATION);

+ 7
- 8
Marlin/src/module/motion.cpp 查看文件

@@ -1097,17 +1097,16 @@ void prepare_line_to_destination() {
1097 1097
   current_position = destination;
1098 1098
 }
1099 1099
 
1100
-uint8_t axes_need_homing(uint8_t axis_bits/*=0x07*/) {
1101
-  #define HOMED_FLAGS TERN(HOME_AFTER_DEACTIVATE, axis_known_position, axis_homed)
1102
-  // Clear test bits that are homed
1103
-  if (TEST(axis_bits, X_AXIS) && TEST(HOMED_FLAGS, X_AXIS)) CBI(axis_bits, X_AXIS);
1104
-  if (TEST(axis_bits, Y_AXIS) && TEST(HOMED_FLAGS, Y_AXIS)) CBI(axis_bits, Y_AXIS);
1105
-  if (TEST(axis_bits, Z_AXIS) && TEST(HOMED_FLAGS, Z_AXIS)) CBI(axis_bits, Z_AXIS);
1100
+uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) {
1101
+  // Clear test bits that are trusted
1102
+  if (TEST(axis_bits, X_AXIS) && TEST(axis_homed, X_AXIS)) CBI(axis_bits, X_AXIS);
1103
+  if (TEST(axis_bits, Y_AXIS) && TEST(axis_homed, Y_AXIS)) CBI(axis_bits, Y_AXIS);
1104
+  if (TEST(axis_bits, Z_AXIS) && TEST(axis_homed, Z_AXIS)) CBI(axis_bits, Z_AXIS);
1106 1105
   return axis_bits;
1107 1106
 }
1108 1107
 
1109
-bool axis_unhomed_error(uint8_t axis_bits/*=0x07*/) {
1110
-  if ((axis_bits = axes_need_homing(axis_bits))) {
1108
+bool homing_needed_error(uint8_t axis_bits/*=0x07*/) {
1109
+  if ((axis_bits = axes_should_home(axis_bits))) {
1111 1110
     PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1112 1111
     char msg[strlen_P(home_first)+1];
1113 1112
     sprintf_P(msg, home_first,

+ 7
- 12
Marlin/src/module/motion.h 查看文件

@@ -40,8 +40,7 @@ constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
40 40
 FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
41 41
 FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
42 42
 FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; }
43
-FORCE_INLINE void set_all_unhomed() { axis_homed = 0; }
44
-FORCE_INLINE void set_all_unknown() { axis_known_position = 0; }
43
+FORCE_INLINE void set_all_unhomed() { axis_homed = axis_known_position = 0; }
45 44
 
46 45
 FORCE_INLINE bool homing_needed() {
47 46
   return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)();
@@ -239,22 +238,18 @@ void do_z_clearance(const float &zclear, const bool z_known=true, const bool rai
239 238
 //
240 239
 // Homing
241 240
 //
242
-
243
-uint8_t axes_need_homing(uint8_t axis_bits=0x07);
244
-bool axis_unhomed_error(uint8_t axis_bits=0x07);
241
+void homeaxis(const AxisEnum axis);
242
+void set_axis_is_at_home(const AxisEnum axis);
243
+void set_axis_never_homed(const AxisEnum axis);
244
+uint8_t axes_should_home(uint8_t axis_bits=0x07);
245
+bool homing_needed_error(uint8_t axis_bits=0x07);
245 246
 
246 247
 #if ENABLED(NO_MOTION_BEFORE_HOMING)
247
-  #define MOTION_CONDITIONS (IsRunning() && !axis_unhomed_error())
248
+  #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error())
248 249
 #else
249 250
   #define MOTION_CONDITIONS IsRunning()
250 251
 #endif
251 252
 
252
-void set_axis_is_at_home(const AxisEnum axis);
253
-
254
-void set_axis_never_homed(const AxisEnum axis);
255
-
256
-void homeaxis(const AxisEnum axis);
257
-
258 253
 /**
259 254
  * Workspace offsets
260 255
  */

+ 1
- 1
Marlin/src/module/probe.cpp 查看文件

@@ -359,7 +359,7 @@ bool Probe::set_deployed(const bool deploy) {
359 359
     do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
360 360
 
361 361
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
362
-    if (axis_unhomed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) {
362
+    if (homing_needed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) {
363 363
       SERIAL_ERROR_MSG(STR_STOP_UNHOMED);
364 364
       stop();
365 365
       return true;

+ 4
- 3
Marlin/src/module/stepper/indirection.h 查看文件

@@ -840,12 +840,13 @@ void reset_stepper_drivers();    // Called by settings.load / settings.reset
840 840
 //
841 841
 // Axis steppers enable / disable macros
842 842
 //
843
+#define FORGET_AXIS(A) TERN(HOME_AFTER_DEACTIVATE, set_axis_never_homed(A), CBI(axis_known_position, A))
843 844
 
844 845
 #define  ENABLE_AXIS_X() do{ ENABLE_STEPPER_X(); ENABLE_STEPPER_X2(); }while(0)
845
-#define DISABLE_AXIS_X() do{ DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); CBI(axis_known_position, X_AXIS); }while(0)
846
+#define DISABLE_AXIS_X() do{ DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); FORGET_AXIS(X_AXIS); }while(0)
846 847
 
847 848
 #define  ENABLE_AXIS_Y() do{ ENABLE_STEPPER_Y(); ENABLE_STEPPER_Y2(); }while(0)
848
-#define DISABLE_AXIS_Y() do{ DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); CBI(axis_known_position, Y_AXIS); }while(0)
849
+#define DISABLE_AXIS_Y() do{ DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); FORGET_AXIS(Y_AXIS); }while(0)
849 850
 
850 851
 #define  ENABLE_AXIS_Z() do{ ENABLE_STEPPER_Z();  ENABLE_STEPPER_Z2();  ENABLE_STEPPER_Z3();  ENABLE_STEPPER_Z4(); }while(0)
851 852
 
@@ -854,7 +855,7 @@ void reset_stepper_drivers();    // Called by settings.load / settings.reset
854 855
 #else
855 856
   #define Z_RESET()
856 857
 #endif
857
-#define DISABLE_AXIS_Z() do{ DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); CBI(axis_known_position, Z_AXIS); Z_RESET(); }while(0)
858
+#define DISABLE_AXIS_Z() do{ DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); FORGET_AXIS(Z_AXIS); Z_RESET(); }while(0)
858 859
 
859 860
 //
860 861
 // Extruder steppers enable / disable macros

+ 1
- 1
Marlin/src/module/tool_change.cpp 查看文件

@@ -174,7 +174,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
174 174
                 grabpos = mpe_settings.parking_xpos[new_tool] + (new_tool ? mpe_settings.grab_distance : -mpe_settings.grab_distance),
175 175
                 offsetcompensation = TERN0(HAS_HOTEND_OFFSET, hotend_offset[active_extruder].x * mpe_settings.compensation_factor);
176 176
 
177
-    if (axis_unhomed_error(_BV(X_AXIS))) return;
177
+    if (homing_needed_error(_BV(X_AXIS))) return;
178 178
 
179 179
     /**
180 180
      * Z Lift and Nozzle Offset shift ar defined in caller method to work equal with any Multi Hotend realization

Loading…
取消
儲存