♻️ Refactor Linear / Logical / Distinct Axes (#21953)
* More patches supporting EXTRUDERS 0 * Extend types in prep for more axes
This commit is contained in:
committed by
Scott Lahteine
parent
f5f999d7bf
commit
4194cdda5b
@ -361,7 +361,8 @@ void Endstops::event_handler() {
|
||||
prev_hit_state = hit_state;
|
||||
if (hit_state) {
|
||||
#if HAS_STATUS_MESSAGE
|
||||
char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' ';
|
||||
char LINEAR_AXIS_LIST(chrX = ' ', chrY = ' ', chrZ = ' '),
|
||||
chrP = ' ';
|
||||
#define _SET_STOP_CHAR(A,C) (chr## A = C)
|
||||
#else
|
||||
#define _SET_STOP_CHAR(A,C) NOOP
|
||||
@ -390,7 +391,13 @@ void Endstops::event_handler() {
|
||||
#endif
|
||||
SERIAL_EOL();
|
||||
|
||||
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %c %c %c %c"), GET_TEXT(MSG_LCD_ENDSTOPS), chrX, chrY, chrZ, chrP));
|
||||
TERN_(HAS_STATUS_MESSAGE,
|
||||
ui.status_printf_P(0,
|
||||
PSTR(S_FMT GANG_N_1(LINEAR_AXES, " %c") " %c"),
|
||||
GET_TEXT(MSG_LCD_ENDSTOPS),
|
||||
LINEAR_AXIS_LIST(chrX, chrY, chrZ), chrP
|
||||
)
|
||||
);
|
||||
|
||||
#if BOTH(SD_ABORT_ON_ENDSTOP_HIT, SDSUPPORT)
|
||||
if (planner.abort_on_endstop_hit) {
|
||||
|
@ -89,7 +89,7 @@ bool relative_mode; // = false;
|
||||
#define Z_INIT_POS Z_HOME_POS
|
||||
#endif
|
||||
|
||||
xyze_pos_t current_position = { X_HOME_POS, Y_HOME_POS, Z_INIT_POS };
|
||||
xyze_pos_t current_position = LOGICAL_AXIS_ARRAY(0, X_HOME_POS, Y_HOME_POS, Z_INIT_POS);
|
||||
|
||||
/**
|
||||
* Cartesian Destination
|
||||
@ -195,16 +195,25 @@ inline void report_more_positions() {
|
||||
// Report the logical position for a given machine position
|
||||
inline void report_logical_position(const xyze_pos_t &rpos) {
|
||||
const xyze_pos_t lpos = rpos.asLogical();
|
||||
SERIAL_ECHOPAIR_P(X_LBL, lpos.x, SP_Y_LBL, lpos.y, SP_Z_LBL, lpos.z, SP_E_LBL, lpos.e);
|
||||
SERIAL_ECHOPAIR_P(
|
||||
LIST_N(DOUBLE(LINEAR_AXES), X_LBL, lpos.x, SP_Y_LBL, lpos.y, SP_Z_LBL, lpos.z)
|
||||
#if HAS_EXTRUDERS
|
||||
, SP_E_LBL, lpos.e
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
// Report the real current position according to the steppers.
|
||||
// Forward kinematics and un-leveling are applied.
|
||||
void report_real_position() {
|
||||
get_cartesian_from_steppers();
|
||||
xyze_pos_t npos = cartes;
|
||||
npos.e = planner.get_axis_position_mm(E_AXIS);
|
||||
xyze_pos_t npos = LOGICAL_AXIS_ARRAY(
|
||||
planner.get_axis_position_mm(E_AXIS),
|
||||
cartes.x, cartes.y, cartes.z
|
||||
);
|
||||
|
||||
TERN_(HAS_POSITION_MODIFIERS, planner.unapply_modifiers(npos, true));
|
||||
|
||||
report_logical_position(npos);
|
||||
report_more_positions();
|
||||
}
|
||||
@ -309,7 +318,9 @@ void sync_plan_position() {
|
||||
planner.set_position_mm(current_position);
|
||||
}
|
||||
|
||||
void sync_plan_position_e() { planner.set_e_position_mm(current_position.e); }
|
||||
#if HAS_EXTRUDERS
|
||||
void sync_plan_position_e() { planner.set_e_position_mm(current_position.e); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the stepper positions in the cartes[] array.
|
||||
@ -354,7 +365,10 @@ void get_cartesian_from_steppers() {
|
||||
void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
||||
get_cartesian_from_steppers();
|
||||
xyze_pos_t pos = cartes;
|
||||
pos.e = planner.get_axis_position_mm(E_AXIS);
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
pos.e = planner.get_axis_position_mm(E_AXIS);
|
||||
#endif
|
||||
|
||||
#if HAS_POSITION_MODIFIERS
|
||||
planner.unapply_modifiers(pos, true);
|
||||
@ -442,9 +456,12 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/
|
||||
* - Delta may lower Z first to get into the free motion zone.
|
||||
* - Before returning, wait for the planner buffer to empty.
|
||||
*/
|
||||
void do_blocking_move_to(const float rx, const float ry, const float rz, const_feedRate_t fr_mm_s/*=0.0*/) {
|
||||
void do_blocking_move_to(
|
||||
LINEAR_AXIS_LIST(const float rx, const float ry, const float rz),
|
||||
const_feedRate_t fr_mm_s/*=0.0f*/
|
||||
) {
|
||||
DEBUG_SECTION(log_move, "do_blocking_move_to", DEBUGGING(LEVELING));
|
||||
if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", rx, ry, rz);
|
||||
if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", LINEAR_AXIS_LIST(rx, ry, rz));
|
||||
|
||||
const feedRate_t z_feedrate = fr_mm_s ?: homing_feedrate(Z_AXIS),
|
||||
xy_feedrate = fr_mm_s ?: feedRate_t(XY_PROBE_FEEDRATE_MM_S);
|
||||
@ -529,34 +546,46 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const_f
|
||||
}
|
||||
|
||||
void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) {
|
||||
do_blocking_move_to(raw.x, raw.y, current_position.z, fr_mm_s);
|
||||
do_blocking_move_to(LINEAR_AXIS_LIST(raw.x, raw.y, current_position.z, current_position.i), fr_mm_s);
|
||||
}
|
||||
void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) {
|
||||
do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s);
|
||||
do_blocking_move_to(LINEAR_AXIS_LIST(raw.x, raw.y, raw.z), fr_mm_s);
|
||||
}
|
||||
void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) {
|
||||
do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s);
|
||||
do_blocking_move_to(LINEAR_AXIS_LIST(raw.x, raw.y, raw.z), fr_mm_s);
|
||||
}
|
||||
|
||||
void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) {
|
||||
do_blocking_move_to(rx, current_position.y, current_position.z, fr_mm_s);
|
||||
do_blocking_move_to(
|
||||
LINEAR_AXIS_LIST(rx, current_position.y, current_position.z),
|
||||
fr_mm_s
|
||||
);
|
||||
}
|
||||
void do_blocking_move_to_y(const_float_t ry, const_feedRate_t fr_mm_s/*=0.0*/) {
|
||||
do_blocking_move_to(current_position.x, ry, current_position.z, fr_mm_s);
|
||||
do_blocking_move_to(
|
||||
LINEAR_AXIS_LIST(current_position.x, ry, current_position.z),
|
||||
fr_mm_s
|
||||
);
|
||||
}
|
||||
void do_blocking_move_to_z(const_float_t rz, const_feedRate_t fr_mm_s/*=0.0*/) {
|
||||
do_blocking_move_to_xy_z(current_position, rz, fr_mm_s);
|
||||
}
|
||||
|
||||
void do_blocking_move_to_xy(const_float_t rx, const_float_t ry, const_feedRate_t fr_mm_s/*=0.0*/) {
|
||||
do_blocking_move_to(rx, ry, current_position.z, fr_mm_s);
|
||||
do_blocking_move_to(
|
||||
LINEAR_AXIS_LIST(rx, ry, current_position.z),
|
||||
fr_mm_s
|
||||
);
|
||||
}
|
||||
void do_blocking_move_to_xy(const xy_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) {
|
||||
do_blocking_move_to_xy(raw.x, raw.y, fr_mm_s);
|
||||
}
|
||||
|
||||
void do_blocking_move_to_xy_z(const xy_pos_t &raw, const_float_t z, const_feedRate_t fr_mm_s/*=0.0f*/) {
|
||||
do_blocking_move_to(raw.x, raw.y, z, fr_mm_s);
|
||||
do_blocking_move_to(
|
||||
LINEAR_AXIS_LIST(raw.x, raw.y, z),
|
||||
fr_mm_s
|
||||
);
|
||||
}
|
||||
|
||||
void do_z_clearance(const_float_t zclear, const bool lower_allowed/*=false*/) {
|
||||
@ -589,8 +618,8 @@ void restore_feedrate_and_scaling() {
|
||||
// Software Endstops are based on the configured limits.
|
||||
soft_endstops_t soft_endstop = {
|
||||
true, false,
|
||||
{ X_MIN_POS, Y_MIN_POS, Z_MIN_POS },
|
||||
{ X_MAX_POS, Y_MAX_POS, Z_MAX_POS }
|
||||
LINEAR_AXIS_ARRAY(X_MIN_POS, Y_MIN_POS, Z_MIN_POS),
|
||||
LINEAR_AXIS_ARRAY(X_MAX_BED, Y_MAX_BED, Z_MAX_POS)
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1176,9 +1205,12 @@ void prepare_line_to_destination() {
|
||||
if (TEST(b, a) && TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(a))
|
||||
CBI(b, a);
|
||||
};
|
||||
set_should(axis_bits, X_AXIS); // Clear test bits that are trusted
|
||||
set_should(axis_bits, Y_AXIS);
|
||||
set_should(axis_bits, Z_AXIS);
|
||||
// Clear test bits that are trusted
|
||||
LINEAR_AXIS_CODE(
|
||||
set_should(axis_bits, X_AXIS),
|
||||
set_should(axis_bits, Y_AXIS),
|
||||
set_should(axis_bits, Z_AXIS)
|
||||
);
|
||||
return axis_bits;
|
||||
}
|
||||
|
||||
@ -1187,9 +1219,11 @@ void prepare_line_to_destination() {
|
||||
PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
|
||||
char msg[strlen_P(home_first)+1];
|
||||
sprintf_P(msg, home_first,
|
||||
TEST(axis_bits, X_AXIS) ? "X" : "",
|
||||
TEST(axis_bits, Y_AXIS) ? "Y" : "",
|
||||
TEST(axis_bits, Z_AXIS) ? "Z" : ""
|
||||
LINEAR_AXIS_LIST(
|
||||
TEST(axis_bits, X_AXIS) ? "X" : "",
|
||||
TEST(axis_bits, Y_AXIS) ? "Y" : "",
|
||||
TEST(axis_bits, Z_AXIS) ? "Z" : ""
|
||||
)
|
||||
);
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOLN(msg);
|
||||
@ -1356,7 +1390,7 @@ void prepare_line_to_destination() {
|
||||
const feedRate_t home_fr_mm_s = fr_mm_s ?: homing_feedrate(axis);
|
||||
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
DEBUG_ECHOPAIR("...(", AS_CHAR(axis_codes[axis]), ", ", distance, ", ");
|
||||
DEBUG_ECHOPAIR("...(", AS_CHAR(AXIS_CHAR(axis)), ", ", distance, ", ");
|
||||
if (fr_mm_s)
|
||||
DEBUG_ECHO(fr_mm_s);
|
||||
else
|
||||
@ -1441,12 +1475,12 @@ void prepare_line_to_destination() {
|
||||
* "trusted" position).
|
||||
*/
|
||||
void set_axis_never_homed(const AxisEnum axis) {
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", AS_CHAR(axis_codes[axis]), ")");
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", AS_CHAR(AXIS_CHAR(axis)), ")");
|
||||
|
||||
set_axis_untrusted(axis);
|
||||
set_axis_unhomed(axis);
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", AS_CHAR(axis_codes[axis]), ")");
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", AS_CHAR(AXIS_CHAR(axis)), ")");
|
||||
|
||||
TERN_(I2C_POSITION_ENCODERS, I2CPEM.unhomed(axis));
|
||||
}
|
||||
@ -1507,7 +1541,7 @@ void prepare_line_to_destination() {
|
||||
if (ABS(phaseDelta) * planner.steps_to_mm[axis] / phasePerUStep < 0.05f)
|
||||
SERIAL_ECHOLNPAIR("Selected home phase ", home_phase[axis],
|
||||
" too close to endstop trigger phase ", phaseCurrent,
|
||||
". Pick a different phase for ", AS_CHAR(axis_codes[axis]));
|
||||
". Pick a different phase for ", AS_CHAR(AXIS_CHAR(axis)));
|
||||
|
||||
// Skip to next if target position is behind current. So it only moves away from endstop.
|
||||
if (phaseDelta < 0) phaseDelta += 1024;
|
||||
@ -1518,7 +1552,7 @@ void prepare_line_to_destination() {
|
||||
// Optional debug messages
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
DEBUG_ECHOLNPAIR(
|
||||
"Endstop ", AS_CHAR(axis_codes[axis]), " hit at Phase:", phaseCurrent,
|
||||
"Endstop ", AS_CHAR(AXIS_CHAR(axis)), " hit at Phase:", phaseCurrent,
|
||||
" Delta:", phaseDelta, " Distance:", mmDelta
|
||||
);
|
||||
}
|
||||
@ -1556,7 +1590,7 @@ void prepare_line_to_destination() {
|
||||
if (!_CAN_HOME(X) && !_CAN_HOME(Y) && !_CAN_HOME(Z)) return;
|
||||
#endif
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", AS_CHAR(axis_codes[axis]), ")");
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", AS_CHAR(AXIS_CHAR(axis)), ")");
|
||||
|
||||
const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS)
|
||||
? TOOL_X_HOME_DIR(active_extruder) : home_dir(axis);
|
||||
@ -1634,7 +1668,7 @@ void prepare_line_to_destination() {
|
||||
case Z_AXIS: es = Z_ENDSTOP; break;
|
||||
}
|
||||
if (TEST(endstops.state(), es)) {
|
||||
SERIAL_ECHO_MSG("Bad ", AS_CHAR(axis_codes[axis]), " Endstop?");
|
||||
SERIAL_ECHO_MSG("Bad ", AS_CHAR(AXIS_CHAR(axis)), " Endstop?");
|
||||
kill(GET_TEXT(MSG_KILL_HOMING_FAILED));
|
||||
}
|
||||
#endif
|
||||
@ -1856,7 +1890,7 @@ void prepare_line_to_destination() {
|
||||
if (axis == Z_AXIS) fwretract.current_hop = 0.0;
|
||||
#endif
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", AS_CHAR(axis_codes[axis]), ")");
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", AS_CHAR(AXIS_CHAR(axis)), ")");
|
||||
|
||||
} // homeaxis()
|
||||
|
||||
@ -1881,7 +1915,7 @@ void prepare_line_to_destination() {
|
||||
* Callers must sync the planner position after calling this!
|
||||
*/
|
||||
void set_axis_is_at_home(const AxisEnum axis) {
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")");
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", AS_CHAR(AXIS_CHAR(axis)), ")");
|
||||
|
||||
set_axis_trusted(axis);
|
||||
set_axis_homed(axis);
|
||||
@ -1931,10 +1965,10 @@ void set_axis_is_at_home(const AxisEnum axis) {
|
||||
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
#if HAS_HOME_OFFSET
|
||||
DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(axis_codes[axis]), "] = ", home_offset[axis]);
|
||||
DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(AXIS_CHAR(axis)), "] = ", home_offset[axis]);
|
||||
#endif
|
||||
DEBUG_POS("", current_position);
|
||||
DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")");
|
||||
DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", AS_CHAR(AXIS_CHAR(axis)), ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ inline int8_t pgm_read_any(const int8_t *p) { return TERN(__IMXRT1062__, *p, pgm
|
||||
|
||||
#define XYZ_DEFS(T, NAME, OPT) \
|
||||
inline T NAME(const AxisEnum axis) { \
|
||||
static const XYZval<T> NAME##_P DEFS_PROGMEM = { X_##OPT, Y_##OPT, Z_##OPT }; \
|
||||
static const XYZval<T> NAME##_P DEFS_PROGMEM = LINEAR_AXIS_ARRAY(X_##OPT, Y_##OPT, Z_##OPT); \
|
||||
return pgm_read_any(&NAME##_P[axis]); \
|
||||
}
|
||||
XYZ_DEFS(float, base_min_pos, MIN_POS);
|
||||
@ -264,7 +264,10 @@ void quickstop_stepper();
|
||||
* no kinematic translation. Used for homing axes and cartesian/core syncing.
|
||||
*/
|
||||
void sync_plan_position();
|
||||
void sync_plan_position_e();
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
void sync_plan_position_e();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Move the planner to the current position from wherever it last moved
|
||||
@ -295,7 +298,10 @@ inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f)
|
||||
/**
|
||||
* Blocking movement and shorthand functions
|
||||
*/
|
||||
void do_blocking_move_to(const float rx, const float ry, const float rz, const_feedRate_t fr_mm_s=0.0f);
|
||||
void do_blocking_move_to(
|
||||
LINEAR_AXIS_LIST(const float rx, const float ry, const float rz),
|
||||
const_feedRate_t fr_mm_s=0.0f
|
||||
);
|
||||
void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s=0.0f);
|
||||
void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s=0.0f);
|
||||
void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s=0.0f);
|
||||
@ -322,7 +328,7 @@ void do_z_clearance(const_float_t zclear, const bool lower_allowed=false);
|
||||
/**
|
||||
* Homing and Trusted Axes
|
||||
*/
|
||||
typedef IF<(LINEAR_AXES>8), uint16_t, uint8_t>::type linear_axis_bits_t;
|
||||
typedef IF<(LINEAR_AXES > 8), uint16_t, uint8_t>::type linear_axis_bits_t;
|
||||
constexpr linear_axis_bits_t linear_bits = _BV(LINEAR_AXES) - 1;
|
||||
|
||||
void set_axis_is_at_home(const AxisEnum axis);
|
||||
|
@ -1345,10 +1345,12 @@ void Planner::check_axes_activity() {
|
||||
#if ANY(DISABLE_X, DISABLE_Y, DISABLE_Z, DISABLE_E)
|
||||
for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) {
|
||||
block_t *block = &block_buffer[b];
|
||||
if (ENABLED(DISABLE_X) && block->steps.x) axis_active.x = true;
|
||||
if (ENABLED(DISABLE_Y) && block->steps.y) axis_active.y = true;
|
||||
if (ENABLED(DISABLE_Z) && block->steps.z) axis_active.z = true;
|
||||
if (ENABLED(DISABLE_E) && block->steps.e) axis_active.e = true;
|
||||
LOGICAL_AXIS_CODE(
|
||||
if (TERN0(DISABLE_E, block->steps.e)) axis_active.e = true,
|
||||
if (TERN0(DISABLE_X, block->steps.x)) axis_active.x = true,
|
||||
if (TERN0(DISABLE_Y, block->steps.y)) axis_active.y = true,
|
||||
if (TERN0(DISABLE_Z, block->steps.z)) axis_active.z = true
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1369,10 +1371,12 @@ void Planner::check_axes_activity() {
|
||||
//
|
||||
// Disable inactive axes
|
||||
//
|
||||
if (TERN0(DISABLE_X, !axis_active.x)) DISABLE_AXIS_X();
|
||||
if (TERN0(DISABLE_Y, !axis_active.y)) DISABLE_AXIS_Y();
|
||||
if (TERN0(DISABLE_Z, !axis_active.z)) DISABLE_AXIS_Z();
|
||||
if (TERN0(DISABLE_E, !axis_active.e)) disable_e_steppers();
|
||||
LOGICAL_AXIS_CODE(
|
||||
if (TERN0(DISABLE_E, !axis_active.e)) disable_e_steppers(),
|
||||
if (TERN0(DISABLE_X, !axis_active.x)) DISABLE_AXIS_X(),
|
||||
if (TERN0(DISABLE_Y, !axis_active.y)) DISABLE_AXIS_Y(),
|
||||
if (TERN0(DISABLE_Z, !axis_active.z)) DISABLE_AXIS_Z()
|
||||
);
|
||||
|
||||
//
|
||||
// Update Fan speeds
|
||||
@ -1823,16 +1827,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
|
||||
, feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
|
||||
) {
|
||||
|
||||
const int32_t da = target.a - position.a,
|
||||
db = target.b - position.b,
|
||||
dc = target.c - position.c;
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
int32_t de = target.e - position.e;
|
||||
#else
|
||||
constexpr int32_t de = 0;
|
||||
#endif
|
||||
int32_t LOGICAL_AXIS_LIST(
|
||||
de = target.e - position.e,
|
||||
da = target.a - position.a,
|
||||
db = target.b - position.b,
|
||||
dc = target.c - position.c
|
||||
);
|
||||
|
||||
/* <-- add a slash to enable
|
||||
SERIAL_ECHOLNPAIR(
|
||||
@ -1883,35 +1883,39 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
// Compute direction bit-mask for this block
|
||||
uint8_t dm = 0;
|
||||
#if CORE_IS_XY
|
||||
if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
||||
if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X
|
||||
if (db < 0) SBI(dm, Y_HEAD); // ...and Y
|
||||
if (dc < 0) SBI(dm, Z_AXIS);
|
||||
if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction
|
||||
if (CORESIGN(da - db) < 0) SBI(dm, B_AXIS); // Motor B direction
|
||||
#elif CORE_IS_XZ
|
||||
if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
||||
if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X
|
||||
if (db < 0) SBI(dm, Y_AXIS);
|
||||
if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
|
||||
if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction
|
||||
if (CORESIGN(da - dc) < 0) SBI(dm, C_AXIS); // Motor C direction
|
||||
#elif CORE_IS_YZ
|
||||
if (da < 0) SBI(dm, X_AXIS);
|
||||
if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
|
||||
if (db < 0) SBI(dm, Y_HEAD); // Save the toolhead's true direction in Y
|
||||
if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
|
||||
if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction
|
||||
if (CORESIGN(db - dc) < 0) SBI(dm, C_AXIS); // Motor C direction
|
||||
#elif ENABLED(MARKFORGED_XY)
|
||||
if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
||||
if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X
|
||||
if (db < 0) SBI(dm, Y_HEAD); // ...and Y
|
||||
if (dc < 0) SBI(dm, Z_AXIS);
|
||||
if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction
|
||||
if (db < 0) SBI(dm, B_AXIS); // Motor B direction
|
||||
#else
|
||||
if (da < 0) SBI(dm, X_AXIS);
|
||||
if (db < 0) SBI(dm, Y_AXIS);
|
||||
if (dc < 0) SBI(dm, Z_AXIS);
|
||||
LINEAR_AXIS_CODE(
|
||||
if (da < 0) SBI(dm, X_AXIS),
|
||||
if (db < 0) SBI(dm, Y_AXIS),
|
||||
if (dc < 0) SBI(dm, Z_AXIS)
|
||||
);
|
||||
#endif
|
||||
#if HAS_EXTRUDERS
|
||||
if (de < 0) SBI(dm, E_AXIS);
|
||||
#endif
|
||||
if (de < 0) SBI(dm, E_AXIS);
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
const float esteps_float = de * e_factor[extruder];
|
||||
@ -1947,7 +1951,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
block->steps.set(ABS(da), ABS(db), ABS(dc));
|
||||
#else
|
||||
// default non-h-bot planning
|
||||
block->steps.set(ABS(da), ABS(db), ABS(dc));
|
||||
block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db), ABS(dc)));
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -1990,41 +1994,51 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
steps_dist_mm.a = (da - db) * steps_to_mm[A_AXIS];
|
||||
steps_dist_mm.b = db * steps_to_mm[B_AXIS];
|
||||
#else
|
||||
steps_dist_mm.a = da * steps_to_mm[A_AXIS];
|
||||
steps_dist_mm.b = db * steps_to_mm[B_AXIS];
|
||||
steps_dist_mm.c = dc * steps_to_mm[C_AXIS];
|
||||
LINEAR_AXIS_CODE(
|
||||
steps_dist_mm.a = da * steps_to_mm[A_AXIS],
|
||||
steps_dist_mm.b = db * steps_to_mm[B_AXIS],
|
||||
steps_dist_mm.c = dc * steps_to_mm[C_AXIS]
|
||||
);
|
||||
#endif
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)];
|
||||
#else
|
||||
steps_dist_mm.e = 0.0f;
|
||||
#endif
|
||||
|
||||
TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator += steps_dist_mm.e);
|
||||
|
||||
if (block->steps.a < MIN_STEPS_PER_SEGMENT && block->steps.b < MIN_STEPS_PER_SEGMENT && block->steps.c < MIN_STEPS_PER_SEGMENT) {
|
||||
block->millimeters = (0
|
||||
#if HAS_EXTRUDERS
|
||||
+ ABS(steps_dist_mm.e)
|
||||
#endif
|
||||
);
|
||||
if (true LINEAR_AXIS_GANG(
|
||||
&& block->steps.a < MIN_STEPS_PER_SEGMENT,
|
||||
&& block->steps.b < MIN_STEPS_PER_SEGMENT,
|
||||
&& block->steps.c < MIN_STEPS_PER_SEGMENT
|
||||
)
|
||||
) {
|
||||
block->millimeters = TERN0(HAS_EXTRUDERS, ABS(steps_dist_mm.e));
|
||||
}
|
||||
else {
|
||||
if (millimeters)
|
||||
block->millimeters = millimeters;
|
||||
else
|
||||
else {
|
||||
block->millimeters = SQRT(
|
||||
#if EITHER(CORE_IS_XY, MARKFORGED_XY)
|
||||
sq(steps_dist_mm.head.x) + sq(steps_dist_mm.head.y) + sq(steps_dist_mm.z)
|
||||
LINEAR_AXIS_GANG(
|
||||
sq(steps_dist_mm.head.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.z)
|
||||
)
|
||||
#elif CORE_IS_XZ
|
||||
sq(steps_dist_mm.head.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.head.z)
|
||||
LINEAR_AXIS_GANG(
|
||||
sq(steps_dist_mm.head.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.head.z)
|
||||
)
|
||||
#elif CORE_IS_YZ
|
||||
sq(steps_dist_mm.x) + sq(steps_dist_mm.head.y) + sq(steps_dist_mm.head.z)
|
||||
LINEAR_AXIS_GANG(
|
||||
sq(steps_dist_mm.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.head.z)
|
||||
)
|
||||
#else
|
||||
sq(steps_dist_mm.x) + sq(steps_dist_mm.y) + sq(steps_dist_mm.z)
|
||||
LINEAR_AXIS_GANG(
|
||||
sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z)
|
||||
)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* At this point at least one of the axes has more steps than
|
||||
@ -2038,11 +2052,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
TERN_(BACKLASH_COMPENSATION, backlash.add_correction_steps(da, db, dc, dm, block));
|
||||
}
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
block->steps.e = esteps;
|
||||
#endif
|
||||
TERN_(HAS_EXTRUDERS, block->steps.e = esteps);
|
||||
|
||||
block->step_event_count = _MAX(block->steps.a, block->steps.b, block->steps.c, esteps);
|
||||
block->step_event_count = _MAX(LOGICAL_AXIS_LIST(
|
||||
esteps, block->steps.a, block->steps.b, block->steps.c
|
||||
));
|
||||
|
||||
// Bail if this is a zero-length block
|
||||
if (block->step_event_count < MIN_STEPS_PER_SEGMENT) return false;
|
||||
@ -2065,8 +2079,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_POWER_CONTROL)
|
||||
if (block->steps.x || block->steps.y || block->steps.z)
|
||||
powerManager.power_on();
|
||||
if (LINEAR_AXIS_GANG(
|
||||
block->steps.x,
|
||||
|| block->steps.y,
|
||||
|| block->steps.z
|
||||
)) powerManager.power_on();
|
||||
#endif
|
||||
|
||||
// Enable active axes
|
||||
@ -2091,11 +2108,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
}
|
||||
if (block->steps.x) ENABLE_AXIS_X();
|
||||
#else
|
||||
if (block->steps.x) ENABLE_AXIS_X();
|
||||
if (block->steps.y) ENABLE_AXIS_Y();
|
||||
#if DISABLED(Z_LATE_ENABLE)
|
||||
if (block->steps.z) ENABLE_AXIS_Z();
|
||||
#endif
|
||||
LINEAR_AXIS_CODE(
|
||||
if (block->steps.x) ENABLE_AXIS_X(),
|
||||
if (block->steps.y) ENABLE_AXIS_Y(),
|
||||
if (TERN(Z_LATE_ENABLE, 0, block->steps.z)) ENABLE_AXIS_Z()
|
||||
);
|
||||
#endif
|
||||
|
||||
// Enable extruder(s)
|
||||
@ -2283,7 +2300,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
// Compute and limit the acceleration rate for the trapezoid generator.
|
||||
const float steps_per_mm = block->step_event_count * inverse_millimeters;
|
||||
uint32_t accel;
|
||||
if (!block->steps.a && !block->steps.b && !block->steps.c) { // Is this a retract / recover move?
|
||||
if (LINEAR_AXIS_GANG(
|
||||
!block->steps.a, && !block->steps.b, && !block->steps.c
|
||||
)) { // Is this a retract / recover move?
|
||||
accel = CEIL(settings.retract_acceleration * steps_per_mm); // Convert to: acceleration steps/sec^2
|
||||
TERN_(LIN_ADVANCE, block->use_advance_lead = false); // No linear advance for simple retract/recover
|
||||
}
|
||||
@ -2348,16 +2367,20 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
|
||||
// Limit acceleration per axis
|
||||
if (block->step_event_count <= acceleration_long_cutoff) {
|
||||
LIMIT_ACCEL_LONG(A_AXIS, 0);
|
||||
LIMIT_ACCEL_LONG(B_AXIS, 0);
|
||||
LIMIT_ACCEL_LONG(C_AXIS, 0);
|
||||
LIMIT_ACCEL_LONG(E_AXIS, E_INDEX_N(extruder));
|
||||
LOGICAL_AXIS_CODE(
|
||||
LIMIT_ACCEL_LONG(E_AXIS, E_INDEX_N(extruder)),
|
||||
LIMIT_ACCEL_LONG(A_AXIS, 0),
|
||||
LIMIT_ACCEL_LONG(B_AXIS, 0),
|
||||
LIMIT_ACCEL_LONG(C_AXIS, 0)
|
||||
);
|
||||
}
|
||||
else {
|
||||
LIMIT_ACCEL_FLOAT(A_AXIS, 0);
|
||||
LIMIT_ACCEL_FLOAT(B_AXIS, 0);
|
||||
LIMIT_ACCEL_FLOAT(C_AXIS, 0);
|
||||
LIMIT_ACCEL_FLOAT(E_AXIS, E_INDEX_N(extruder));
|
||||
LOGICAL_AXIS_CODE(
|
||||
LIMIT_ACCEL_FLOAT(E_AXIS, E_INDEX_N(extruder)),
|
||||
LIMIT_ACCEL_FLOAT(A_AXIS, 0),
|
||||
LIMIT_ACCEL_FLOAT(B_AXIS, 0),
|
||||
LIMIT_ACCEL_FLOAT(C_AXIS, 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
block->acceleration_steps_per_s2 = accel;
|
||||
@ -2421,7 +2444,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
#if HAS_DIST_MM_ARG
|
||||
cart_dist_mm
|
||||
#else
|
||||
{ steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.e }
|
||||
LOGICAL_AXIS_ARRAY(steps_dist_mm.e, steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z)
|
||||
#endif
|
||||
;
|
||||
|
||||
@ -2440,8 +2463,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) {
|
||||
// Compute cosine of angle between previous and current path. (prev_unit_vec is negative)
|
||||
// NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity.
|
||||
float junction_cos_theta = (-prev_unit_vec.x * unit_vec.x) + (-prev_unit_vec.y * unit_vec.y)
|
||||
+ (-prev_unit_vec.z * unit_vec.z) + (-prev_unit_vec.e * unit_vec.e);
|
||||
float junction_cos_theta = LOGICAL_AXIS_GANG(
|
||||
+ (-prev_unit_vec.e * unit_vec.e),
|
||||
(-prev_unit_vec.x * unit_vec.x),
|
||||
+ (-prev_unit_vec.y * unit_vec.y),
|
||||
+ (-prev_unit_vec.z * unit_vec.z)
|
||||
);
|
||||
|
||||
// NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta).
|
||||
if (junction_cos_theta > 0.999999f) {
|
||||
@ -2756,7 +2783,8 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_
|
||||
*
|
||||
* Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc.
|
||||
*/
|
||||
bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e
|
||||
bool Planner::buffer_segment(
|
||||
LOGICAL_AXIS_LIST(const_float_t e, const_float_t a, const_float_t b, const_float_t c)
|
||||
OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
|
||||
, const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
|
||||
) {
|
||||
@ -2775,21 +2803,25 @@ bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c,
|
||||
// The target position of the tool in absolute steps
|
||||
// Calculate target position in absolute steps
|
||||
const abce_long_t target = {
|
||||
int32_t(LROUND(a * settings.axis_steps_per_mm[A_AXIS])),
|
||||
int32_t(LROUND(b * settings.axis_steps_per_mm[B_AXIS])),
|
||||
int32_t(LROUND(c * settings.axis_steps_per_mm[C_AXIS])),
|
||||
int32_t(LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(extruder)]))
|
||||
LOGICAL_AXIS_LIST(
|
||||
int32_t(LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(extruder)])),
|
||||
int32_t(LROUND(a * settings.axis_steps_per_mm[A_AXIS])),
|
||||
int32_t(LROUND(b * settings.axis_steps_per_mm[B_AXIS])),
|
||||
int32_t(LROUND(c * settings.axis_steps_per_mm[C_AXIS]))
|
||||
)
|
||||
};
|
||||
|
||||
#if HAS_POSITION_FLOAT
|
||||
const xyze_pos_t target_float = { a, b, c, e };
|
||||
const xyze_pos_t target_float = LOGICAL_AXIS_ARRAY(e, a, b, c);
|
||||
#endif
|
||||
|
||||
// DRYRUN prevents E moves from taking place
|
||||
if (DEBUGGING(DRYRUN) || TERN0(CANCEL_OBJECTS, cancelable.skipping)) {
|
||||
position.e = target.e;
|
||||
TERN_(HAS_POSITION_FLOAT, position_float.e = e);
|
||||
}
|
||||
#if HAS_EXTRUDERS
|
||||
// DRYRUN prevents E moves from taking place
|
||||
if (DEBUGGING(DRYRUN) || TERN0(CANCEL_OBJECTS, cancelable.skipping)) {
|
||||
position.e = target.e;
|
||||
TERN_(HAS_POSITION_FLOAT, position_float.e = e);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* <-- add a slash to enable
|
||||
SERIAL_ECHOPAIR(" buffer_segment FR:", fr_mm_s);
|
||||
@ -2848,10 +2880,12 @@ bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c,
|
||||
* millimeters - the length of the movement, if known
|
||||
* inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
|
||||
*/
|
||||
bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters
|
||||
bool Planner::buffer_line(
|
||||
LOGICAL_AXIS_LIST(const_float_t e, const_float_t rx, const_float_t ry, const_float_t rz)
|
||||
, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters
|
||||
OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration)
|
||||
) {
|
||||
xyze_pos_t machine = { rx, ry, rz, e };
|
||||
xyze_pos_t machine = LOGICAL_AXIS_ARRAY(e, rx, ry, rz);
|
||||
TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine));
|
||||
|
||||
#if IS_KINEMATIC
|
||||
@ -2914,16 +2948,12 @@ bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz,
|
||||
FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i];
|
||||
#endif
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
block->extruder = extruder;
|
||||
#endif
|
||||
TERN_(HAS_MULTI_EXTRUDER, block->extruder = extruder);
|
||||
|
||||
block->page_idx = page_idx;
|
||||
|
||||
block->step_event_count = num_steps;
|
||||
block->initial_rate =
|
||||
block->final_rate =
|
||||
block->nominal_rate = last_page_step_rate; // steps/s
|
||||
block->initial_rate = block->final_rate = block->nominal_rate = last_page_step_rate; // steps/s
|
||||
|
||||
block->accelerate_until = 0;
|
||||
block->decelerate_after = block->step_event_count;
|
||||
@ -2967,13 +2997,19 @@ bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz,
|
||||
* The provided ABC position is in machine units.
|
||||
*/
|
||||
|
||||
void Planner::set_machine_position_mm(const_float_t a, const_float_t b, const_float_t c, const_float_t e) {
|
||||
void Planner::set_machine_position_mm(
|
||||
LOGICAL_AXIS_LIST(const_float_t e, const_float_t a, const_float_t b, const_float_t c)
|
||||
) {
|
||||
TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder);
|
||||
TERN_(HAS_POSITION_FLOAT, position_float.set(a, b, c, e));
|
||||
position.set(LROUND(a * settings.axis_steps_per_mm[A_AXIS]),
|
||||
LROUND(b * settings.axis_steps_per_mm[B_AXIS]),
|
||||
LROUND(c * settings.axis_steps_per_mm[C_AXIS]),
|
||||
LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(active_extruder)]));
|
||||
TERN_(HAS_POSITION_FLOAT, position_float.set(LOGICAL_AXIS_LIST(e, a, b, c)));
|
||||
position.set(
|
||||
LOGICAL_AXIS_LIST(
|
||||
LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(active_extruder)]),
|
||||
LROUND(a * settings.axis_steps_per_mm[A_AXIS]),
|
||||
LROUND(b * settings.axis_steps_per_mm[B_AXIS]),
|
||||
LROUND(c * settings.axis_steps_per_mm[C_AXIS])
|
||||
)
|
||||
);
|
||||
if (has_blocks_queued()) {
|
||||
//previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest.
|
||||
//previous_speed.reset();
|
||||
@ -2983,11 +3019,11 @@ void Planner::set_machine_position_mm(const_float_t a, const_float_t b, const_fl
|
||||
stepper.set_position(position);
|
||||
}
|
||||
|
||||
void Planner::set_position_mm(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e) {
|
||||
xyze_pos_t machine = { rx, ry, rz, e };
|
||||
#if HAS_POSITION_MODIFIERS
|
||||
apply_modifiers(machine, true);
|
||||
#endif
|
||||
void Planner::set_position_mm(
|
||||
LOGICAL_AXIS_LIST(const_float_t e, const_float_t rx, const_float_t ry, const_float_t rz)
|
||||
) {
|
||||
xyze_pos_t machine = LOGICAL_AXIS_ARRAY(e, rx, ry, rz);
|
||||
TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine, true));
|
||||
#if IS_KINEMATIC
|
||||
position_cart.set(rx, ry, rz, e);
|
||||
inverse_kinematics(machine);
|
||||
@ -2997,23 +3033,27 @@ void Planner::set_position_mm(const_float_t rx, const_float_t ry, const_float_t
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Setters for planner position (also setting stepper position).
|
||||
*/
|
||||
void Planner::set_e_position_mm(const_float_t e) {
|
||||
const uint8_t axis_index = E_AXIS_N(active_extruder);
|
||||
TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder);
|
||||
#if HAS_EXTRUDERS
|
||||
|
||||
const float e_new = DIFF_TERN(FWRETRACT, e, fwretract.current_retract[active_extruder]);
|
||||
position.e = LROUND(settings.axis_steps_per_mm[axis_index] * e_new);
|
||||
TERN_(HAS_POSITION_FLOAT, position_float.e = e_new);
|
||||
TERN_(IS_KINEMATIC, position_cart.e = e);
|
||||
/**
|
||||
* Setters for planner position (also setting stepper position).
|
||||
*/
|
||||
void Planner::set_e_position_mm(const_float_t e) {
|
||||
const uint8_t axis_index = E_AXIS_N(active_extruder);
|
||||
TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder);
|
||||
|
||||
if (has_blocks_queued())
|
||||
buffer_sync_block();
|
||||
else
|
||||
stepper.set_axis_position(E_AXIS, position.e);
|
||||
}
|
||||
const float e_new = DIFF_TERN(FWRETRACT, e, fwretract.current_retract[active_extruder]);
|
||||
position.e = LROUND(settings.axis_steps_per_mm[axis_index] * e_new);
|
||||
TERN_(HAS_POSITION_FLOAT, position_float.e = e_new);
|
||||
TERN_(IS_KINEMATIC, position_cart.e = e);
|
||||
|
||||
if (has_blocks_queued())
|
||||
buffer_sync_block();
|
||||
else
|
||||
stepper.set_axis_position(E_AXIS, position.e);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
|
||||
void Planner::reset_acceleration_rates() {
|
||||
@ -3043,11 +3083,11 @@ void Planner::refresh_positioning() {
|
||||
|
||||
// Apply limits to a variable and give a warning if the value was out of range
|
||||
inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_name, const xyze_float_t &max_limit) {
|
||||
const uint8_t lim_axis = axis > E_AXIS ? E_AXIS : axis;
|
||||
const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis;
|
||||
const float before = val;
|
||||
LIMIT(val, 0.1, max_limit[lim_axis]);
|
||||
if (before != val) {
|
||||
SERIAL_CHAR(axis_codes[lim_axis]);
|
||||
SERIAL_CHAR(AXIS_CHAR(lim_axis));
|
||||
SERIAL_ECHOPGM(" Max ");
|
||||
SERIAL_ECHOPGM_P(setting_name);
|
||||
SERIAL_ECHOLNPAIR(" limited to ", val);
|
||||
|
@ -76,7 +76,7 @@
|
||||
// Feedrate for manual moves
|
||||
#ifdef MANUAL_FEEDRATE
|
||||
constexpr xyze_feedrate_t _mf = MANUAL_FEEDRATE,
|
||||
manual_feedrate_mm_s { _mf.x / 60.0f, _mf.y / 60.0f, _mf.z / 60.0f, _mf.e / 60.0f };
|
||||
manual_feedrate_mm_s = LOGICAL_AXIS_ARRAY(_mf.e / 60.0f, _mf.x / 60.0f, _mf.y / 60.0f, _mf.z / 60.0f);
|
||||
#endif
|
||||
|
||||
#if IS_KINEMATIC && HAS_JUNCTION_DEVIATION
|
||||
@ -758,7 +758,8 @@ class Planner {
|
||||
* extruder - target extruder
|
||||
* millimeters - the length of the movement, if known
|
||||
*/
|
||||
static bool buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e
|
||||
static bool buffer_segment(
|
||||
LOGICAL_AXIS_LIST(const_float_t e, const_float_t a, const_float_t b, const_float_t c)
|
||||
OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
|
||||
, const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
|
||||
);
|
||||
@ -767,9 +768,11 @@ class Planner {
|
||||
OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
|
||||
, const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
|
||||
) {
|
||||
return buffer_segment(abce.a, abce.b, abce.c, abce.e
|
||||
return buffer_segment(
|
||||
LOGICAL_AXIS_LIST(abce.e, abce.a, abce.b, abce.c)
|
||||
OPTARG(HAS_DIST_MM_ARG, cart_dist_mm)
|
||||
, fr_mm_s, extruder, millimeters);
|
||||
, fr_mm_s, extruder, millimeters
|
||||
);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -785,14 +788,18 @@ class Planner {
|
||||
* millimeters - the length of the movement, if known
|
||||
* inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
|
||||
*/
|
||||
static bool buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0
|
||||
static bool buffer_line(
|
||||
LOGICAL_AXIS_LIST(const_float_t e, const_float_t rx, const_float_t ry, const_float_t rz)
|
||||
, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0
|
||||
OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0)
|
||||
);
|
||||
|
||||
FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0
|
||||
OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0)
|
||||
) {
|
||||
return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters
|
||||
return buffer_line(
|
||||
LOGICAL_AXIS_LIST(cart.e, cart.x, cart.y, cart.z)
|
||||
, fr_mm_s, extruder, millimeters
|
||||
OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
|
||||
);
|
||||
}
|
||||
@ -814,9 +821,16 @@ class Planner {
|
||||
*
|
||||
* Clears previous speed values.
|
||||
*/
|
||||
static void set_position_mm(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e);
|
||||
FORCE_INLINE static void set_position_mm(const xyze_pos_t &cart) { set_position_mm(cart.x, cart.y, cart.z, cart.e); }
|
||||
static void set_e_position_mm(const_float_t e);
|
||||
static void set_position_mm(
|
||||
LOGICAL_AXIS_LIST(const_float_t e, const_float_t rx, const_float_t ry, const_float_t rz)
|
||||
);
|
||||
FORCE_INLINE static void set_position_mm(const xyze_pos_t &cart) {
|
||||
set_position_mm(LOGICAL_AXIS_LIST(cart.e, cart.x, cart.y, cart.z, cart.i, cart.j, cart.k));
|
||||
}
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
static void set_e_position_mm(const_float_t e);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the planner.position and individual stepper positions.
|
||||
@ -824,8 +838,12 @@ class Planner {
|
||||
* The supplied position is in machine space, and no additional
|
||||
* conversions are applied.
|
||||
*/
|
||||
static void set_machine_position_mm(const_float_t a, const_float_t b, const_float_t c, const_float_t e);
|
||||
FORCE_INLINE static void set_machine_position_mm(const abce_pos_t &abce) { set_machine_position_mm(abce.a, abce.b, abce.c, abce.e); }
|
||||
static void set_machine_position_mm(
|
||||
LOGICAL_AXIS_LIST(const_float_t e, const_float_t a, const_float_t b, const_float_t c)
|
||||
);
|
||||
FORCE_INLINE static void set_machine_position_mm(const abce_pos_t &abce) {
|
||||
set_machine_position_mm(LOGICAL_AXIS_LIST(abce.e, abce.a, abce.b, abce.c));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an axis position according to stepper position(s)
|
||||
@ -834,12 +852,10 @@ class Planner {
|
||||
static float get_axis_position_mm(const AxisEnum axis);
|
||||
|
||||
static inline abce_pos_t get_axis_positions_mm() {
|
||||
const abce_pos_t out = {
|
||||
get_axis_position_mm(A_AXIS),
|
||||
get_axis_position_mm(B_AXIS),
|
||||
get_axis_position_mm(C_AXIS),
|
||||
get_axis_position_mm(E_AXIS)
|
||||
};
|
||||
const abce_pos_t out = LOGICAL_AXIS_ARRAY(
|
||||
get_axis_position_mm(E_AXIS),
|
||||
get_axis_position_mm(A_AXIS), get_axis_position_mm(B_AXIS), get_axis_position_mm(C_AXIS)
|
||||
);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -168,10 +168,10 @@
|
||||
void M554_report();
|
||||
#endif
|
||||
|
||||
typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stepper_current_t;
|
||||
typedef struct { uint32_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_hybrid_threshold_t;
|
||||
typedef struct { int16_t X, Y, Z, X2, Y2, Z2, Z3, Z4; } tmc_sgt_t;
|
||||
typedef struct { bool X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stealth_enabled_t;
|
||||
typedef struct { uint16_t LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stepper_current_t;
|
||||
typedef struct { uint32_t LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_hybrid_threshold_t;
|
||||
typedef struct { int16_t LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4; } tmc_sgt_t;
|
||||
typedef struct { bool LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stealth_enabled_t;
|
||||
|
||||
// Limit an index to an array size
|
||||
#define ALIM(I,ARR) _MIN(I, (signed)COUNT(ARR) - 1)
|
||||
@ -654,7 +654,7 @@ void MarlinSettings::postprocess() {
|
||||
EEPROM_WRITE(dummyf);
|
||||
#endif
|
||||
#else
|
||||
const xyze_pos_t planner_max_jerk = { 10, 10, 0.4, float(DEFAULT_EJERK) };
|
||||
const xyze_pos_t planner_max_jerk = LOGICAL_AXIS_ARRAY(float(DEFAULT_EJERK), 10, 10, 0.4);
|
||||
EEPROM_WRITE(planner_max_jerk);
|
||||
#endif
|
||||
|
||||
@ -1188,10 +1188,10 @@ void MarlinSettings::postprocess() {
|
||||
#endif
|
||||
#else
|
||||
const tmc_hybrid_threshold_t tmc_hybrid_threshold = {
|
||||
.X = 100, .Y = 100, .Z = 3,
|
||||
LINEAR_AXIS_LIST(.X = 100, .Y = 100, .Z = 3),
|
||||
.X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3,
|
||||
.E0 = 30, .E1 = 30, .E2 = 30,
|
||||
.E3 = 30, .E4 = 30, .E5 = 30
|
||||
.E0 = 30, .E1 = 30, .E2 = 30, .E3 = 30,
|
||||
.E4 = 30, .E5 = 30, .E6 = 30, .E7 = 30
|
||||
};
|
||||
#endif
|
||||
EEPROM_WRITE(tmc_hybrid_threshold);
|
||||
@ -2604,7 +2604,7 @@ void MarlinSettings::reset() {
|
||||
#ifndef DEFAULT_ZJERK
|
||||
#define DEFAULT_ZJERK 0
|
||||
#endif
|
||||
planner.max_jerk.set(DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK);
|
||||
planner.max_jerk.set(LINEAR_AXIS_LIST(DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK));
|
||||
TERN_(HAS_CLASSIC_E_JERK, planner.max_jerk.e = DEFAULT_EJERK;);
|
||||
#endif
|
||||
|
||||
@ -3142,10 +3142,12 @@ void MarlinSettings::reset() {
|
||||
CONFIG_ECHO_HEADING("Maximum feedrates (units/s):");
|
||||
CONFIG_ECHO_START();
|
||||
SERIAL_ECHOLNPAIR_P(
|
||||
PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS])
|
||||
, SP_Y_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Y_AXIS])
|
||||
, SP_Z_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Z_AXIS])
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
LIST_N(DOUBLE(LINEAR_AXES),
|
||||
PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS]),
|
||||
SP_Y_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Y_AXIS]),
|
||||
SP_Z_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Z_AXIS])
|
||||
)
|
||||
#if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS)
|
||||
, SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS])
|
||||
#endif
|
||||
);
|
||||
@ -3162,10 +3164,12 @@ void MarlinSettings::reset() {
|
||||
CONFIG_ECHO_HEADING("Maximum Acceleration (units/s2):");
|
||||
CONFIG_ECHO_START();
|
||||
SERIAL_ECHOLNPAIR_P(
|
||||
PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS])
|
||||
, SP_Y_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Y_AXIS])
|
||||
, SP_Z_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Z_AXIS])
|
||||
#if DISABLED(DISTINCT_E_FACTORS)
|
||||
LIST_N(DOUBLE(LINEAR_AXES),
|
||||
PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]),
|
||||
SP_Y_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Y_AXIS]),
|
||||
SP_Z_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Z_AXIS])
|
||||
)
|
||||
#if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS)
|
||||
, SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS])
|
||||
#endif
|
||||
);
|
||||
@ -3894,9 +3898,11 @@ void MarlinSettings::reset() {
|
||||
CONFIG_ECHO_START();
|
||||
SERIAL_ECHOLNPAIR_P(
|
||||
PSTR(" M425 F"), backlash.get_correction()
|
||||
, SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x)
|
||||
, SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y)
|
||||
, SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z)
|
||||
, LIST_N(DOUBLE(LINEAR_AXES),
|
||||
SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x),
|
||||
SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y),
|
||||
SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z)
|
||||
)
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
, PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm)
|
||||
#endif
|
||||
|
@ -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);
|
||||
|
@ -433,8 +433,12 @@ class Stepper {
|
||||
static int32_t position(const AxisEnum axis);
|
||||
|
||||
// Set the current position in steps
|
||||
static void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e);
|
||||
static inline void set_position(const xyze_long_t &abce) { set_position(abce.a, abce.b, abce.c, abce.e); }
|
||||
static void set_position(
|
||||
LOGICAL_AXIS_LIST(const int32_t &e, const int32_t &a, const int32_t &b, const int32_t &c)
|
||||
);
|
||||
static inline void set_position(const xyze_long_t &abce) {
|
||||
set_position(LOGICAL_AXIS_LIST(abce.e, abce.a, abce.b, abce.c));
|
||||
}
|
||||
static void set_axis_position(const AxisEnum a, const int32_t &v);
|
||||
|
||||
// Report the positions of the steppers, in steps
|
||||
@ -530,8 +534,12 @@ class Stepper {
|
||||
private:
|
||||
|
||||
// Set the current position in steps
|
||||
static void _set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e);
|
||||
FORCE_INLINE static void _set_position(const abce_long_t &spos) { _set_position(spos.a, spos.b, spos.c, spos.e); }
|
||||
static void _set_position(
|
||||
LOGICAL_AXIS_LIST(const int32_t &e, const int32_t &a, const int32_t &b, const int32_t &c)
|
||||
);
|
||||
FORCE_INLINE static void _set_position(const abce_long_t &spos) {
|
||||
_set_position(LOGICAL_AXIS_LIST(spos.e, spos.a, spos.b, spos.c));
|
||||
}
|
||||
|
||||
FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t *loops) {
|
||||
uint32_t timer;
|
||||
|
@ -35,7 +35,9 @@
|
||||
#include <HardwareSerial.h>
|
||||
#include <SPI.h>
|
||||
|
||||
enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
||||
enum StealthIndex : uint8_t {
|
||||
LOGICAL_AXIS_LIST(STEALTH_AXIS_E, STEALTH_AXIS_X, STEALTH_AXIS_Y, STEALTH_AXIS_Z)
|
||||
};
|
||||
#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE)
|
||||
|
||||
// IC = TMC model number
|
||||
@ -400,7 +402,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum TMCAxis : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7, TOTAL };
|
||||
enum TMCAxis : uint8_t { LINEAR_AXIS_LIST(X, Y, Z), X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7, TOTAL };
|
||||
|
||||
void tmc_serial_begin() {
|
||||
#if HAS_TMC_HW_SERIAL
|
||||
@ -765,19 +767,24 @@ void restore_trinamic_drivers() {
|
||||
}
|
||||
|
||||
void reset_trinamic_drivers() {
|
||||
static constexpr bool stealthchop_by_axis[] = { ENABLED(STEALTHCHOP_XY), ENABLED(STEALTHCHOP_Z), ENABLED(STEALTHCHOP_E) };
|
||||
static constexpr bool stealthchop_by_axis[] = LOGICAL_AXIS_ARRAY(
|
||||
ENABLED(STEALTHCHOP_E),
|
||||
ENABLED(STEALTHCHOP_XY),
|
||||
ENABLED(STEALTHCHOP_XY),
|
||||
ENABLED(STEALTHCHOP_Z)
|
||||
);
|
||||
|
||||
#if AXIS_IS_TMC(X)
|
||||
TMC_INIT(X, STEALTH_AXIS_XY);
|
||||
TMC_INIT(X, STEALTH_AXIS_X);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
TMC_INIT(X2, STEALTH_AXIS_XY);
|
||||
TMC_INIT(X2, STEALTH_AXIS_X);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y)
|
||||
TMC_INIT(Y, STEALTH_AXIS_XY);
|
||||
TMC_INIT(Y, STEALTH_AXIS_Y);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
TMC_INIT(Y2, STEALTH_AXIS_XY);
|
||||
TMC_INIT(Y2, STEALTH_AXIS_Y);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z)
|
||||
TMC_INIT(Z, STEALTH_AXIS_Z);
|
||||
@ -841,7 +848,7 @@ void reset_trinamic_drivers() {
|
||||
stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY));
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif // USE SENSORLESS
|
||||
|
||||
#ifdef TMC_ADV
|
||||
TMC_ADV()
|
||||
|
Reference in New Issue
Block a user