♻️ Refactor Linear / Logical / Distinct Axes (#21953)

* More patches supporting EXTRUDERS 0
* Extend types in prep for more axes
This commit is contained in:
Scott Lahteine
2021-05-24 16:38:57 -05:00
committed by GitHub
parent 0d7075b90c
commit dd4990252e
43 changed files with 1142 additions and 788 deletions

View File

@@ -498,7 +498,7 @@ void Stepper::set_directions() {
MIXER_STEPPER_LOOP(j) NORM_E_DIR(j);
count_direction.e = 1;
}
#else
#elif HAS_EXTRUDERS
if (motor_direction(E_AXIS)) {
REV_E_DIR(stepper_extruder);
count_direction.e = -1;
@@ -1627,7 +1627,7 @@ void Stepper::pulse_phase_isr() {
PAGE_PULSE_PREP(X);
PAGE_PULSE_PREP(Y);
PAGE_PULSE_PREP(Z);
PAGE_PULSE_PREP(E);
TERN_(HAS_EXTRUDERS, PAGE_PULSE_PREP(E));
page_step_state.segment_steps++;
@@ -1660,7 +1660,7 @@ void Stepper::pulse_phase_isr() {
PAGE_PULSE_PREP(X);
PAGE_PULSE_PREP(Y);
PAGE_PULSE_PREP(Z);
PAGE_PULSE_PREP(E);
TERN_(HAS_EXTRUDERS, PAGE_PULSE_PREP(E));
page_step_state.segment_steps++;
@@ -2103,13 +2103,15 @@ uint32_t Stepper::block_phase_isr() {
#endif
uint8_t axis_bits = 0;
if (X_MOVE_TEST) SBI(axis_bits, A_AXIS);
if (Y_MOVE_TEST) SBI(axis_bits, B_AXIS);
if (Z_MOVE_TEST) SBI(axis_bits, C_AXIS);
//if (!!current_block->steps.e) SBI(axis_bits, E_AXIS);
//if (!!current_block->steps.a) SBI(axis_bits, X_HEAD);
//if (!!current_block->steps.b) SBI(axis_bits, Y_HEAD);
//if (!!current_block->steps.c) SBI(axis_bits, Z_HEAD);
LINEAR_AXIS_CODE(
if (X_MOVE_TEST) SBI(axis_bits, A_AXIS),
if (Y_MOVE_TEST) SBI(axis_bits, B_AXIS),
if (Z_MOVE_TEST) SBI(axis_bits, C_AXIS)
);
//if (current_block->steps.e) SBI(axis_bits, E_AXIS);
//if (current_block->steps.a) SBI(axis_bits, X_HEAD);
//if (current_block->steps.b) SBI(axis_bits, Y_HEAD);
//if (current_block->steps.c) SBI(axis_bits, Z_HEAD);
axis_did_move = axis_bits;
// No acceleration / deceleration time elapsed so far
@@ -2606,9 +2608,13 @@ void Stepper::init() {
#endif
// Init direction bits for first moves
set_directions((INVERT_X_DIR ? _BV(X_AXIS) : 0)
| (INVERT_Y_DIR ? _BV(Y_AXIS) : 0)
| (INVERT_Z_DIR ? _BV(Z_AXIS) : 0));
set_directions(0
LINEAR_AXIS_GANG(
| TERN0(INVERT_X_DIR, _BV(X_AXIS)),
| TERN0(INVERT_Y_DIR, _BV(Y_AXIS)),
| TERN0(INVERT_Z_DIR, _BV(Z_AXIS))
)
);
#if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM
initialized = true;
@@ -2625,7 +2631,9 @@ void Stepper::init() {
* This allows get_axis_position_mm to correctly
* derive the current XYZ position later on.
*/
void Stepper::_set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
void Stepper::_set_position(
LOGICAL_AXIS_LIST(const int32_t &e, const int32_t &a, const int32_t &b, const int32_t &c)
) {
#if CORE_IS_XY
// corexy positioning
// these equations follow the form of the dA and dB equations on https://www.corexy.com/theory.html
@@ -2640,9 +2648,9 @@ void Stepper::_set_position(const int32_t &a, const int32_t &b, const int32_t &c
count_position.set(a - b, b, c);
#else
// default non-h-bot planning
count_position.set(a, b, c);
count_position.set(LINEAR_AXIS_LIST(a, b, c));
#endif
count_position.e = e;
TERN_(HAS_EXTRUDERS, count_position.e = e);
}
/**
@@ -2665,10 +2673,13 @@ int32_t Stepper::position(const AxisEnum axis) {
}
// Set the current position in steps
void Stepper::set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
//TODO: Test for LINEAR_AXES >= 4
void Stepper::set_position(
LOGICAL_AXIS_LIST(const int32_t &e, const int32_t &a, const int32_t &b, const int32_t &c)
) {
planner.synchronize();
const bool was_enabled = suspend();
_set_position(a, b, c, e);
_set_position(LOGICAL_AXIS_LIST(e, a, b, c));
if (was_enabled) wake_up();
}
@@ -2743,10 +2754,11 @@ void Stepper::report_a_position(const xyz_long_t &pos) {
SERIAL_ECHOPAIR_P(PSTR(STR_COUNT_X), pos.x, SP_Y_LBL, pos.y);
#endif
#if ANY(CORE_IS_XZ, CORE_IS_YZ, DELTA)
SERIAL_ECHOLNPAIR(" C:", pos.z);
#else
SERIAL_ECHOLNPAIR_P(SP_Z_LBL, pos.z);
SERIAL_ECHOPAIR(" C:", pos.z);
#elif LINEAR_AXES >= 3
SERIAL_ECHOPAIR_P(SP_Z_LBL, pos.z);
#endif
SERIAL_EOL();
}
void Stepper::report_positions() {
@@ -2903,7 +2915,7 @@ void Stepper::report_positions() {
DIR_WAIT_BEFORE();
const xyz_byte_t old_dir = { X_DIR_READ(), Y_DIR_READ(), Z_DIR_READ() };
const xyz_byte_t old_dir = LINEAR_AXIS_ARRAY(X_DIR_READ(), Y_DIR_READ(), Z_DIR_READ());
X_DIR_WRITE(INVERT_X_DIR ^ z_direction);
Y_DIR_WRITE(INVERT_Y_DIR ^ z_direction);