Merge pull request #5274 from Sebastianv650/improve_smooth_moves
Improvement for ENSURE_SMOOTH_MOVES
This commit is contained in:
commit
e9e4208ff1
@ -141,6 +141,10 @@ float Planner::previous_speed[NUM_AXIS],
|
|||||||
float Planner::position_float[NUM_AXIS] = { 0 };
|
float Planner::position_float[NUM_AXIS] = { 0 };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(ENSURE_SMOOTH_MOVES)
|
||||||
|
uint32_t Planner::block_buffer_runtime_us = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class and Instance Methods
|
* Class and Instance Methods
|
||||||
*/
|
*/
|
||||||
@ -988,6 +992,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
|||||||
segment_time = (MIN_BLOCK_TIME) * 1000UL;
|
segment_time = (MIN_BLOCK_TIME) * 1000UL;
|
||||||
}
|
}
|
||||||
block->segment_time = segment_time;
|
block->segment_time = segment_time;
|
||||||
|
block_buffer_runtime_us += segment_time;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0
|
block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0
|
||||||
|
@ -210,6 +210,10 @@ class Planner {
|
|||||||
static float extruder_advance_k;
|
static float extruder_advance_k;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(ENSURE_SMOOTH_MOVES)
|
||||||
|
static uint32_t block_buffer_runtime_us; //Theoretical block buffer runtime in µs
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -367,6 +371,9 @@ class Planner {
|
|||||||
static block_t* get_current_block() {
|
static block_t* get_current_block() {
|
||||||
if (blocks_queued()) {
|
if (blocks_queued()) {
|
||||||
block_t* block = &block_buffer[block_buffer_tail];
|
block_t* block = &block_buffer[block_buffer_tail];
|
||||||
|
#if ENABLED(ENSURE_SMOOTH_MOVES)
|
||||||
|
block_buffer_runtime_us -= block->segment_time; //We can't be sure how long an active block will take, so don't count it.
|
||||||
|
#endif
|
||||||
SBI(block->flag, BLOCK_BIT_BUSY);
|
SBI(block->flag, BLOCK_BIT_BUSY);
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
@ -378,11 +385,15 @@ class Planner {
|
|||||||
static bool long_move() {
|
static bool long_move() {
|
||||||
if (blocks_queued()) {
|
if (blocks_queued()) {
|
||||||
block_t* block = &block_buffer[block_buffer_tail];
|
block_t* block = &block_buffer[block_buffer_tail];
|
||||||
return block->segment_time > (LCD_UPDATE_THRESHOLD) * 1000UL;
|
return block_buffer_runtime_us > (LCD_UPDATE_THRESHOLD) * 1000UL + (MIN_BLOCK_TIME) * 3000UL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clear_block_buffer_runtime(){
|
||||||
|
block_buffer_runtime_us = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(AUTOTEMP)
|
#if ENABLED(AUTOTEMP)
|
||||||
|
@ -1072,6 +1072,9 @@ void Stepper::finish_and_disable() {
|
|||||||
|
|
||||||
void Stepper::quick_stop() {
|
void Stepper::quick_stop() {
|
||||||
cleaning_buffer_counter = 5000;
|
cleaning_buffer_counter = 5000;
|
||||||
|
#if ENABLED(ENSURE_SMOOTH_MOVES)
|
||||||
|
planner.clear_block_buffer_runtime();
|
||||||
|
#endif
|
||||||
DISABLE_STEPPER_DRIVER_INTERRUPT();
|
DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||||
while (planner.blocks_queued()) planner.discard_current_block();
|
while (planner.blocks_queued()) planner.discard_current_block();
|
||||||
current_block = NULL;
|
current_block = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user