Skip to content

Commit

Permalink
Update Homing.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
bdring committed Aug 11, 2023
1 parent d9ab16b commit 9ca4ad1
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions FluidNC/src/Machine/Homing.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "Homing.h"

#include "../System.h" // sys.*
#include "../Stepper.h" // st_wake
#include "../Protocol.h" // protocol_handle_events
#include "../Limits.h" // ambiguousLimit
#include "../System.h" // sys.*
#include "../Stepper.h" // st_wake
#include "../Protocol.h" // protocol_handle_events
#include "../Limits.h" // ambiguousLimit
#include "../Machine/Axes.h"
#include "../Machine/MachineConfig.h" // config

Expand Down Expand Up @@ -42,13 +42,25 @@ namespace Machine {

AxisMask Homing::_unhomed_axes; // Bitmap of axes whose position is unknown

bool Homing::axis_is_homed(size_t axis) { return bitnum_is_false(_unhomed_axes, axis); }
void Homing::set_axis_homed(size_t axis) { clear_bitnum(_unhomed_axes, axis); }
void Homing::set_axis_unhomed(size_t axis) { set_bitnum(_unhomed_axes, axis); }
void Homing::set_all_axes_unhomed() { _unhomed_axes = Machine::Axes::homingMask; }
void Homing::set_all_axes_homed() { _unhomed_axes = 0; }
bool Homing::axis_is_homed(size_t axis) {
return bitnum_is_false(_unhomed_axes, axis);
}
void Homing::set_axis_homed(size_t axis) {
clear_bitnum(_unhomed_axes, axis);
}
void Homing::set_axis_unhomed(size_t axis) {
set_bitnum(_unhomed_axes, axis);
}
void Homing::set_all_axes_unhomed() {
_unhomed_axes = Machine::Axes::homingMask;
}
void Homing::set_all_axes_homed() {
_unhomed_axes = 0;
}

AxisMask Homing::unhomed_axes() { return _unhomed_axes; }
AxisMask Homing::unhomed_axes() {
return _unhomed_axes;
}

const char* Homing::_phaseNames[] = {
"None", "PrePulloff", "FastApproach", "Pulloff0", "SlowApproach", "Pulloff1", "Pulloff2", "CycleDone",
Expand Down Expand Up @@ -76,7 +88,9 @@ namespace Machine {
protocol_send_event(&cycleStartEvent);
}

static MotorMask limited() { return Machine::Axes::posLimitMask | Machine::Axes::negLimitMask; }
static MotorMask limited() {
return Machine::Axes::posLimitMask | Machine::Axes::negLimitMask;
}

void Homing::cycleStop() {
log_debug("CycleStop " << phaseName(_phase));
Expand Down Expand Up @@ -360,7 +374,7 @@ namespace Machine {
}

void Homing::fail(ExecAlarm alarm) {
Stepper::reset(); // Stop moving
Stepper::reset(); // Stop moving
send_alarm(alarm);
config->_axes->set_homing_mode(_cycleAxes, false); // tell motors homing is done...failed
config->_axes->set_disable(config->_stepping->_idleMsecs != 255);
Expand Down Expand Up @@ -432,6 +446,7 @@ namespace Machine {
// cycle. The protocol loop will then respond to events and advance
// the homing state machine through its phases.
void Homing::run_cycles(AxisMask axisMask) {
// Check to see if the Kinematics takes care of homing.
if (config->_kinematics->kinematics_homing(axisMask)) {
return;
}
Expand Down

0 comments on commit 9ca4ad1

Please sign in to comment.