Motion: add tests for the axis autoenable
Add Motion::Enabled() to get the current axis enablement status.pull/96/head
parent
448edfd84b
commit
9a93ebecfc
|
|
@ -77,6 +77,9 @@ public:
|
||||||
/// @returns true if the init was successful (TMC2130 responded ok)
|
/// @returns true if the init was successful (TMC2130 responded ok)
|
||||||
bool InitAxis(Axis axis);
|
bool InitAxis(Axis axis);
|
||||||
|
|
||||||
|
/// Return the axis power status.
|
||||||
|
bool Enabled(Axis axis) const { return axisData[axis].enabled; }
|
||||||
|
|
||||||
/// Set axis power status. One must manually ensure no moves are currently being
|
/// Set axis power status. One must manually ensure no moves are currently being
|
||||||
/// performed by calling QueueEmpty().
|
/// performed by calling QueueEmpty().
|
||||||
void SetEnabled(Axis axis, bool enabled);
|
void SetEnabled(Axis axis, bool enabled);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,24 @@ TEST_CASE("motion::basic", "[motion]") {
|
||||||
REQUIRE(motion.Position(Idler) == 10);
|
REQUIRE(motion.Position(Idler) == 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("motion::auto_axis_enable", "[motion]") {
|
||||||
|
// by default the axis should start disabled
|
||||||
|
REQUIRE(motion.Enabled(Pulley) == false);
|
||||||
|
|
||||||
|
// enable manually the axis
|
||||||
|
motion.SetEnabled(Pulley, true);
|
||||||
|
REQUIRE(motion.Enabled(Pulley) == true);
|
||||||
|
|
||||||
|
// now disable
|
||||||
|
motion.SetEnabled(Pulley, false);
|
||||||
|
REQUIRE(motion.Enabled(Pulley) == false);
|
||||||
|
|
||||||
|
// planning a move should enable the axis automatically
|
||||||
|
REQUIRE(motion.QueueEmpty());
|
||||||
|
motion.PlanMove<Pulley>(1.0_mm, 100.0_mm_s);
|
||||||
|
REQUIRE(motion.Enabled(Pulley) == true);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("motion::unit", "[motion]") {
|
TEST_CASE("motion::unit", "[motion]") {
|
||||||
// test AxisUnit conversion in the PlanMove and PlanMoveTo.
|
// test AxisUnit conversion in the PlanMove and PlanMoveTo.
|
||||||
REQUIRE(motion.QueueEmpty());
|
REQUIRE(motion.QueueEmpty());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue