PulseGen: ensure Abort calculates the current remainder correctly

Instead of stepping halfway, step ~1/3 of the way through.

This ensures we can check if the steps performed is correct due to the
internal step subtraction.
pull/47/head
Yuri D'Elia 2021-07-11 22:19:44 +02:00
parent 9e935f6a07
commit 9b77623be1
1 changed files with 5 additions and 3 deletions

View File

@ -202,9 +202,9 @@ TEST_CASE("pulse_gen::queue_abort", "[pulse_gen]") {
// queue should start empty // queue should start empty
REQUIRE(pg.QueueEmpty()); REQUIRE(pg.QueueEmpty());
// enqueue a move and step halfway through // enqueue a move and step ~1/3 through
REQUIRE(pg.PlanMoveTo(10, 1)); REQUIRE(pg.PlanMoveTo(10, 1));
REQUIRE(stepUntilDone(pg, mp, 5) == -1); REQUIRE(stepUntilDone(pg, mp, 3) == -1);
// abort the queue // abort the queue
pg.AbortPlannedMoves(); pg.AbortPlannedMoves();
@ -214,7 +214,9 @@ TEST_CASE("pulse_gen::queue_abort", "[pulse_gen]") {
bool st = ReadPin(IDLER_STEP_PIN) == Level::high; bool st = ReadPin(IDLER_STEP_PIN) == Level::high;
REQUIRE(pg.Step(mp) == 0); REQUIRE(pg.Step(mp) == 0);
REQUIRE(st == (ReadPin(IDLER_STEP_PIN) == Level::high)); REQUIRE(st == (ReadPin(IDLER_STEP_PIN) == Level::high));
REQUIRE(pg.Position() == 5);
// check that the aborted position matches
REQUIRE(pg.Position() == 3);
} }
TEST_CASE("pulse_gen::accel_ramp", "[pulse_gen]") { TEST_CASE("pulse_gen::accel_ramp", "[pulse_gen]") {