Motion/PulseGen: allow to abort a move for chaining
Add a new parameter "halt" (default to true) to control the stopping behavior: - halt=true: no subsequent moves will be planned, motions stops abruptly - half=false: a new move will be chained after the current onepull/93/head
parent
d18143dff2
commit
d55e01bb58
|
|
@ -62,9 +62,9 @@ bool Motion::QueueEmpty() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Motion::AbortPlannedMoves() {
|
||||
void Motion::AbortPlannedMoves(bool halt) {
|
||||
for (uint8_t i = 0; i != NUM_AXIS; ++i)
|
||||
axisData[i].ctrl.AbortPlannedMoves();
|
||||
axisData[i].ctrl.AbortPlannedMoves(halt);
|
||||
}
|
||||
|
||||
st_timer_t Motion::Step() {
|
||||
|
|
|
|||
|
|
@ -240,7 +240,8 @@ public:
|
|||
bool Full(Axis axis) const { return axisData[axis].ctrl.Full(); }
|
||||
|
||||
/// stop whatever moves are being done
|
||||
void AbortPlannedMoves();
|
||||
/// @param halt When true, also abruptly stop axis movement.
|
||||
void AbortPlannedMoves(bool halt = true);
|
||||
|
||||
/// @returns the TMC213 driver associated with the particular axis
|
||||
inline const hal::tmc2130::TMC2130 &DriverForAxis(Axis axis) const {
|
||||
|
|
|
|||
|
|
@ -136,15 +136,20 @@ pos_t PulseGen::CurPosition() const {
|
|||
return cur_pos;
|
||||
}
|
||||
|
||||
void PulseGen::AbortPlannedMoves() {
|
||||
void PulseGen::AbortPlannedMoves(bool halt) {
|
||||
// always update to effective position
|
||||
position = CurPosition();
|
||||
|
||||
// destroy the current block
|
||||
if (current_block) {
|
||||
last_rate = acc_step_rate;
|
||||
current_block = nullptr;
|
||||
block_index.pop();
|
||||
}
|
||||
|
||||
// truncate the last rate if halting
|
||||
if (halt)
|
||||
last_rate = 0;
|
||||
}
|
||||
|
||||
} // namespace motor
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ public:
|
|||
bool PlanMoveTo(pos_t pos, steps_t feedrate);
|
||||
|
||||
/// Stop whatever moves are being done
|
||||
void AbortPlannedMoves();
|
||||
/// @param halt When true, also abruptly stop axis movement.
|
||||
void AbortPlannedMoves(bool halt = true);
|
||||
|
||||
/// @returns the head position of the axis at the end of all moves
|
||||
pos_t Position() const { return position; }
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ bool Motion::QueueEmpty() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Motion::AbortPlannedMoves() {
|
||||
void Motion::AbortPlannedMoves(bool halt) {
|
||||
for (uint8_t i = 0; i < 3; ++i) {
|
||||
axes[i].targetPos = axes[i].pos; // leave the axis where it was at the time of abort
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue