PulseGen: implement AbortPlannedMoves
parent
44a263d334
commit
d7874d5336
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue