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 one
pull/93/head
Yuri D'Elia 2021-08-29 17:34:00 +02:00 committed by DRracer
parent d18143dff2
commit d55e01bb58
5 changed files with 13 additions and 6 deletions

View File

@ -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() {

View File

@ -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 {

View File

@ -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

View File

@ -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; }

View File

@ -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
}