Browse Source

Mark axes not-homed with HOME_AFTER_DEACTIVATE (#18907)

swissnorp 5 years ago
parent
commit
a12ac5e175
No account linked to committer's email address

+ 3
- 2
Marlin/src/feature/babystep.cpp View File

26
 
26
 
27
 #include "babystep.h"
27
 #include "babystep.h"
28
 #include "../MarlinCore.h"
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
 #include "../module/stepper.h"
31
 #include "../module/stepper.h"
31
 
32
 
32
 #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
33
 #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
54
 }
55
 }
55
 
56
 
56
 void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
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
   accum += distance; // Count up babysteps for the UI
60
   accum += distance; // Count up babysteps for the UI
60
   steps[BS_AXIS_IND(axis)] += distance;
61
   steps[BS_AXIS_IND(axis)] += distance;

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

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

+ 1
- 1
Marlin/src/feature/pause.cpp View File

413
     unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
413
     unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
414
 
414
 
415
   // Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos)
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
     nozzle.park(0, park_point);
417
     nozzle.park(0, park_point);
418
 
418
 
419
   #if ENABLED(DUAL_X_CARRIAGE)
419
   #if ENABLED(DUAL_X_CARRIAGE)

+ 1
- 1
Marlin/src/gcode/bedlevel/G26.cpp View File

490
 
490
 
491
   // Don't allow Mesh Validation without homing first,
491
   // Don't allow Mesh Validation without homing first,
492
   // or if the parameter parsing did not go OK, abort
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
   // Change the tool first, if specified
495
   // Change the tool first, if specified
496
   if (parser.seenval('T')) tool_change(parser.value_int());
496
   if (parser.seenval('T')) tool_change(parser.value_int());

+ 1
- 1
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

183
               faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
183
               faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
184
 
184
 
185
   // Don't allow auto-leveling without homing first
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
   if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
188
   if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
189
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip");
189
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip");

+ 3
- 3
Marlin/src/gcode/calibrate/G28.cpp View File

118
     DEBUG_SECTION(log_G28, "home_z_safely", DEBUGGING(LEVELING));
118
     DEBUG_SECTION(log_G28, "home_z_safely", DEBUGGING(LEVELING));
119
 
119
 
120
     // Disallow Z homing if X or Y homing is needed
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
     sync_plan_position();
123
     sync_plan_position();
124
 
124
 
299
   #else // NOT DELTA
299
   #else // NOT DELTA
300
 
300
 
301
     const bool homeZ = parser.seen('Z'),
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
                homeX = needX || parser.seen('X'), homeY = needY || parser.seen('Y'),
304
                homeX = needX || parser.seen('X'), homeY = needY || parser.seen('Y'),
305
                home_all = homeX == homeY && homeX == homeZ, // All or None
305
                home_all = homeX == homeY && homeX == homeZ, // All or None
306
                doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ;
306
                doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ;

+ 1
- 1
Marlin/src/gcode/calibrate/G425.cpp View File

584
   TEMPORARY_SOFT_ENDSTOP_STATE(false);
584
   TEMPORARY_SOFT_ENDSTOP_STATE(false);
585
   TEMPORARY_BED_LEVELING_STATE(false);
585
   TEMPORARY_BED_LEVELING_STATE(false);
586
 
586
 
587
-  if (axis_unhomed_error()) return;
587
+  if (homing_needed_error()) return;
588
 
588
 
589
   measurements_t m;
589
   measurements_t m;
590
 
590
 

+ 1
- 1
Marlin/src/gcode/calibrate/M48.cpp View File

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

+ 1
- 1
Marlin/src/gcode/feature/camera/M240.cpp View File

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

+ 1
- 1
Marlin/src/gcode/feature/clean/G12.cpp View File

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

+ 1
- 1
Marlin/src/gcode/feature/pause/G27.cpp View File

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

+ 2
- 2
Marlin/src/gcode/feature/pause/M701_M702.cpp View File

61
 
61
 
62
   #if ENABLED(NO_MOTION_BEFORE_HOMING)
62
   #if ENABLED(NO_MOTION_BEFORE_HOMING)
63
     // Don't raise Z if the machine isn't homed
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
   #endif
65
   #endif
66
 
66
 
67
   #if ENABLED(MIXING_EXTRUDER)
67
   #if ENABLED(MIXING_EXTRUDER)
149
 
149
 
150
   #if ENABLED(NO_MOTION_BEFORE_HOMING)
150
   #if ENABLED(NO_MOTION_BEFORE_HOMING)
151
     // Don't raise Z if the machine isn't homed
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
   #endif
153
   #endif
154
 
154
 
155
   #if ENABLED(MIXING_EXTRUDER)
155
   #if ENABLED(MIXING_EXTRUDER)

+ 1
- 1
Marlin/src/gcode/geometry/M206_M428.cpp View File

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

+ 1
- 1
Marlin/src/gcode/motion/G0_G1.cpp View File

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

+ 1
- 1
Marlin/src/lcd/menu/menu_configuration.cpp View File

181
 #if ENABLED(DUAL_X_CARRIAGE)
181
 #if ENABLED(DUAL_X_CARRIAGE)
182
 
182
 
183
   void menu_idex() {
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
     START_MENU();
186
     START_MENU();
187
     BACK_ITEM(MSG_CONFIGURATION);
187
     BACK_ITEM(MSG_CONFIGURATION);

+ 7
- 8
Marlin/src/module/motion.cpp View File

1097
   current_position = destination;
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
   return axis_bits;
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
     PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1110
     PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1112
     char msg[strlen_P(home_first)+1];
1111
     char msg[strlen_P(home_first)+1];
1113
     sprintf_P(msg, home_first,
1112
     sprintf_P(msg, home_first,

+ 7
- 12
Marlin/src/module/motion.h View File

40
 FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
40
 FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
41
 FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
41
 FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
42
 FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; }
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
 FORCE_INLINE bool homing_needed() {
45
 FORCE_INLINE bool homing_needed() {
47
   return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)();
46
   return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)();
239
 //
238
 //
240
 // Homing
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
 #if ENABLED(NO_MOTION_BEFORE_HOMING)
247
 #if ENABLED(NO_MOTION_BEFORE_HOMING)
247
-  #define MOTION_CONDITIONS (IsRunning() && !axis_unhomed_error())
248
+  #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error())
248
 #else
249
 #else
249
   #define MOTION_CONDITIONS IsRunning()
250
   #define MOTION_CONDITIONS IsRunning()
250
 #endif
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
  * Workspace offsets
254
  * Workspace offsets
260
  */
255
  */

+ 1
- 1
Marlin/src/module/probe.cpp View File

359
     do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
359
     do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
360
 
360
 
361
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
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
       SERIAL_ERROR_MSG(STR_STOP_UNHOMED);
363
       SERIAL_ERROR_MSG(STR_STOP_UNHOMED);
364
       stop();
364
       stop();
365
       return true;
365
       return true;

+ 4
- 3
Marlin/src/module/stepper/indirection.h View File

840
 //
840
 //
841
 // Axis steppers enable / disable macros
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
 #define  ENABLE_AXIS_X() do{ ENABLE_STEPPER_X(); ENABLE_STEPPER_X2(); }while(0)
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
 #define  ENABLE_AXIS_Y() do{ ENABLE_STEPPER_Y(); ENABLE_STEPPER_Y2(); }while(0)
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
 #define  ENABLE_AXIS_Z() do{ ENABLE_STEPPER_Z();  ENABLE_STEPPER_Z2();  ENABLE_STEPPER_Z3();  ENABLE_STEPPER_Z4(); }while(0)
851
 #define  ENABLE_AXIS_Z() do{ ENABLE_STEPPER_Z();  ENABLE_STEPPER_Z2();  ENABLE_STEPPER_Z3();  ENABLE_STEPPER_Z4(); }while(0)
851
 
852
 
854
 #else
855
 #else
855
   #define Z_RESET()
856
   #define Z_RESET()
856
 #endif
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
 // Extruder steppers enable / disable macros
861
 // Extruder steppers enable / disable macros

+ 1
- 1
Marlin/src/module/tool_change.cpp View File

174
                 grabpos = mpe_settings.parking_xpos[new_tool] + (new_tool ? mpe_settings.grab_distance : -mpe_settings.grab_distance),
174
                 grabpos = mpe_settings.parking_xpos[new_tool] + (new_tool ? mpe_settings.grab_distance : -mpe_settings.grab_distance),
175
                 offsetcompensation = TERN0(HAS_HOTEND_OFFSET, hotend_offset[active_extruder].x * mpe_settings.compensation_factor);
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
      * Z Lift and Nozzle Offset shift ar defined in caller method to work equal with any Multi Hotend realization
180
      * Z Lift and Nozzle Offset shift ar defined in caller method to work equal with any Multi Hotend realization

Loading…
Cancel
Save