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
33 changed files with 72 additions and 73 deletions

View File

@ -32,7 +32,7 @@
#include "motion.h"
// For homing:
#include "stepper.h"
#include "planner.h"
#include "endstops.h"
#include "../lcd/ultralcd.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);
feedrate_mm_s = homing_feedrate(X_AXIS);
line_to_current_position();
stepper.synchronize();
planner.synchronize();
// Re-enable stealthChop if used. Disable diag1 pin on driver.
#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");
#endif
stepper.synchronize();
planner.synchronize();
}
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);
@ -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],
planner.max_feedrate_mm_s[X_AXIS], 1
);
stepper.synchronize();
planner.synchronize();
SYNC_PLAN_POSITION_KINEMATIC();
extruder_duplication_enabled = true;
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);
#endif
stepper.synchronize();
planner.synchronize();
if (is_home_dir) {

View File

@ -1299,6 +1299,11 @@ void Planner::check_axes_activity() {
#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
*

View File

@ -551,6 +551,11 @@ class Planner {
*/
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.
* 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
}
/**
* 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
*
@ -2055,7 +2049,7 @@ float Stepper::get_axis_position_mm(const AxisEnum axis) {
}
void Stepper::finish_and_disable() {
synchronize();
planner.synchronize();
disable_all_steppers();
}

View File

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

View File

@ -24,7 +24,6 @@
#include "motion.h"
#include "planner.h"
#include "stepper.h"
#include "../Marlin.h"
@ -71,7 +70,7 @@
void move_extruder_servo(const uint8_t e) {
constexpr int16_t angles[] = SWITCHING_EXTRUDER_SERVO_ANGLES;
static_assert(COUNT(angles) == REQ_ANGLES, "SWITCHING_EXTRUDER_SERVO_ANGLES needs " STRINGIFY(REQ_ANGLES) " angles.");
stepper.synchronize();
planner.synchronize();
#if EXTRUDERS & 1
if (e < EXTRUDERS - 1)
#endif
@ -87,7 +86,7 @@
void move_nozzle_servo(const uint8_t e) {
const int16_t angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES;
stepper.synchronize();
planner.synchronize();
MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, angles[e]);
safe_delay(500);
}
@ -144,7 +143,7 @@
if (DEBUGGING(LEVELING)) DEBUG_POS("Moving to Raised Z-Position", current_position);
#endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
stepper.synchronize();
planner.synchronize();
// STEP 2
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);
#endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
stepper.synchronize();
planner.synchronize();
// STEP 3
#if ENABLED(DEBUG_LEVELING_FEATURE)
@ -171,7 +170,7 @@
if (DEBUGGING(LEVELING)) DEBUG_POS("Moving away from parked extruder", current_position);
#endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
stepper.synchronize();
planner.synchronize();
// STEP 5
#if ENABLED(DEBUG_LEVELING_FEATURE)
@ -192,7 +191,7 @@
if (DEBUGGING(LEVELING)) DEBUG_POS("Move UnparkPos", current_position);
#endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS]/2, active_extruder);
stepper.synchronize();
planner.synchronize();
// Step 7
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);
#endif
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
stepper.synchronize();
planner.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
SERIAL_ECHOLNPGM("Autopark done.");
#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],
active_extruder
);
stepper.synchronize();
planner.synchronize();
}
// 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
} // (tmp_extruder != active_extruder)
stepper.synchronize();
planner.synchronize();
#if ENABLED(EXT_SOLENOID) && !ENABLED(PARKING_EXTRUDER)
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
#if DO_SWITCH_EXTRUDER
stepper.synchronize();
planner.synchronize();
move_extruder_servo(active_extruder);
#endif