@ -413,48 +413,49 @@ ISR(TIMER1_COMPA_vect) {
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      # else 
 
					 
					 
					 
					      # else 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        // Head direction in -X axis for CoreXY bots.
 
 
					 
					 
					 
					        // Head direction in -X axis for CoreXY bots.
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        // If DeltaX == -DeltaY, the movement is only in Y axis
 
 
					 
					 
					 
					        // If DeltaX == -DeltaY, the movement is only in Y axis
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if  ( TEST ( out_bits ,  X_HEAD )  & &  ( current_block - > steps_x  ! =  current_block - > steps_y  | |  ( TEST ( out_bits ,  X_AXIS )  = =  TEST ( out_bits ,  Y_AXIS ) ) ) ) 
 
					 
					 
					 
					        if  ( current_block - > steps_x  ! =  current_block - > steps_y  | |  ( TEST ( out_bits ,  X_AXIS )  = =  TEST ( out_bits ,  Y_AXIS ) ) )       
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            if  ( TEST ( out_bits ,  X_HEAD ) ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      # endif 
 
					 
					 
					 
					      # endif 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        {  // -direction
 
 
					 
					 
					 
					            {  // -direction
 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					          # ifdef DUAL_X_CARRIAGE 
 
					 
					 
					 
					              # ifdef DUAL_X_CARRIAGE 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					            // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
 
 
					 
					 
					 
					                // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( ( current_block - > active_extruder  = =  0  & &  X_HOME_DIR  = =  - 1 )  | |  ( current_block - > active_extruder  ! =  0  & &  X2_HOME_DIR  = =  - 1 ) ) 
 
					 
					 
					 
					                if  ( ( current_block - > active_extruder  = =  0  & &  X_HOME_DIR  = =  - 1 )  | |  ( current_block - > active_extruder  ! =  0  & &  X2_HOME_DIR  = =  - 1 ) ) 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					          # endif           
 
					 
					 
					 
					              # endif           
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					            { 
 
					 
					 
					 
					                { 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					              # if defined(X_MIN_PIN) && X_MIN_PIN >= 0 
 
					 
					 
					 
					                  # if defined(X_MIN_PIN) && X_MIN_PIN >= 0 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					                UPDATE_ENDSTOP ( x ,  X ,  min ,  MIN ) ; 
 
					 
					 
					 
					                    UPDATE_ENDSTOP ( x ,  X ,  min ,  MIN ) ; 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                  # endif 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            else  {  // +direction
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					              # ifdef DUAL_X_CARRIAGE 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                if  ( ( current_block - > active_extruder  = =  0  & &  X_HOME_DIR  = =  1 )  | |  ( current_block - > active_extruder  ! =  0  & &  X2_HOME_DIR  = =  1 ) ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					              # endif 
 
					 
					 
					 
					              # endif 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                  # if defined(X_MAX_PIN) && X_MAX_PIN >= 0 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                    UPDATE_ENDSTOP ( x ,  X ,  max ,  MAX ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                  # endif 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            } 
 
					 
					 
					 
					            } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        } 
 
					 
					 
					 
					      # ifndef COREXY 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					        else  {  // +direction
 
 
					 
					 
					 
					        if  ( TEST ( out_bits ,  Y_AXIS ) )    // -direction
 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					          # ifdef DUAL_X_CARRIAGE 
 
					 
					 
					 
					      # else 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					            // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
 
 
					 
					 
					 
					        // Head direction in -Y axis for CoreXY bots.
 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( ( current_block - > active_extruder  = =  0  & &  X_HOME_DIR  = =  1 )  | |  ( current_block - > active_extruder  ! =  0  & &  X2_HOME_DIR  = =  1 ) ) 
 
					 
					 
					 
					        // If DeltaX == DeltaY, the movement is only in X axis
 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					          # endif 
 
					 
					 
					 
					        if  ( current_block - > steps_x  ! =  current_block - > steps_y  | |  ( TEST ( out_bits ,  X_AXIS )  ! =  TEST ( out_bits ,  Y_AXIS ) ) ) 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					            { 
 
					 
					 
					 
					            if  ( TEST ( out_bits ,  Y_HEAD ) )              
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					              # if defined(X_MAX_PIN) && X_MAX_PIN >= 0 
 
					 
					 
					 
					      # endif 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					                UPDATE_ENDSTOP ( x ,  X ,  max ,  MAX ) ; 
 
					 
					 
					 
					            {  // -direction
 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					              # if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                UPDATE_ENDSTOP ( y ,  Y ,  min ,  MIN ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					              # endif 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            else  {  // +direction
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					              # if defined(Y_MAX_PIN) && Y_MAX_PIN >= 0 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                UPDATE_ENDSTOP ( y ,  Y ,  max ,  MAX ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					              # endif 
 
					 
					 
					 
					              # endif 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            } 
 
					 
					 
					 
					            } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        } 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        # ifndef COREXY 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          if  ( TEST ( out_bits ,  Y_AXIS ) )    // -direction
 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        # else 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          // Head direction in -Y axis for CoreXY bots.
 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          // If DeltaX == DeltaY, the movement is only in X axis
 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          if  ( TEST ( out_bits ,  Y_HEAD )  & &  ( current_block - > steps_x  ! =  current_block - > steps_y  | |  ( TEST ( out_bits ,  X_AXIS )  ! =  TEST ( out_bits ,  Y_AXIS ) ) ) ) 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        # endif 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        {  // -direction
 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          # if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            UPDATE_ENDSTOP ( y ,  Y ,  min ,  MIN ) ; 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          # endif 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        } 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        else  {  // +direction
 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          # if defined(Y_MAX_PIN) && Y_MAX_PIN >= 0 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            UPDATE_ENDSTOP ( y ,  Y ,  max ,  MAX ) ; 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					          # endif 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        } 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    } 
 
					 
					 
					 
					    } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    if  ( TEST ( out_bits ,  Z_AXIS ) )  {    // -direction
 
 
					 
					 
					 
					    if  ( TEST ( out_bits ,  Z_AXIS ) )  {    // -direction