Refactor and optimize Stepper/Planner
This commit is contained in:
parent
38e1823375
commit
8f26c3a6d3
11 changed files with 991 additions and 792 deletions
|
|
@ -8474,7 +8474,7 @@ inline void gcode_M111() {
|
|||
*/
|
||||
inline void gcode_M81() {
|
||||
thermalManager.disable_all_heaters();
|
||||
stepper.finish_and_disable();
|
||||
planner.finish_and_disable();
|
||||
|
||||
#if FAN_COUNT > 0
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
|
||||
|
|
@ -8517,7 +8517,7 @@ inline void gcode_M18_M84() {
|
|||
else {
|
||||
bool all_axis = !(parser.seen('X') || parser.seen('Y') || parser.seen('Z') || parser.seen('E'));
|
||||
if (all_axis) {
|
||||
stepper.finish_and_disable();
|
||||
planner.finish_and_disable();
|
||||
}
|
||||
else {
|
||||
planner.synchronize();
|
||||
|
|
@ -9963,7 +9963,7 @@ inline void gcode_M400() { planner.synchronize(); }
|
|||
#endif // FILAMENT_WIDTH_SENSOR
|
||||
|
||||
void quickstop_stepper() {
|
||||
stepper.quick_stop();
|
||||
planner.quick_stop();
|
||||
planner.synchronize();
|
||||
set_current_from_steppers_for_axis(ALL_AXES);
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
|
|
@ -10342,7 +10342,7 @@ inline void gcode_M502() {
|
|||
* M540: Set whether SD card print should abort on endstop hit (M540 S<0|1>)
|
||||
*/
|
||||
inline void gcode_M540() {
|
||||
if (parser.seen('S')) stepper.abort_on_endstop_hit = parser.value_bool();
|
||||
if (parser.seen('S')) planner.abort_on_endstop_hit = parser.value_bool();
|
||||
}
|
||||
|
||||
#endif // ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
||||
|
|
@ -12995,7 +12995,8 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
idle();
|
||||
}
|
||||
LOOP_XYZE(i) raw[i] += segment_distance[i];
|
||||
planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder, cartesian_segment_mm);
|
||||
if (!planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder, cartesian_segment_mm))
|
||||
break;
|
||||
}
|
||||
|
||||
// Since segment_distance is only approximate,
|
||||
|
|
@ -13281,7 +13282,8 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
#if ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
// For SCARA scale the feed rate from mm/s to degrees/s
|
||||
// i.e., Complete the angular vector in the given time.
|
||||
planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder);
|
||||
if (!planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder))
|
||||
break;
|
||||
/*
|
||||
SERIAL_ECHO(segments);
|
||||
SERIAL_ECHOPAIR(": X=", raw[X_AXIS]); SERIAL_ECHOPAIR(" Y=", raw[Y_AXIS]);
|
||||
|
|
@ -13291,7 +13293,8 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
//*/
|
||||
oldA = delta[A_AXIS]; oldB = delta[B_AXIS];
|
||||
#else
|
||||
planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], _feedrate_mm_s, active_extruder, cartesian_segment_mm);
|
||||
if (!planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], _feedrate_mm_s, active_extruder, cartesian_segment_mm))
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -13385,14 +13388,14 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
}
|
||||
// unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
planner.buffer_line(
|
||||
if (!planner.buffer_line(
|
||||
i == 0 ? raised_parked_position[X_AXIS] : current_position[X_AXIS],
|
||||
i == 0 ? raised_parked_position[Y_AXIS] : current_position[Y_AXIS],
|
||||
i == 2 ? current_position[Z_AXIS] : raised_parked_position[Z_AXIS],
|
||||
current_position[E_AXIS],
|
||||
i == 1 ? PLANNER_XY_FEEDRATE() : planner.max_feedrate_mm_s[Z_AXIS],
|
||||
active_extruder
|
||||
);
|
||||
active_extruder)
|
||||
) break;
|
||||
delayed_move_time = 0;
|
||||
active_extruder_parked = false;
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
|
|
@ -13409,17 +13412,12 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
}
|
||||
#endif
|
||||
// move duplicate extruder into correct duplication position.
|
||||
planner.set_position_mm(
|
||||
inactive_extruder_x_pos,
|
||||
current_position[Y_AXIS],
|
||||
current_position[Z_AXIS],
|
||||
current_position[E_AXIS]
|
||||
);
|
||||
planner.buffer_line(
|
||||
planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
if (!planner.buffer_line(
|
||||
current_position[X_AXIS] + duplicate_extruder_x_offset,
|
||||
current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS],
|
||||
planner.max_feedrate_mm_s[X_AXIS], 1
|
||||
);
|
||||
planner.max_feedrate_mm_s[X_AXIS], 1)
|
||||
) break;
|
||||
planner.synchronize();
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
extruder_duplication_enabled = true;
|
||||
|
|
@ -13652,14 +13650,17 @@ void prepare_move_to_destination() {
|
|||
// i.e., Complete the angular vector in the given time.
|
||||
inverse_kinematics(raw);
|
||||
ADJUST_DELTA(raw);
|
||||
planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder);
|
||||
if (!planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder))
|
||||
break;
|
||||
oldA = delta[A_AXIS]; oldB = delta[B_AXIS];
|
||||
#elif HAS_UBL_AND_CURVES
|
||||
float pos[XYZ] = { raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS] };
|
||||
planner.apply_leveling(pos);
|
||||
planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], raw[E_AXIS], fr_mm_s, active_extruder);
|
||||
if (!planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], raw[E_AXIS], fr_mm_s, active_extruder))
|
||||
break;
|
||||
#else
|
||||
planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder);
|
||||
if (!planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder))
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue