Skip to content

Commit 54da780

Browse files
committed
return MOVE_TIMED_EMPTY on empty queue
1 parent c733673 commit 54da780

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

extras/tests/pc_based/test_16.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ char fname[100];
122122
rc.start_plot(fname);
123123

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

128128
ret = s.moveTimed(2, 200000, actual);
@@ -139,7 +139,7 @@ char fname[100];
139139
fas_queue[0].read_idx++;
140140
}
141141
ret = s.moveTimed(2, 200000, actual);
142-
test(ret == MOVE_TIMED_OK, "TC2_S4: valid pars");
142+
test(ret == MOVE_TIMED_EMPTY, "TC2_S4: valid pars");
143143
actual_sum += actual;
144144

145145
// process commands

src/FastAccelStepper.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,11 +914,12 @@ int32_t FastAccelStepper::getCurrentPosition() {
914914
int8_t FastAccelStepper::moveTimed(int16_t steps, uint32_t duration,
915915
uint32_t& actual_duration,
916916
bool start) {
917+
uint8_t ret_ok = isQueueEmpty() ? MOVE_TIMED_EMPTY : MOVE_TIMED_OK;
917918
if ((steps == 0) && (duration == 0)) {
918919
if (start) {
919920
addQueueEntry(NULL, true); // start the queue
920921
}
921-
return MOVE_TIMED_OK;
922+
return ret_ok;
922923
}
923924
uint8_t freeEntries = QUEUE_LEN - queueEntries();
924925
actual_duration = 0;
@@ -951,7 +952,7 @@ int8_t FastAccelStepper::moveTimed(int16_t steps, uint32_t duration,
951952
actual_duration += cmd.ticks;
952953
duration -= cmd.ticks;
953954
}
954-
return MOVE_TIMED_OK;
955+
return ret_ok;
955956
}
956957

957958
// let's evaluate the direction
@@ -1004,7 +1005,7 @@ int8_t FastAccelStepper::moveTimed(int16_t steps, uint32_t duration,
10041005
cmd.steps = 0;
10051006
}
10061007
}
1007-
return MOVE_TIMED_OK;
1008+
return ret_ok;
10081009
}
10091010
// Now we need to run steps at "high" speed.
10101011
if (steps > QUEUE_LEN * 255) {
@@ -1048,7 +1049,7 @@ int8_t FastAccelStepper::moveTimed(int16_t steps, uint32_t duration,
10481049
actual_duration += cmd_duration;
10491050
steps -= cmd.steps;
10501051
}
1051-
return MOVE_TIMED_OK;
1052+
return ret_ok;
10521053
}
10531054
void FastAccelStepper::detachFromPin() { fas_queue[_queue_num].disconnect(); }
10541055
void FastAccelStepper::reAttachToPin() { fas_queue[_queue_num].connect(); }

0 commit comments

Comments
 (0)