Skip to content

Commit

Permalink
return MOVE_TIMED_EMPTY on empty queue
Browse files Browse the repository at this point in the history
  • Loading branch information
gin66 committed Feb 20, 2025
1 parent c733673 commit 54da780
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions extras/tests/pc_based/test_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ char fname[100];
rc.start_plot(fname);

ret = s.moveTimed(QUEUE_LEN/2-1, QUEUE_LEN/2*100000, actual);
test(ret == MOVE_TIMED_OK, "TC2_S1: valid pars");
test(ret == MOVE_TIMED_EMPTY, "TC2_S1: valid pars");
actual_sum += actual;

ret = s.moveTimed(2, 200000, actual);
Expand All @@ -139,7 +139,7 @@ char fname[100];
fas_queue[0].read_idx++;
}
ret = s.moveTimed(2, 200000, actual);
test(ret == MOVE_TIMED_OK, "TC2_S4: valid pars");
test(ret == MOVE_TIMED_EMPTY, "TC2_S4: valid pars");
actual_sum += actual;

// process commands
Expand Down
9 changes: 5 additions & 4 deletions src/FastAccelStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,11 +914,12 @@ int32_t FastAccelStepper::getCurrentPosition() {
int8_t FastAccelStepper::moveTimed(int16_t steps, uint32_t duration,
uint32_t& actual_duration,
bool start) {
uint8_t ret_ok = isQueueEmpty() ? MOVE_TIMED_EMPTY : MOVE_TIMED_OK;
if ((steps == 0) && (duration == 0)) {
if (start) {
addQueueEntry(NULL, true); // start the queue
}
return MOVE_TIMED_OK;
return ret_ok;
}
uint8_t freeEntries = QUEUE_LEN - queueEntries();
actual_duration = 0;
Expand Down Expand Up @@ -951,7 +952,7 @@ int8_t FastAccelStepper::moveTimed(int16_t steps, uint32_t duration,
actual_duration += cmd.ticks;
duration -= cmd.ticks;
}
return MOVE_TIMED_OK;
return ret_ok;
}

// let's evaluate the direction
Expand Down Expand Up @@ -1004,7 +1005,7 @@ int8_t FastAccelStepper::moveTimed(int16_t steps, uint32_t duration,
cmd.steps = 0;
}
}
return MOVE_TIMED_OK;
return ret_ok;
}
// Now we need to run steps at "high" speed.
if (steps > QUEUE_LEN * 255) {
Expand Down Expand Up @@ -1048,7 +1049,7 @@ int8_t FastAccelStepper::moveTimed(int16_t steps, uint32_t duration,
actual_duration += cmd_duration;
steps -= cmd.steps;
}
return MOVE_TIMED_OK;
return ret_ok;
}
void FastAccelStepper::detachFromPin() { fas_queue[_queue_num].disconnect(); }
void FastAccelStepper::reAttachToPin() { fas_queue[_queue_num].connect(); }

0 comments on commit 54da780

Please sign in to comment.