Improve sync of stepper positions
This commit is contained in:
@ -57,14 +57,18 @@ enum BlockFlagBit : char {
|
||||
BLOCK_BIT_BUSY,
|
||||
|
||||
// The block is segment 2+ of a longer move
|
||||
BLOCK_BIT_CONTINUED
|
||||
BLOCK_BIT_CONTINUED,
|
||||
|
||||
// Sync the stepper counts from the block
|
||||
BLOCK_BIT_SYNC_POSITION
|
||||
};
|
||||
|
||||
enum BlockFlag : char {
|
||||
BLOCK_FLAG_RECALCULATE = _BV(BLOCK_BIT_RECALCULATE),
|
||||
BLOCK_FLAG_NOMINAL_LENGTH = _BV(BLOCK_BIT_NOMINAL_LENGTH),
|
||||
BLOCK_FLAG_BUSY = _BV(BLOCK_BIT_BUSY),
|
||||
BLOCK_FLAG_CONTINUED = _BV(BLOCK_BIT_CONTINUED)
|
||||
BLOCK_FLAG_CONTINUED = _BV(BLOCK_BIT_CONTINUED),
|
||||
BLOCK_FLAG_SYNC_POSITION = _BV(BLOCK_BIT_SYNC_POSITION)
|
||||
};
|
||||
|
||||
/**
|
||||
@ -422,6 +426,20 @@ class Planner {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Planner::get_next_free_block
|
||||
*
|
||||
* - Get the next head index (passed by reference)
|
||||
* - Wait for a space to open up in the planner
|
||||
* - Return the head block
|
||||
*/
|
||||
FORCE_INLINE static block_t* get_next_free_block(uint8_t &next_buffer_head) {
|
||||
next_buffer_head = next_block_index(block_buffer_head);
|
||||
while (block_buffer_tail == next_buffer_head) idle(); // while (is_full)
|
||||
return &block_buffer[block_buffer_head];
|
||||
}
|
||||
|
||||
/**
|
||||
* Planner::_buffer_steps
|
||||
*
|
||||
@ -439,6 +457,12 @@ class Planner {
|
||||
, float fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
|
||||
);
|
||||
|
||||
/**
|
||||
* Planner::buffer_sync_block
|
||||
* Add a block to the buffer that just updates the position
|
||||
*/
|
||||
static void buffer_sync_block();
|
||||
|
||||
/**
|
||||
* Planner::buffer_segment
|
||||
*
|
||||
@ -518,7 +542,7 @@ class Planner {
|
||||
static void set_position_mm_kinematic(const float (&cart)[XYZE]);
|
||||
static void set_position_mm(const AxisEnum axis, const float &v);
|
||||
FORCE_INLINE static void set_z_position_mm(const float &z) { set_position_mm(Z_AXIS, z); }
|
||||
FORCE_INLINE static void set_e_position_mm(const float &e) { set_position_mm(AxisEnum(E_AXIS), e); }
|
||||
FORCE_INLINE static void set_e_position_mm(const float &e) { set_position_mm(E_AXIS, e); }
|
||||
|
||||
/**
|
||||
* Sync from the stepper positions. (e.g., after an interrupted move)
|
||||
@ -528,7 +552,7 @@ class Planner {
|
||||
/**
|
||||
* Does the buffer have any blocks queued?
|
||||
*/
|
||||
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); }
|
||||
|
||||
/**
|
||||
* "Discard" the block and "release" the memory.
|
||||
|
Reference in New Issue
Block a user