♻️ 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
@ -49,9 +49,11 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) {
|
||||
if (IsRunning()
|
||||
#if ENABLED(NO_MOTION_BEFORE_HOMING)
|
||||
&& !homing_needed_error(
|
||||
(parser.seen_test('X') ? _BV(X_AXIS) : 0)
|
||||
| (parser.seen_test('Y') ? _BV(Y_AXIS) : 0)
|
||||
| (parser.seen_test('Z') ? _BV(Z_AXIS) : 0) )
|
||||
LINEAR_AXIS_GANG(
|
||||
(parser.seen_test('X') ? _BV(X_AXIS) : 0),
|
||||
| (parser.seen_test('Y') ? _BV(Y_AXIS) : 0),
|
||||
| (parser.seen_test('Z') ? _BV(Z_AXIS) : 0))
|
||||
)
|
||||
#endif
|
||||
) {
|
||||
TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_RUNNING));
|
||||
@ -83,7 +85,7 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) {
|
||||
|
||||
if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
|
||||
// When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves
|
||||
if (fwretract.autoretract_enabled && parser.seen('E') && !parser.seen("XYZ")) {
|
||||
if (fwretract.autoretract_enabled && parser.seen_test('E') && !parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z"))) {
|
||||
const float echange = destination.e - current_position.e;
|
||||
// Is this a retract or recover move?
|
||||
if (WITHIN(ABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
|
||||
|
@ -109,23 +109,32 @@ void plan_arc(
|
||||
#endif
|
||||
}
|
||||
|
||||
float linear_travel = cart[l_axis] - start_L,
|
||||
extruder_travel = cart.e - current_position.e;
|
||||
float linear_travel = cart[l_axis] - start_L;
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
float extruder_travel = cart.e - current_position.e;
|
||||
#endif
|
||||
|
||||
// If circling around...
|
||||
if (ENABLED(ARC_P_CIRCLES) && circles) {
|
||||
const float total_angular = angular_travel + circles * RADIANS(360), // Total rotation with all circles and remainder
|
||||
part_per_circle = RADIANS(360) / total_angular, // Each circle's part of the total
|
||||
l_per_circle = linear_travel * part_per_circle, // L movement per circle
|
||||
e_per_circle = extruder_travel * part_per_circle; // E movement per circle
|
||||
l_per_circle = linear_travel * part_per_circle; // L movement per circle
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
const float e_per_circle = extruder_travel * part_per_circle; // E movement per circle
|
||||
#endif
|
||||
|
||||
xyze_pos_t temp_position = current_position; // for plan_arc to compare to current_position
|
||||
for (uint16_t n = circles; n--;) {
|
||||
temp_position.e += e_per_circle; // Destination E axis
|
||||
TERN_(HAS_EXTRUDERS, temp_position.e += e_per_circle); // Destination E axis
|
||||
temp_position[l_axis] += l_per_circle; // Destination L axis
|
||||
plan_arc(temp_position, offset, clockwise, 0); // Plan a single whole circle
|
||||
}
|
||||
linear_travel = cart[l_axis] - current_position[l_axis];
|
||||
extruder_travel = cart.e - current_position.e;
|
||||
#if HAS_EXTRUDERS
|
||||
extruder_travel = cart.e - current_position.e;
|
||||
#endif
|
||||
}
|
||||
|
||||
const float flat_mm = radius * angular_travel,
|
||||
@ -179,16 +188,19 @@ void plan_arc(
|
||||
xyze_pos_t raw;
|
||||
const float theta_per_segment = angular_travel / segments,
|
||||
linear_per_segment = linear_travel / segments,
|
||||
extruder_per_segment = extruder_travel / segments,
|
||||
sq_theta_per_segment = sq(theta_per_segment),
|
||||
sin_T = theta_per_segment - sq_theta_per_segment * theta_per_segment / 6,
|
||||
cos_T = 1 - 0.5f * sq_theta_per_segment; // Small angle approximation
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
const float extruder_per_segment = extruder_travel / segments;
|
||||
#endif
|
||||
|
||||
// Initialize the linear axis
|
||||
raw[l_axis] = current_position[l_axis];
|
||||
|
||||
// Initialize the extruder axis
|
||||
raw.e = current_position.e;
|
||||
TERN_(HAS_EXTRUDERS, raw.e = current_position.e);
|
||||
|
||||
#if ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
const float inv_duration = scaled_fr_mm_s / seg_length;
|
||||
@ -240,7 +252,8 @@ void plan_arc(
|
||||
#else
|
||||
raw[l_axis] += linear_per_segment;
|
||||
#endif
|
||||
raw.e += extruder_per_segment;
|
||||
|
||||
TERN_(HAS_EXTRUDERS, raw.e += extruder_per_segment);
|
||||
|
||||
apply_motion_limits(raw);
|
||||
|
||||
|
@ -87,7 +87,7 @@ void GcodeSuite::M290() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!parser.seen("XYZ") || parser.seen('R')) {
|
||||
if (!parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z")) || parser.seen('R')) {
|
||||
SERIAL_ECHO_START();
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
|
Reference in New Issue
Block a user