|
@@ -215,7 +215,7 @@ class Planner {
|
215
|
215
|
#endif
|
216
|
216
|
|
217
|
217
|
#if ENABLED(ENSURE_SMOOTH_MOVES)
|
218
|
|
- static uint32_t block_buffer_runtime_us; //Theoretical block buffer runtime in µs
|
|
218
|
+ volatile static uint32_t block_buffer_runtime_us; //Theoretical block buffer runtime in µs
|
219
|
219
|
#endif
|
220
|
220
|
|
221
|
221
|
public:
|
|
@@ -387,21 +387,26 @@ class Planner {
|
387
|
387
|
SBI(block->flag, BLOCK_BIT_BUSY);
|
388
|
388
|
return block;
|
389
|
389
|
}
|
390
|
|
- else
|
|
390
|
+ else {
|
|
391
|
+ #if ENABLED(ENSURE_SMOOTH_MOVES)
|
|
392
|
+ clear_block_buffer_runtime(); // paranoia. Buffer is empty now - so reset accumulated time to zero.
|
|
393
|
+ #endif
|
391
|
394
|
return NULL;
|
|
395
|
+ }
|
392
|
396
|
}
|
393
|
397
|
|
394
|
398
|
#if ENABLED(ENSURE_SMOOTH_MOVES)
|
395
|
399
|
static bool long_move() {
|
396
|
|
- if (block_buffer_runtime_us) {
|
397
|
|
- return block_buffer_runtime_us > (LCD_UPDATE_THRESHOLD) * 1000UL + (MIN_BLOCK_TIME) * 3000UL;
|
398
|
|
- }
|
399
|
|
- else
|
400
|
|
- return true;
|
|
400
|
+ CRITICAL_SECTION_START
|
|
401
|
+ uint32_t bbru = block_buffer_runtime_us;
|
|
402
|
+ CRITICAL_SECTION_END
|
|
403
|
+ return !bbru || bbru > (LCD_UPDATE_THRESHOLD) * 1000UL + (MIN_BLOCK_TIME) * 3000UL;
|
401
|
404
|
}
|
402
|
405
|
|
403
|
406
|
static void clear_block_buffer_runtime(){
|
404
|
|
- block_buffer_runtime_us = 0;
|
|
407
|
+ CRITICAL_SECTION_START
|
|
408
|
+ block_buffer_runtime_us = 0;
|
|
409
|
+ CRITICAL_SECTION_END
|
405
|
410
|
}
|
406
|
411
|
#endif
|
407
|
412
|
|