PulseGen: implement AbortPlannedMoves

pull/47/head
Yuri D'Elia 2021-07-06 09:12:47 +02:00
parent 44a263d334
commit d7874d5336
2 changed files with 20 additions and 1 deletions

View File

@ -96,7 +96,7 @@ void PulseGen::Move(pos_t target, steps_t feed_rate) {
return;
// Direction and speed for this block
block->direction = (target > position);
block->direction = (target >= position);
block->nominal_rate = feed_rate;
// Acceleration of the segment, in steps/sec^2
@ -111,5 +111,21 @@ void PulseGen::Move(pos_t target, steps_t feed_rate) {
position = target;
}
void PulseGen::AbortPlannedMoves() {
if (!current_block)
return;
// update position
steps_t steps_missing = (current_block->steps - steps_completed);
if (current_block->direction)
position -= steps_missing;
else
position += steps_missing;
// destroy the block
current_block = nullptr;
block_index.pop();
}
} // namespace motor
} // namespace modules

View File

@ -32,6 +32,9 @@ public:
/// Plan a single move (can only be executed when !Full())
void Move(pos_t x, steps_t feed_rate);
/// stop whatever moves are being done
void AbortPlannedMoves();
/// @returns the current position of the axis
pos_t Position() const { return position; }