PulseGen: perform an extra queue check in Move()
Since scheduling a move on a block which is being executed will jolt the motors, be extra-safe and perform an extra lower-level check before committing even if the caller is responsible. Return the status, which can be useful to build a simple busy loop.pull/47/head
parent
bd8ae62211
commit
94f11642e0
|
|
@ -85,15 +85,18 @@ void PulseGen::CalculateTrapezoid(block_t *block, steps_t entry_speed, steps_t e
|
|||
block->final_rate = final_rate;
|
||||
}
|
||||
|
||||
void PulseGen::Move(pos_t target, steps_t feed_rate) {
|
||||
bool PulseGen::Move(pos_t target, steps_t feed_rate) {
|
||||
// Prepare to set up new block
|
||||
if (block_index.full())
|
||||
return false;
|
||||
block_t *block = &block_buffer[block_index.back()];
|
||||
|
||||
block->steps = abs(target - position);
|
||||
|
||||
// Bail if this is a zero-length block
|
||||
if (block->steps <= config::dropSegments)
|
||||
return;
|
||||
block->steps = abs(target - position);
|
||||
if (block->steps <= config::dropSegments) {
|
||||
// behave as-if the block as been scheduled
|
||||
return true;
|
||||
}
|
||||
|
||||
// Direction and speed for this block
|
||||
block->direction = (target >= position);
|
||||
|
|
@ -109,6 +112,7 @@ void PulseGen::Move(pos_t target, steps_t feed_rate) {
|
|||
// Move forward
|
||||
block_index.push();
|
||||
position = target;
|
||||
return true;
|
||||
}
|
||||
|
||||
void PulseGen::AbortPlannedMoves() {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ public:
|
|||
/// Set acceleration for the axis
|
||||
void SetAcceleration(steps_t accel) { acceleration = accel; }
|
||||
|
||||
/// Plan a single move (can only be executed when !Full())
|
||||
void Move(pos_t x, steps_t feed_rate);
|
||||
/// Plan a single move (can only be executed when not Full())
|
||||
/// @returns True if the move has been planned
|
||||
bool Move(pos_t x, steps_t feed_rate);
|
||||
|
||||
/// stop whatever moves are being done
|
||||
void AbortPlannedMoves();
|
||||
|
|
|
|||
Loading…
Reference in New Issue