Move Stepper::synchronize to Planner (#10713)

Co-Authored-By: ejtagle <ejtagle@hotmail.com>
This commit is contained in:
Scott Lahteine 2018-05-12 01:38:02 -05:00 committed by GitHub
parent f2e3c9896e
commit 306f0f2135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 72 additions and 73 deletions

View File

@ -274,7 +274,7 @@ bool pin_is_protected(const pin_t pin) {
void quickstop_stepper() { void quickstop_stepper() {
stepper.quick_stop(); stepper.quick_stop();
stepper.synchronize(); planner.synchronize();
set_current_from_steppers_for_axis(ALL_AXES); set_current_from_steppers_for_axis(ALL_AXES);
SYNC_PLAN_POSITION_KINEMATIC(); SYNC_PLAN_POSITION_KINEMATIC();
} }
@ -461,7 +461,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
planner.buffer_line_kinematic(current_position, MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED), active_extruder); planner.buffer_line_kinematic(current_position, MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED), active_extruder);
current_position[E_AXIS] = olde; current_position[E_AXIS] = olde;
planner.set_e_position_mm(olde); planner.set_e_position_mm(olde);
stepper.synchronize(); planner.synchronize();
#if ENABLED(SWITCHING_EXTRUDER) #if ENABLED(SWITCHING_EXTRUDER)
E0_ENABLE_WRITE(oldstatus); E0_ENABLE_WRITE(oldstatus);
#else #else

View File

@ -356,11 +356,11 @@ bool I2CPositionEncoder::test_axis() {
startCoord[encoderAxis] = startPosition; startCoord[encoderAxis] = startPosition;
endCoord[encoderAxis] = endPosition; endCoord[encoderAxis] = endPosition;
stepper.synchronize(); planner.synchronize();
planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS], planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
stepper.get_axis_position_mm(E_AXIS), feedrate, 0); stepper.get_axis_position_mm(E_AXIS), feedrate, 0);
stepper.synchronize(); planner.synchronize();
// if the module isn't currently trusted, wait until it is (or until it should be if things are working) // if the module isn't currently trusted, wait until it is (or until it should be if things are working)
if (!trusted) { if (!trusted) {
@ -372,7 +372,7 @@ bool I2CPositionEncoder::test_axis() {
if (trusted) { // if trusted, commence test if (trusted) { // if trusted, commence test
planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS], planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
stepper.get_axis_position_mm(E_AXIS), feedrate, 0); stepper.get_axis_position_mm(E_AXIS), feedrate, 0);
stepper.synchronize(); planner.synchronize();
} }
return trusted; return trusted;
@ -415,12 +415,12 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
startCoord[encoderAxis] = startDistance; startCoord[encoderAxis] = startDistance;
endCoord[encoderAxis] = endDistance; endCoord[encoderAxis] = endDistance;
stepper.synchronize(); planner.synchronize();
LOOP_L_N(i, iter) { LOOP_L_N(i, iter) {
planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS], planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
stepper.get_axis_position_mm(E_AXIS), feedrate, 0); stepper.get_axis_position_mm(E_AXIS), feedrate, 0);
stepper.synchronize(); planner.synchronize();
delay(250); delay(250);
startCount = get_position(); startCount = get_position();
@ -429,7 +429,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS], planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
stepper.get_axis_position_mm(E_AXIS), feedrate, 0); stepper.get_axis_position_mm(E_AXIS), feedrate, 0);
stepper.synchronize(); planner.synchronize();
//Read encoder distance //Read encoder distance
delay(250); delay(250);

View File

@ -797,7 +797,7 @@
do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height); do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
//, min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0); //, min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0);
stepper.synchronize(); planner.synchronize();
SERIAL_PROTOCOLPGM("Place shim under nozzle"); SERIAL_PROTOCOLPGM("Place shim under nozzle");
LCD_MESSAGEPGM(MSG_UBL_BC_INSERT); LCD_MESSAGEPGM(MSG_UBL_BC_INSERT);
@ -806,7 +806,7 @@
const float z1 = measure_point_with_encoder(); const float z1 = measure_point_with_encoder();
do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE); do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
stepper.synchronize(); planner.synchronize();
SERIAL_PROTOCOLPGM("Remove shim"); SERIAL_PROTOCOLPGM("Remove shim");
LCD_MESSAGEPGM(MSG_UBL_BC_REMOVE); LCD_MESSAGEPGM(MSG_UBL_BC_REMOVE);

View File

@ -122,7 +122,7 @@ static void do_pause_e_move(const float &length, const float &fr) {
destination[E_AXIS] += length / planner.e_factor[active_extruder]; destination[E_AXIS] += length / planner.e_factor[active_extruder];
planner.buffer_line_kinematic(destination, fr, active_extruder); planner.buffer_line_kinematic(destination, fr, active_extruder);
set_current_from_destination(); set_current_from_destination();
stepper.synchronize(); planner.synchronize();
} }
/** /**
@ -370,7 +370,7 @@ bool pause_print(const float &retract, const point_t &park_point, const float &u
COPY(resume_position, current_position); COPY(resume_position, current_position);
// Wait for buffered blocks to complete // Wait for buffered blocks to complete
stepper.synchronize(); planner.synchronize();
// Initial retract before move to filament change position // Initial retract before move to filament change position
if (retract && thermalManager.hotEnoughToExtrude(active_extruder)) if (retract && thermalManager.hotEnoughToExtrude(active_extruder))

View File

@ -48,7 +48,7 @@ class FilamentRunoutSensor {
if ((IS_SD_PRINTING || print_job_timer.isRunning()) && check() && !filament_ran_out) { if ((IS_SD_PRINTING || print_job_timer.isRunning()) && check() && !filament_ran_out) {
filament_ran_out = true; filament_ran_out = true;
enqueue_and_echo_commands_P(PSTR(FILAMENT_RUNOUT_SCRIPT)); enqueue_and_echo_commands_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
stepper.synchronize(); planner.synchronize();
} }
} }
private: private:

View File

@ -27,7 +27,7 @@
#include "../module/stepper.h" #include "../module/stepper.h"
void select_multiplexed_stepper(const uint8_t e) { void select_multiplexed_stepper(const uint8_t e) {
stepper.synchronize(); planner.synchronize();
disable_e_steppers(); disable_e_steppers();
WRITE(E_MUX0_PIN, TEST(e, 0) ? HIGH : LOW); WRITE(E_MUX0_PIN, TEST(e, 0) ? HIGH : LOW);
WRITE(E_MUX1_PIN, TEST(e, 1) ? HIGH : LOW); WRITE(E_MUX1_PIN, TEST(e, 1) ? HIGH : LOW);

View File

@ -500,7 +500,7 @@ inline bool prime_nozzle() {
#endif #endif
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0); G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
set_destination_from_current(); set_destination_from_current();
stepper.synchronize(); // Without this synchronize, the purge is more consistent, planner.synchronize(); // Without this synchronize, the purge is more consistent,
// but because the planner has a buffer, we won't be able // but because the planner has a buffer, we won't be able
// to stop as quickly. So we put up with the less smooth // to stop as quickly. So we put up with the less smooth
// action to give the user a more responsive 'Stop'. // action to give the user a more responsive 'Stop'.

View File

@ -391,7 +391,7 @@ void GcodeSuite::G29() {
SERIAL_EOL(); SERIAL_EOL();
} }
stepper.synchronize(); planner.synchronize();
// Disable auto bed leveling during G29. // Disable auto bed leveling during G29.
// Be formal so G29 can be done successively without G28. // Be formal so G29 can be done successively without G28.
@ -949,7 +949,7 @@ void GcodeSuite::G29() {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
#endif #endif
stepper.synchronize(); planner.synchronize();
enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT)); enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
#endif #endif

View File

@ -132,7 +132,7 @@ void GcodeSuite::G29() {
// One last "return to the bed" (as originally coded) at completion // One last "return to the bed" (as originally coded) at completion
current_position[Z_AXIS] = MANUAL_PROBE_HEIGHT; current_position[Z_AXIS] = MANUAL_PROBE_HEIGHT;
line_to_current_position(); line_to_current_position();
stepper.synchronize(); planner.synchronize();
// After recording the last point, activate home and activate // After recording the last point, activate home and activate
mbl_probe_index = -1; mbl_probe_index = -1;
@ -147,7 +147,7 @@ void GcodeSuite::G29() {
current_position[Z_AXIS] = 0; current_position[Z_AXIS] = 0;
set_destination_from_current(); set_destination_from_current();
buffer_line_to_destination(homing_feedrate(Z_AXIS)); buffer_line_to_destination(homing_feedrate(Z_AXIS));
stepper.synchronize(); planner.synchronize();
#endif #endif
#if ENABLED(LCD_BED_LEVELING) #if ENABLED(LCD_BED_LEVELING)

View File

@ -171,7 +171,7 @@ void GcodeSuite::G28(const bool always_home_all) {
#endif #endif
// Wait for planner moves to finish! // Wait for planner moves to finish!
stepper.synchronize(); planner.synchronize();
// Cancel the active G29 session // Cancel the active G29 session
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)

View File

@ -85,7 +85,7 @@ void ac_setup(const bool reset_bed) {
tool_change(0, 0, true); tool_change(0, 0, true);
#endif #endif
stepper.synchronize(); planner.synchronize();
setup_for_endstop_or_probe_move(); setup_for_endstop_or_probe_move();
#if HAS_LEVELING #if HAS_LEVELING

View File

@ -50,7 +50,7 @@ void GcodeSuite::M18_M84() {
stepper.finish_and_disable(); stepper.finish_and_disable();
} }
else { else {
stepper.synchronize(); planner.synchronize();
if (parser.seen('X')) disable_X(); if (parser.seen('X')) disable_X();
if (parser.seen('Y')) disable_Y(); if (parser.seen('Y')) disable_Y();
if (parser.seen('Z')) disable_Z(); if (parser.seen('Z')) disable_Z();

View File

@ -37,7 +37,7 @@ void GcodeSuite::M226() {
int target = LOW; int target = LOW;
stepper.synchronize(); planner.synchronize();
pinMode(pin, INPUT); pinMode(pin, INPUT);
switch (pin_state) { switch (pin_state) {

View File

@ -79,7 +79,7 @@ inline void ocr_val_mode() {
void GcodeSuite::M3_M4(bool is_M3) { void GcodeSuite::M3_M4(bool is_M3) {
stepper.synchronize(); // wait until previous movement commands (G0/G0/G2/G3) have completed before playing with the spindle planner.synchronize(); // wait until previous movement commands (G0/G0/G2/G3) have completed before playing with the spindle
#if SPINDLE_DIR_CHANGE #if SPINDLE_DIR_CHANGE
const bool rotation_dir = (is_M3 != SPINDLE_INVERT_DIR); const bool rotation_dir = (is_M3 != SPINDLE_INVERT_DIR);
if (SPINDLE_STOP_ON_DIR_CHANGE \ if (SPINDLE_STOP_ON_DIR_CHANGE \
@ -129,7 +129,7 @@ void GcodeSuite::M3_M4(bool is_M3) {
* M5 turn off spindle * M5 turn off spindle
*/ */
void GcodeSuite::M5() { void GcodeSuite::M5() {
stepper.synchronize(); planner.synchronize();
WRITE(SPINDLE_LASER_ENABLE_PIN, !SPINDLE_LASER_ENABLE_INVERT); WRITE(SPINDLE_LASER_ENABLE_PIN, !SPINDLE_LASER_ENABLE_INVERT);
#if ENABLED(SPINDLE_LASER_PWM) #if ENABLED(SPINDLE_LASER_PWM)
analogWrite(SPINDLE_LASER_PWM_PIN, SPINDLE_LASER_PWM_INVERT ? 255 : 0); analogWrite(SPINDLE_LASER_PWM_PIN, SPINDLE_LASER_PWM_INVERT ? 255 : 0);

View File

@ -28,6 +28,6 @@
*/ */
void GcodeSuite::M400() { void GcodeSuite::M400() {
stepper.synchronize(); planner.synchronize();
} }

View File

@ -43,7 +43,7 @@
* Note: the X axis should be homed after changing dual x-carriage mode. * Note: the X axis should be homed after changing dual x-carriage mode.
*/ */
void GcodeSuite::M605() { void GcodeSuite::M605() {
stepper.synchronize(); planner.synchronize();
if (parser.seen('S')) dual_x_carriage_mode = (DualXMode)parser.value_byte(); if (parser.seen('S')) dual_x_carriage_mode = (DualXMode)parser.value_byte();
switch (dual_x_carriage_mode) { switch (dual_x_carriage_mode) {
case DXC_FULL_CONTROL_MODE: case DXC_FULL_CONTROL_MODE:
@ -75,7 +75,7 @@
#elif ENABLED(DUAL_NOZZLE_DUPLICATION_MODE) #elif ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
void GcodeSuite::M605() { void GcodeSuite::M605() {
stepper.synchronize(); planner.synchronize();
extruder_duplication_enabled = parser.intval('S') == (int)DXC_DUPLICATION_MODE; extruder_duplication_enabled = parser.intval('S') == (int)DXC_DUPLICATION_MODE;
SERIAL_ECHO_START(); SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(MSG_DUPLICATION_MODE, extruder_duplication_enabled ? MSG_ON : MSG_OFF); SERIAL_ECHOLNPAIR(MSG_DUPLICATION_MODE, extruder_duplication_enabled ? MSG_ON : MSG_OFF);

View File

@ -37,7 +37,7 @@ void GcodeSuite::M900() {
if (parser.seenval('K')) { if (parser.seenval('K')) {
const float newK = parser.floatval('K'); const float newK = parser.floatval('K');
if (WITHIN(newK, 0, 10)) { if (WITHIN(newK, 0, 10)) {
stepper.synchronize(); planner.synchronize();
planner.extruder_advance_K = newK; planner.extruder_advance_K = newK;
} }
else else

View File

@ -33,7 +33,7 @@
*/ */
bool GcodeSuite::select_coordinate_system(const int8_t _new) { bool GcodeSuite::select_coordinate_system(const int8_t _new) {
if (active_coordinate_system == _new) return false; if (active_coordinate_system == _new) return false;
stepper.synchronize(); planner.synchronize();
float old_offset[XYZ] = { 0 }, new_offset[XYZ] = { 0 }; float old_offset[XYZ] = { 0 }, new_offset[XYZ] = { 0 };
if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1)) if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
COPY(old_offset, coordinate_system[active_coordinate_system]); COPY(old_offset, coordinate_system[active_coordinate_system]);

View File

@ -77,7 +77,7 @@
report_xyz(delta); report_xyz(delta);
#endif #endif
stepper.synchronize(); planner.synchronize();
SERIAL_PROTOCOLPGM("Stepper:"); SERIAL_PROTOCOLPGM("Stepper:");
LOOP_XYZE(i) { LOOP_XYZE(i) {
@ -126,6 +126,6 @@ void GcodeSuite::M114() {
} }
#endif #endif
stepper.synchronize(); planner.synchronize();
report_current_position(); report_current_position();
} }

View File

@ -58,7 +58,7 @@ void GcodeSuite::M0_M1() {
const bool has_message = !hasP && !hasS && args && *args; const bool has_message = !hasP && !hasS && args && *args;
stepper.synchronize(); planner.synchronize();
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)

View File

@ -84,7 +84,7 @@ void GcodeSuite::G0_G1(
#define _MOVE_SYNC parser.seenval('Z') // Only for Z move #define _MOVE_SYNC parser.seenval('Z') // Only for Z move
#endif #endif
if (_MOVE_SYNC) { if (_MOVE_SYNC) {
stepper.synchronize(); planner.synchronize();
SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP); SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
} }
#endif #endif

View File

@ -33,7 +33,7 @@ void GcodeSuite::G4() {
if (parser.seenval('P')) dwell_ms = parser.value_millis(); // milliseconds to wait if (parser.seenval('P')) dwell_ms = parser.value_millis(); // milliseconds to wait
if (parser.seenval('S')) dwell_ms = parser.value_millis_from_seconds(); // seconds to wait if (parser.seenval('S')) dwell_ms = parser.value_millis_from_seconds(); // seconds to wait
stepper.synchronize(); planner.synchronize();
#if ENABLED(NANODLP_Z_SYNC) #if ENABLED(NANODLP_Z_SYNC)
SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP); SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
#endif #endif

View File

@ -44,14 +44,14 @@ static bool G38_run_probe() {
} }
#endif #endif
stepper.synchronize(); // wait until the machine is idle planner.synchronize(); // wait until the machine is idle
// Move until destination reached or target hit // Move until destination reached or target hit
endstops.enable(true); endstops.enable(true);
G38_move = true; G38_move = true;
G38_endstop_hit = false; G38_endstop_hit = false;
prepare_move_to_destination(); prepare_move_to_destination();
stepper.synchronize(); planner.synchronize();
G38_move = false; G38_move = false;
endstops.hit_on_purpose(); endstops.hit_on_purpose();
@ -68,7 +68,7 @@ static bool G38_run_probe() {
LOOP_XYZ(i) destination[i] += retract_mm[i]; LOOP_XYZ(i) destination[i] += retract_mm[i];
endstops.enable(false); endstops.enable(false);
prepare_move_to_destination(); prepare_move_to_destination();
stepper.synchronize(); planner.synchronize();
feedrate_mm_s /= 4; feedrate_mm_s /= 4;
@ -78,7 +78,7 @@ static bool G38_run_probe() {
endstops.enable(true); endstops.enable(true);
G38_move = true; G38_move = true;
prepare_move_to_destination(); prepare_move_to_destination();
stepper.synchronize(); planner.synchronize();
G38_move = false; G38_move = false;
set_current_from_steppers_for_axis(ALL_AXES); set_current_from_steppers_for_axis(ALL_AXES);

View File

@ -179,7 +179,7 @@ void GcodeSuite::M30() {
* *
*/ */
void GcodeSuite::M32() { void GcodeSuite::M32() {
if (card.sdprinting) stepper.synchronize(); if (card.sdprinting) planner.synchronize();
if (card.cardOK) { if (card.cardOK) {
const bool call_procedure = parser.boolval('P'); const bool call_procedure = parser.boolval('P');

View File

@ -570,7 +570,7 @@ uint16_t max_display_update_time = 0;
no_reentry = true; no_reentry = true;
const screenFunc_t old_screen = currentScreen; const screenFunc_t old_screen = currentScreen;
lcd_goto_screen(_lcd_synchronize); lcd_goto_screen(_lcd_synchronize);
stepper.synchronize(); // idle() is called until moves complete planner.synchronize(); // idle() is called until moves complete
no_reentry = false; no_reentry = false;
lcd_goto_screen(old_screen); lcd_goto_screen(old_screen);
} }

View File

@ -32,7 +32,7 @@
#include "motion.h" #include "motion.h"
// For homing: // For homing:
#include "stepper.h" #include "planner.h"
#include "endstops.h" #include "endstops.h"
#include "../lcd/ultralcd.h" #include "../lcd/ultralcd.h"
#include "../Marlin.h" #include "../Marlin.h"
@ -258,7 +258,7 @@ bool home_delta() {
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (delta_height + 10); current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (delta_height + 10);
feedrate_mm_s = homing_feedrate(X_AXIS); feedrate_mm_s = homing_feedrate(X_AXIS);
line_to_current_position(); line_to_current_position();
stepper.synchronize(); planner.synchronize();
// Re-enable stealthChop if used. Disable diag1 pin on driver. // Re-enable stealthChop if used. Disable diag1 pin on driver.
#if ENABLED(SENSORLESS_HOMING) #if ENABLED(SENSORLESS_HOMING)

View File

@ -402,7 +402,7 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to"); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
#endif #endif
stepper.synchronize(); planner.synchronize();
} }
void do_blocking_move_to_x(const float &rx, const float &fr_mm_s/*=0.0*/) { void do_blocking_move_to_x(const float &rx, const float &fr_mm_s/*=0.0*/) {
do_blocking_move_to(rx, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_s); do_blocking_move_to(rx, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_s);
@ -881,7 +881,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 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
); );
stepper.synchronize(); planner.synchronize();
SYNC_PLAN_POSITION_KINEMATIC(); SYNC_PLAN_POSITION_KINEMATIC();
extruder_duplication_enabled = true; extruder_duplication_enabled = true;
active_extruder_parked = false; active_extruder_parked = false;
@ -1110,7 +1110,7 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], fr_mm_s ? fr_mm_s : homing_feedrate(axis), active_extruder); planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], fr_mm_s ? fr_mm_s : homing_feedrate(axis), active_extruder);
#endif #endif
stepper.synchronize(); planner.synchronize();
if (is_home_dir) { if (is_home_dir) {

View File

@ -1299,6 +1299,11 @@ void Planner::check_axes_activity() {
#endif // PLANNER_LEVELING #endif // PLANNER_LEVELING
/**
* Block until all buffered steps are executed / cleaned
*/
void Planner::synchronize() { while (has_blocks_queued() || stepper.cleaning_buffer_counter) idle(); }
/** /**
* Planner::_buffer_steps * Planner::_buffer_steps
* *

View File

@ -551,6 +551,11 @@ class Planner {
*/ */
FORCE_INLINE static bool has_blocks_queued() { return (block_buffer_head != block_buffer_tail); } FORCE_INLINE static bool has_blocks_queued() { return (block_buffer_head != block_buffer_tail); }
//
// Block until all buffered steps are executed
//
static void synchronize();
/** /**
* "Discard" the block and "release" the memory. * "Discard" the block and "release" the memory.
* Called when the current block is no longer needed. * Called when the current block is no longer needed.

View File

@ -1977,12 +1977,6 @@ void Stepper::init() {
set_directions(); // Init directions to last_direction_bits = 0 set_directions(); // Init directions to last_direction_bits = 0
} }
/**
* Block until all buffered steps are executed / cleaned
*/
void Stepper::synchronize() { while (planner.has_blocks_queued() || cleaning_buffer_counter) idle(); }
/** /**
* Set the stepper positions directly in steps * Set the stepper positions directly in steps
* *
@ -2055,7 +2049,7 @@ float Stepper::get_axis_position_mm(const AxisEnum axis) {
} }
void Stepper::finish_and_disable() { void Stepper::finish_and_disable() {
synchronize(); planner.synchronize();
disable_all_steppers(); disable_all_steppers();
} }

View File

@ -183,11 +183,6 @@ class Stepper {
static void advance_isr_scheduler(); static void advance_isr_scheduler();
#endif #endif
//
// Block until all buffered steps are executed
//
static void synchronize();
// //
// Set the current position in steps // Set the current position in steps
// //
@ -196,14 +191,14 @@ class Stepper {
FORCE_INLINE static void _set_position(const AxisEnum a, const int32_t &v) { count_position[a] = v; } FORCE_INLINE static void _set_position(const AxisEnum a, const int32_t &v) { count_position[a] = v; }
FORCE_INLINE 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 int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
synchronize(); planner.synchronize();
CRITICAL_SECTION_START; CRITICAL_SECTION_START;
_set_position(a, b, c, e); _set_position(a, b, c, e);
CRITICAL_SECTION_END; CRITICAL_SECTION_END;
} }
static void set_position(const AxisEnum a, const int32_t &v) { static void set_position(const AxisEnum a, const int32_t &v) {
synchronize(); planner.synchronize();
CRITICAL_SECTION_START; CRITICAL_SECTION_START;
count_position[a] = v; count_position[a] = v;
CRITICAL_SECTION_END; CRITICAL_SECTION_END;
@ -212,7 +207,7 @@ class Stepper {
FORCE_INLINE static void _set_e_position(const int32_t &e) { count_position[E_AXIS] = e; } FORCE_INLINE static void _set_e_position(const int32_t &e) { count_position[E_AXIS] = e; }
static void set_e_position(const int32_t &e) { static void set_e_position(const int32_t &e) {
synchronize(); planner.synchronize();
CRITICAL_SECTION_START; CRITICAL_SECTION_START;
count_position[E_AXIS] = e; count_position[E_AXIS] = e;
CRITICAL_SECTION_END; CRITICAL_SECTION_END;

View File

@ -24,7 +24,6 @@
#include "motion.h" #include "motion.h"
#include "planner.h" #include "planner.h"
#include "stepper.h"
#include "../Marlin.h" #include "../Marlin.h"
@ -71,7 +70,7 @@
void move_extruder_servo(const uint8_t e) { void move_extruder_servo(const uint8_t e) {
constexpr int16_t angles[] = SWITCHING_EXTRUDER_SERVO_ANGLES; constexpr int16_t angles[] = SWITCHING_EXTRUDER_SERVO_ANGLES;
static_assert(COUNT(angles) == REQ_ANGLES, "SWITCHING_EXTRUDER_SERVO_ANGLES needs " STRINGIFY(REQ_ANGLES) " angles."); static_assert(COUNT(angles) == REQ_ANGLES, "SWITCHING_EXTRUDER_SERVO_ANGLES needs " STRINGIFY(REQ_ANGLES) " angles.");
stepper.synchronize(); planner.synchronize();
#if EXTRUDERS & 1 #if EXTRUDERS & 1
if (e < EXTRUDERS - 1) if (e < EXTRUDERS - 1)
#endif #endif
@ -87,7 +86,7 @@
void move_nozzle_servo(const uint8_t e) { void move_nozzle_servo(const uint8_t e) {
const int16_t angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES; const int16_t angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES;
stepper.synchronize(); planner.synchronize();
MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, angles[e]); MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, angles[e]);
safe_delay(500); safe_delay(500);
} }
@ -144,7 +143,7 @@
if (DEBUGGING(LEVELING)) DEBUG_POS("Moving to Raised Z-Position", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("Moving to Raised Z-Position", current_position);
#endif #endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder); planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
stepper.synchronize(); planner.synchronize();
// STEP 2 // STEP 2
current_position[X_AXIS] = parkingposx[active_extruder] + hotend_offset[X_AXIS][active_extruder]; current_position[X_AXIS] = parkingposx[active_extruder] + hotend_offset[X_AXIS][active_extruder];
@ -153,7 +152,7 @@
if (DEBUGGING(LEVELING)) DEBUG_POS("Moving ParkPos", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("Moving ParkPos", current_position);
#endif #endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder); planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
stepper.synchronize(); planner.synchronize();
// STEP 3 // STEP 3
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
@ -171,7 +170,7 @@
if (DEBUGGING(LEVELING)) DEBUG_POS("Moving away from parked extruder", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("Moving away from parked extruder", current_position);
#endif #endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder); planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
stepper.synchronize(); planner.synchronize();
// STEP 5 // STEP 5
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
@ -192,7 +191,7 @@
if (DEBUGGING(LEVELING)) DEBUG_POS("Move UnparkPos", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("Move UnparkPos", current_position);
#endif #endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS]/2, active_extruder); planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS]/2, active_extruder);
stepper.synchronize(); planner.synchronize();
// Step 7 // Step 7
current_position[X_AXIS] = midpos - hotend_offset[X_AXIS][tmp_extruder]; current_position[X_AXIS] = midpos - hotend_offset[X_AXIS][tmp_extruder];
@ -201,7 +200,7 @@
if (DEBUGGING(LEVELING)) DEBUG_POS("Move midway to new extruder", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("Move midway to new extruder", current_position);
#endif #endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder); planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
stepper.synchronize(); planner.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
SERIAL_ECHOLNPGM("Autopark done."); SERIAL_ECHOLNPGM("Autopark done.");
#endif #endif
@ -283,7 +282,7 @@ inline void invalid_extruder_error(const uint8_t e) {
planner.max_feedrate_mm_s[i == 1 ? X_AXIS : Z_AXIS], planner.max_feedrate_mm_s[i == 1 ? X_AXIS : Z_AXIS],
active_extruder active_extruder
); );
stepper.synchronize(); planner.synchronize();
} }
// Apply Y & Z extruder offset (X offset is used as home pos with Dual X) // Apply Y & Z extruder offset (X offset is used as home pos with Dual X)
@ -466,7 +465,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
#endif #endif
} // (tmp_extruder != active_extruder) } // (tmp_extruder != active_extruder)
stepper.synchronize(); planner.synchronize();
#if ENABLED(EXT_SOLENOID) && !ENABLED(PARKING_EXTRUDER) #if ENABLED(EXT_SOLENOID) && !ENABLED(PARKING_EXTRUDER)
disable_all_solenoids(); disable_all_solenoids();
@ -493,7 +492,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
#endif // HOTENDS <= 1 #endif // HOTENDS <= 1
#if DO_SWITCH_EXTRUDER #if DO_SWITCH_EXTRUDER
stepper.synchronize(); planner.synchronize();
move_extruder_servo(active_extruder); move_extruder_servo(active_extruder);
#endif #endif

View File

@ -28,6 +28,7 @@
#include "../Marlin.h" #include "../Marlin.h"
#include "../lcd/ultralcd.h" #include "../lcd/ultralcd.h"
#include "../module/planner.h"
#include "../module/stepper.h" #include "../module/stepper.h"
#include "../module/printcounter.h" #include "../module/printcounter.h"
#include "../core/language.h" #include "../core/language.h"
@ -962,7 +963,7 @@ uint16_t CardReader::get_num_Files() {
} }
void CardReader::printingHasFinished() { void CardReader::printingHasFinished() {
stepper.synchronize(); planner.synchronize();
file.close(); file.close();
if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure. if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure.
file_subcall_ctr--; file_subcall_ctr--;