Browse Source

Clear up HAS_WORKSPACE_OFFSET meaning

Scott Lahteine 6 years ago
parent
commit
2c9586be0c
3 changed files with 20 additions and 26 deletions
  1. 5
    5
      Marlin/src/inc/Conditionals_post.h
  2. 13
    15
      Marlin/src/module/motion.cpp
  3. 2
    6
      Marlin/src/module/motion.h

+ 5
- 5
Marlin/src/inc/Conditionals_post.h View File

@@ -1527,11 +1527,11 @@
1527 1527
 // Updated G92 behavior shifts the workspace
1528 1528
 #define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
1529 1529
 // The home offset also shifts the coordinate space
1530
-#define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && DISABLED(DELTA))
1531
-// Either offset yields extra calculations on all moves
1532
-#define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT || HAS_HOME_OFFSET)
1533
-// M206 doesn't apply to DELTA
1534
-#define HAS_M206_COMMAND (HAS_HOME_OFFSET && DISABLED(DELTA))
1530
+#define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && (IS_SCARA || IS_CARTESIAN))
1531
+// Cumulative offset to workspace to save some calculation
1532
+#define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT && HAS_HOME_OFFSET)
1533
+// M206 sets the home offset for Cartesian machines
1534
+#define HAS_M206_COMMAND (HAS_HOME_OFFSET && !IS_SCARA)
1535 1535
 
1536 1536
 // LCD timeout to status screen default is 15s
1537 1537
 #ifndef LCD_TIMEOUT_TO_STATUS

+ 13
- 15
Marlin/src/module/motion.cpp View File

@@ -138,20 +138,18 @@ float cartes[XYZ];
138 138
  * The workspace can be offset by some commands, or
139 139
  * these offsets may be omitted to save on computation.
140 140
  */
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
141
+#if HAS_POSITION_SHIFT
142
+  // The distance that XYZ has been offset by G92. Reset by G28.
143
+  float position_shift[XYZ] = { 0 };
144
+#endif
145
+#if HAS_HOME_OFFSET
146
+  // This offset is added to the configured home position.
147
+  // Set by M206, M428, or menu item. Saved to EEPROM.
148
+  float home_offset[XYZ] = { 0 };
149
+#endif
150
+#if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
151
+  // The above two are combined to save on computes
152
+  float workspace_offset[XYZ] = { 0 };
155 153
 #endif
156 154
 
157 155
 #if OLDSCHOOL_ABL
@@ -1518,7 +1516,7 @@ void homeaxis(const AxisEnum axis) {
1518 1516
    * at the same positions relative to the machine.
1519 1517
    */
1520 1518
   void update_software_endstops(const AxisEnum axis) {
1521
-    #if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
1519
+    #if HAS_HOME_OFFSET
1522 1520
       workspace_offset[axis] = home_offset[axis] + position_shift[axis];
1523 1521
     #endif
1524 1522
 

+ 2
- 6
Marlin/src/module/motion.h View File

@@ -211,14 +211,10 @@ void homeaxis(const AxisEnum axis);
211 211
   void sensorless_homing_per_axis(const AxisEnum axis, const bool enable=true);
212 212
 #endif
213 213
 
214
-//
215
-// Macros
216
-//
217
-
218 214
 /**
219 215
  * Workspace offsets
220 216
  */
221
-#if HAS_WORKSPACE_OFFSET
217
+#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
222 218
   #if HAS_HOME_OFFSET
223 219
     extern float home_offset[XYZ];
224 220
   #endif
@@ -230,7 +226,7 @@ void homeaxis(const AxisEnum axis);
230 226
     #define WORKSPACE_OFFSET(AXIS) workspace_offset[AXIS]
231 227
   #elif HAS_HOME_OFFSET
232 228
     #define WORKSPACE_OFFSET(AXIS) home_offset[AXIS]
233
-  #elif HAS_POSITION_SHIFT
229
+  #else
234 230
     #define WORKSPACE_OFFSET(AXIS) position_shift[AXIS]
235 231
   #endif
236 232
   #define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + WORKSPACE_OFFSET(AXIS))

Loading…
Cancel
Save