🏗️ Planner::busy() (#23145)

This commit is contained in:
espr14 2021-11-17 18:07:11 +01:00 committed by Scott Lahteine
parent feffc19867
commit c2a674d2c1
2 changed files with 13 additions and 10 deletions

View File

@ -91,10 +91,6 @@
#include "../feature/power.h" #include "../feature/power.h"
#endif #endif
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
#include "../feature/closedloop.h"
#endif
#if ENABLED(BACKLASH_COMPENSATION) #if ENABLED(BACKLASH_COMPENSATION)
#include "../feature/backlash.h" #include "../feature/backlash.h"
#endif #endif
@ -1763,13 +1759,9 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
} }
/** /**
* Block until all buffered steps are executed / cleaned * Block until the planner is finished processing
*/ */
void Planner::synchronize() { void Planner::synchronize() { while (busy()) idle(); }
while (has_blocks_queued() || cleaning_buffer_counter
|| TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING())
) idle();
}
/** /**
* Planner::_buffer_steps * Planner::_buffer_steps

View File

@ -75,6 +75,10 @@
#define IS_PAGE(B) false #define IS_PAGE(B) false
#endif #endif
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
#include "../feature/closedloop.h"
#endif
// Feedrate for manual moves // Feedrate for manual moves
#ifdef MANUAL_FEEDRATE #ifdef MANUAL_FEEDRATE
constexpr xyze_feedrate_t _mf = MANUAL_FEEDRATE, constexpr xyze_feedrate_t _mf = MANUAL_FEEDRATE,
@ -865,6 +869,13 @@ class Planner {
// Triggered position of an axis in mm (not core-savvy) // Triggered position of an axis in mm (not core-savvy)
static float triggered_position_mm(const AxisEnum axis); static float triggered_position_mm(const AxisEnum axis);
// Blocks are queued, or we're running out moves, or the closed loop controller is waiting
static inline bool busy() {
return (has_blocks_queued() || cleaning_buffer_counter
|| TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING())
);
}
// Block until all buffered steps are executed / cleaned // Block until all buffered steps are executed / cleaned
static void synchronize(); static void synchronize();