|
@@ -53,14 +53,18 @@ enum BlockFlagBit {
|
53
|
53
|
BLOCK_BIT_START_FROM_FULL_HALT,
|
54
|
54
|
|
55
|
55
|
// The block is busy
|
56
|
|
- BLOCK_BIT_BUSY
|
|
56
|
+ BLOCK_BIT_BUSY,
|
|
57
|
+
|
|
58
|
+ // The block is segment 2+ of a longer move
|
|
59
|
+ BLOCK_BIT_CONTINUED
|
57
|
60
|
};
|
58
|
61
|
|
59
|
62
|
enum BlockFlag {
|
60
|
63
|
BLOCK_FLAG_RECALCULATE = _BV(BLOCK_BIT_RECALCULATE),
|
61
|
64
|
BLOCK_FLAG_NOMINAL_LENGTH = _BV(BLOCK_BIT_NOMINAL_LENGTH),
|
62
|
65
|
BLOCK_FLAG_START_FROM_FULL_HALT = _BV(BLOCK_BIT_START_FROM_FULL_HALT),
|
63
|
|
- BLOCK_FLAG_BUSY = _BV(BLOCK_BIT_BUSY)
|
|
66
|
+ BLOCK_FLAG_BUSY = _BV(BLOCK_BIT_BUSY),
|
|
67
|
+ BLOCK_FLAG_CONTINUED = _BV(BLOCK_BIT_CONTINUED)
|
64
|
68
|
};
|
65
|
69
|
|
66
|
70
|
/**
|
|
@@ -450,22 +454,32 @@ class Planner {
|
450
|
454
|
static bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }
|
451
|
455
|
|
452
|
456
|
/**
|
453
|
|
- * "Discards" the block and "releases" the memory.
|
|
457
|
+ * "Discard" the block and "release" the memory.
|
454
|
458
|
* Called when the current block is no longer needed.
|
455
|
459
|
*/
|
456
|
|
- static void discard_current_block() {
|
|
460
|
+ FORCE_INLINE static void discard_current_block() {
|
457
|
461
|
if (blocks_queued())
|
458
|
462
|
block_buffer_tail = BLOCK_MOD(block_buffer_tail + 1);
|
459
|
463
|
}
|
460
|
464
|
|
461
|
465
|
/**
|
|
466
|
+ * "Discard" the next block if it's continued.
|
|
467
|
+ * Called after an interrupted move to throw away the rest of the move.
|
|
468
|
+ */
|
|
469
|
+ FORCE_INLINE static bool discard_continued_block() {
|
|
470
|
+ const bool discard = blocks_queued() && TEST(block_buffer[block_buffer_tail].flag, BLOCK_BIT_CONTINUED);
|
|
471
|
+ if (discard) discard_current_block();
|
|
472
|
+ return discard;
|
|
473
|
+ }
|
|
474
|
+
|
|
475
|
+ /**
|
462
|
476
|
* The current block. NULL if the buffer is empty.
|
463
|
477
|
* This also marks the block as busy.
|
464
|
478
|
* WARNING: Called from Stepper ISR context!
|
465
|
479
|
*/
|
466
|
480
|
static block_t* get_current_block() {
|
467
|
481
|
if (blocks_queued()) {
|
468
|
|
- block_t* block = &block_buffer[block_buffer_tail];
|
|
482
|
+ block_t * const block = &block_buffer[block_buffer_tail];
|
469
|
483
|
#if ENABLED(ULTRA_LCD)
|
470
|
484
|
block_buffer_runtime_us -= block->segment_time_us; // We can't be sure how long an active block will take, so don't count it.
|
471
|
485
|
#endif
|