소스 검색

Merge pull request #6337 from thinkyhead/rc_core_endstop_fix

CORExx endstop detection fixes
Scott Lahteine 7 년 전
부모
커밋
76765a8279
1개의 변경된 파일68개의 추가작업 그리고 37개의 파일을 삭제
  1. 68
    37
      Marlin/endstops.cpp

+ 68
- 37
Marlin/endstops.cpp 파일 보기

266
     } while(0)
266
     } while(0)
267
 
267
 
268
   #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ)
268
   #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ)
269
-  // If G38 command then check Z_MIN_PROBE for every axis and every direction
269
+    // If G38 command is active check Z_MIN_PROBE for ALL movement
270
     if (G38_move) {
270
     if (G38_move) {
271
       UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
271
       UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
272
       if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
272
       if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
273
-        if      (stepper.current_block->steps[_AXIS(X)] > 0) {_ENDSTOP_HIT(X); stepper.endstop_triggered(_AXIS(X));}
274
-        else if (stepper.current_block->steps[_AXIS(Y)] > 0) {_ENDSTOP_HIT(Y); stepper.endstop_triggered(_AXIS(Y));}
275
-        else if (stepper.current_block->steps[_AXIS(Z)] > 0) {_ENDSTOP_HIT(Z); stepper.endstop_triggered(_AXIS(Z));}
273
+        if      (stepper.current_block->steps[_AXIS(X)] > 0) { _ENDSTOP_HIT(X); stepper.endstop_triggered(_AXIS(X)); }
274
+        else if (stepper.current_block->steps[_AXIS(Y)] > 0) { _ENDSTOP_HIT(Y); stepper.endstop_triggered(_AXIS(Y)); }
275
+        else if (stepper.current_block->steps[_AXIS(Z)] > 0) { _ENDSTOP_HIT(Z); stepper.endstop_triggered(_AXIS(Z)); }
276
         G38_endstop_hit = true;
276
         G38_endstop_hit = true;
277
       }
277
       }
278
     }
278
     }
279
   #endif
279
   #endif
280
 
280
 
281
-  #if CORE_IS_XY || CORE_IS_XZ
282
-    #if ENABLED(COREYX) || ENABLED(COREZX)
281
+    #if ENABLED(COREXY) || ENABLED(COREXZ)
282
+      #define CORE_X_CMP ==
283
+    #elif ENABLED(COREYX) || ENABLED(COREZX)
283
       #define CORE_X_CMP !=
284
       #define CORE_X_CMP !=
284
-      #define CORE_X_NOT !
285
+    #endif
286
+
287
+    /**
288
+     * Head direction in -X axis for CoreXY and CoreXZ bots.
289
+     *
290
+     * If steps differ, both axes are moving.
291
+     * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
292
+     * If DeltaA ==  DeltaB, the movement is only in the 1st axis (X)
293
+     */
294
+    #if CORE_IS_XY || CORE_IS_XZ
295
+      if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
296
+        || (    stepper.current_block->steps[CORE_AXIS_1] > 0
297
+             && stepper.motor_direction(CORE_AXIS_1) CORE_X_CMP stepper.motor_direction(CORE_AXIS_2)
298
+           )
299
+      ) {
300
+        if (stepper.motor_direction(X_HEAD))
285
     #else
301
     #else
286
-      #define CORE_X_CMP ==
287
-      #define CORE_X_NOT
302
+      if (stepper.current_block->steps[X_AXIS] > 0)
303
+        if (stepper.motor_direction(X_AXIS))   // stepping along -X axis (regular Cartesian bot)
288
     #endif
304
     #endif
289
-    // Head direction in -X axis for CoreXY and CoreXZ bots.
290
-    // If steps differ, both axes are moving.
291
-    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
292
-    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X)
293
-    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_X_CMP stepper.motor_direction(CORE_AXIS_2)) {
294
-      if (CORE_X_NOT stepper.motor_direction(X_HEAD))
295
-  #else
296
-      if (stepper.motor_direction(X_AXIS))   // stepping along -X axis (regular Cartesian bot)
297
-  #endif
298
       { // -direction
305
       { // -direction
299
         #if ENABLED(DUAL_X_CARRIAGE)
306
         #if ENABLED(DUAL_X_CARRIAGE)
300
           // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
307
           // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
301
-          if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR < 0) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR < 0))
308
+          if ( (stepper.current_block->active_extruder == 0 && X_HOME_DIR < 0)
309
+            || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR < 0)
310
+          )
302
         #endif
311
         #endif
303
           {
312
           {
304
             #if HAS_X_MIN
313
             #if HAS_X_MIN
309
       else { // +direction
318
       else { // +direction
310
         #if ENABLED(DUAL_X_CARRIAGE)
319
         #if ENABLED(DUAL_X_CARRIAGE)
311
           // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
320
           // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
312
-          if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR > 0) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR > 0))
321
+          if ( (stepper.current_block->active_extruder == 0 && X_HOME_DIR > 0)
322
+            || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR > 0)
323
+          )
313
         #endif
324
         #endif
314
           {
325
           {
315
             #if HAS_X_MAX
326
             #if HAS_X_MAX
322
   #endif
333
   #endif
323
 
334
 
324
   // Handle swapped vs. typical Core axis order
335
   // Handle swapped vs. typical Core axis order
325
-  #if ENABLED(COREYX) || ENABLED(COREZY) || ENABLED(COREZX)
336
+  #if ENABLED(COREYX) || ENABLED(COREYZ)
326
     #define CORE_YZ_CMP ==
337
     #define CORE_YZ_CMP ==
327
-    #define CORE_YZ_NOT !
328
-  #elif CORE_IS_XY || CORE_IS_YZ || CORE_IS_XZ
338
+  #elif ENABLED(COREXY) || ENABLED(COREZY)
329
     #define CORE_YZ_CMP !=
339
     #define CORE_YZ_CMP !=
330
-    #define CORE_YZ_NOT
331
   #endif
340
   #endif
332
 
341
 
333
   #if CORE_IS_XY || CORE_IS_YZ
342
   #if CORE_IS_XY || CORE_IS_YZ
334
-    // Head direction in -Y axis for CoreXY / CoreYZ bots.
335
-    // If steps differ, both axes are moving
336
-    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y)
337
-    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
338
-    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)) {
339
-      if (CORE_YZ_NOT stepper.motor_direction(Y_HEAD))
343
+    /**
344
+     * Head direction in -Y axis for CoreXY / CoreYZ bots.
345
+     *
346
+     * If steps differ, both axes are moving
347
+     * If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y)
348
+     * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
349
+     */
350
+    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
351
+      || (    stepper.current_block->steps[CORE_AXIS_1] > 0
352
+           && stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)
353
+         )
354
+    ) {
355
+      if (stepper.motor_direction(Y_HEAD))
340
   #else
356
   #else
357
+    if (stepper.current_block->steps[Y_AXIS] > 0)
341
       if (stepper.motor_direction(Y_AXIS))   // -direction
358
       if (stepper.motor_direction(Y_AXIS))   // -direction
342
   #endif
359
   #endif
343
       { // -direction
360
       { // -direction
354
     }
371
     }
355
   #endif
372
   #endif
356
 
373
 
374
+
375
+  #if ENABLED(COREZX) || ENABLED(COREZY)
376
+    #define CORE_YZ_CMP ==
377
+  #elif ENABLED(COREXZ) || ENABLED(COREYZ)
378
+    #define CORE_YZ_CMP !=
379
+  #endif
380
+
357
   #if CORE_IS_XZ || CORE_IS_YZ
381
   #if CORE_IS_XZ || CORE_IS_YZ
358
-    // Head direction in -Z axis for CoreXZ or CoreYZ bots.
359
-    // If steps differ, both axes are moving
360
-    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
361
-    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
362
-    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)) {
363
-      if (CORE_YZ_NOT stepper.motor_direction(Z_HEAD))
382
+    /**
383
+     * Head direction in -Z axis for CoreXZ or CoreYZ bots.
384
+     *
385
+     * If steps differ, both axes are moving
386
+     * If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
387
+     * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
388
+     */
389
+    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
390
+      || (    stepper.current_block->steps[CORE_AXIS_1] > 0
391
+           && stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)
392
+         )
393
+    ) {
394
+      if (stepper.motor_direction(Z_HEAD))
364
   #else
395
   #else
396
+    if (stepper.current_block->steps[Z_AXIS] > 0)
365
       if (stepper.motor_direction(Z_AXIS))
397
       if (stepper.motor_direction(Z_AXIS))
366
   #endif
398
   #endif
367
       { // Z -direction. Gantry down, bed up.
399
       { // Z -direction. Gantry down, bed up.
368
         #if HAS_Z_MIN
400
         #if HAS_Z_MIN
369
-
370
           #if ENABLED(Z_DUAL_ENDSTOPS)
401
           #if ENABLED(Z_DUAL_ENDSTOPS)
371
 
402
 
372
             UPDATE_ENDSTOP_BIT(Z, MIN);
403
             UPDATE_ENDSTOP_BIT(Z, MIN);

Loading…
취소
저장