- this->feed_rate[X_AXIS] = slow_rate;
- STEPPER[X_AXIS]->move(!dirx, retract_steps, 0);
- this->feed_rate[Y_AXIS] = slow_rate;
- STEPPER[Y_AXIS]->move(!diry, retract_steps, 0);
-
- // wait until done
- while ( STEPPER[X_AXIS]->is_moving() || STEPPER[Y_AXIS]->is_moving()) {
- THEKERNEL->call_event(ON_IDLE);
- if(THEKERNEL->is_halted()) return;
- }
-
- // Start moving the axes to the origin slowly
- this->status = MOVING_TO_ENDSTOP_SLOW;
- this->feed_rate[X_AXIS] = slow_rate;
- STEPPER[X_AXIS]->move(dirx, 10000000, 0);
- this->feed_rate[Y_AXIS] = slow_rate;
- STEPPER[Y_AXIS]->move(diry, 10000000, 0);
-
- // wait for primary axis
- if(!this->wait_for_homed_corexy(home_axis)) return;
-}
-
-// this homing works for HBots/CoreXY
-void Endstops::do_homing_corexy(char axes_to_move)
-{
- // TODO should really make order configurable, and select whether to allow XY to home at the same time, diagonally
- // To move XY at the same time only one motor needs to turn, determine which motor and which direction based on min or max directions
- // allow to move until an endstop triggers, then stop that motor. Speed up when moving diagonally to match X or Y speed
- // continue moving in the direction not yet triggered (which means two motors turning) until endstop hit
-
- if((axes_to_move & 0x03) == 0x03) { // both X and Y need Homing
- // determine which motor to turn and which way
- bool dirx = this->home_direction[X_AXIS];
- bool diry = this->home_direction[Y_AXIS];
- int motor;
- bool dir;
- if(dirx && diry) { // min/min
- motor = X_AXIS;
- dir = true;
- } else if(dirx && !diry) { // min/max
- motor = Y_AXIS;
- dir = true;
- } else if(!dirx && diry) { // max/min
- motor = Y_AXIS;
- dir = false;
- } else if(!dirx && !diry) { // max/max
- motor = X_AXIS;
- dir = false;
- }
-
- // then move both X and Y until one hits the endstop
- this->status = MOVING_TO_ENDSTOP_FAST;
- // need to allow for more ground covered when moving diagonally
- this->feed_rate[motor] = this->fast_rates[motor] * 1.4142;
- STEPPER[motor]->move(dir, 10000000, 0);
- // wait until either X or Y hits the endstop
- bool running = true;
- while (running) {
- THEKERNEL->call_event(ON_IDLE);
- if(THEKERNEL->is_halted()) return;
- for(int m = X_AXIS; m <= Y_AXIS; m++) {
- if(this->pins[m + (this->home_direction[m] ? 0 : 3)].get()) {
- // turn off motor
- if(STEPPER[motor]->is_moving()) STEPPER[motor]->move(0, 0);
- running = false;
- break;
- }
- }