Swap buttons left<->right
parent
6f982e2505
commit
7d423df583
|
|
@ -21,9 +21,9 @@ private:
|
|||
|
||||
/// Enum of buttons - used also as indices in an array of buttons to keep the code size tight.
|
||||
enum {
|
||||
Left = 0,
|
||||
Right = 0,
|
||||
Middle,
|
||||
Right
|
||||
Left
|
||||
};
|
||||
|
||||
/// A model of the 3 buttons on the MMU unit
|
||||
|
|
|
|||
|
|
@ -186,9 +186,9 @@ void ToolChangeFailLoadToFinda(logic::ToolChange &tc, uint8_t fromSlot, uint8_t
|
|||
REQUIRE(WhileTopState(tc, ProgressCode::ERRDisengagingIdler, 5000));
|
||||
}
|
||||
|
||||
void ToolChangeFailLoadToFindaButton0(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
void ToolChangeFailLoadToFindaLeftBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
// now waiting for user input
|
||||
PressButtonAndDebounce(tc, 0);
|
||||
PressButtonAndDebounce(tc, mb::Left);
|
||||
|
||||
REQUIRE(WhileTopState(tc, ProgressCode::ERREngagingIdler, 5000UL));
|
||||
|
||||
|
|
@ -211,9 +211,9 @@ void ToolChangeFailLoadToFindaButton0(logic::ToolChange &tc, uint8_t toSlot) {
|
|||
CheckFinishedCorrectly(tc, toSlot);
|
||||
}
|
||||
|
||||
void ToolChangeFailLoadToFindaButton1(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
void ToolChangeFailLoadToFindaMiddleBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
// now waiting for user input
|
||||
PressButtonAndDebounce(tc, 1);
|
||||
PressButtonAndDebounce(tc, mb::Middle);
|
||||
|
||||
REQUIRE(WhileCondition(
|
||||
tc,
|
||||
|
|
@ -236,73 +236,73 @@ void ToolChangeFailLoadToFindaButton1(logic::ToolChange &tc, uint8_t toSlot) {
|
|||
CheckFinishedCorrectly(tc, toSlot);
|
||||
}
|
||||
|
||||
void ToolChangeFailLoadToFindaButton2FINDA_FSensor(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
void ToolChangeFailLoadToFindaRightBtnFINDA_FSensor(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
// now waiting for user input - press FINDA and FSensor
|
||||
hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high);
|
||||
mfs::fsensor.ProcessMessage(true);
|
||||
PressButtonAndDebounce(tc, 2);
|
||||
PressButtonAndDebounce(tc, mb::Right);
|
||||
|
||||
CheckFinishedCorrectly(tc, toSlot);
|
||||
}
|
||||
|
||||
void ToolChangeFailLoadToFindaButton2FINDA(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
void ToolChangeFailLoadToFindaRightBtnFINDA(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
// now waiting for user input - press FINDA
|
||||
hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high);
|
||||
PressButtonAndDebounce(tc, 2);
|
||||
PressButtonAndDebounce(tc, mb::Right);
|
||||
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), toSlot, true, false, ml::off, ml::blink0, ErrorCode::FSENSOR_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
||||
}
|
||||
|
||||
void ToolChangeFailLoadToFindaButton2(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
void ToolChangeFailLoadToFindaRightBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
// now waiting for user input - do not press anything
|
||||
PressButtonAndDebounce(tc, 2);
|
||||
PressButtonAndDebounce(tc, mb::Right);
|
||||
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
||||
}
|
||||
|
||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btn0", "[tool_change]") {
|
||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btnL", "[tool_change]") {
|
||||
logic::ToolChange tc;
|
||||
for (uint8_t fromSlot = 0; fromSlot < config::toolCount; ++fromSlot) {
|
||||
for (uint8_t toSlot = 0; toSlot < config::toolCount; ++toSlot) {
|
||||
if (fromSlot != toSlot) {
|
||||
ToolChangeFailLoadToFinda(tc, fromSlot, toSlot);
|
||||
ToolChangeFailLoadToFindaButton0(tc, toSlot);
|
||||
ToolChangeFailLoadToFindaLeftBtn(tc, toSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btn1", "[tool_change]") {
|
||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btnM", "[tool_change]") {
|
||||
logic::ToolChange tc;
|
||||
for (uint8_t fromSlot = 0; fromSlot < config::toolCount; ++fromSlot) {
|
||||
for (uint8_t toSlot = 0; toSlot < config::toolCount; ++toSlot) {
|
||||
if (fromSlot != toSlot) {
|
||||
ToolChangeFailLoadToFinda(tc, fromSlot, toSlot);
|
||||
ToolChangeFailLoadToFindaButton1(tc, toSlot);
|
||||
ToolChangeFailLoadToFindaMiddleBtn(tc, toSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btn2_FINDA_FSensor", "[tool_change]") {
|
||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btnR_FINDA_FSensor", "[tool_change]") {
|
||||
logic::ToolChange tc;
|
||||
for (uint8_t fromSlot = 0; fromSlot < config::toolCount; ++fromSlot) {
|
||||
for (uint8_t toSlot = 0; toSlot < config::toolCount; ++toSlot) {
|
||||
if (fromSlot != toSlot) {
|
||||
ToolChangeFailLoadToFinda(tc, fromSlot, toSlot);
|
||||
ToolChangeFailLoadToFindaButton2FINDA_FSensor(tc, toSlot);
|
||||
ToolChangeFailLoadToFindaRightBtnFINDA_FSensor(tc, toSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btn2_FINDA", "[tool_change]") {
|
||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btnR_FINDA", "[tool_change]") {
|
||||
logic::ToolChange tc;
|
||||
for (uint8_t fromSlot = 0; fromSlot < config::toolCount; ++fromSlot) {
|
||||
for (uint8_t toSlot = 0; toSlot < config::toolCount; ++toSlot) {
|
||||
if (fromSlot != toSlot) {
|
||||
ToolChangeFailLoadToFinda(tc, fromSlot, toSlot);
|
||||
ToolChangeFailLoadToFindaButton2FINDA(tc, toSlot);
|
||||
ToolChangeFailLoadToFindaRightBtnFINDA(tc, toSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,27 +115,27 @@ TEST_CASE("buttons::Step-debounce-one-button", "[buttons]") {
|
|||
b.Step(); // should detect the press but remain in detected state - wait for debounce
|
||||
mt::IncMillis();
|
||||
}
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
|
||||
// 1023
|
||||
for (uint8_t i = 0; i < oversampleFactor; ++i) {
|
||||
b.Step(); // reset to waiting
|
||||
mt::IncMillis();
|
||||
}
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
|
||||
// 5
|
||||
for (uint8_t i = 0; i < oversampleFactor; ++i) {
|
||||
b.Step(); // pressed again, still in debouncing state
|
||||
mt::IncMillis();
|
||||
}
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
|
||||
// 9
|
||||
for (uint8_t i = 0; i < oversampleFactor; ++i) {
|
||||
|
|
@ -151,43 +151,43 @@ TEST_CASE("buttons::Step-debounce-one-button", "[buttons]") {
|
|||
b.Step(); // no change
|
||||
mt::IncMillis();
|
||||
}
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
|
||||
// 7
|
||||
for (uint8_t i = 0; i < oversampleFactor; ++i) {
|
||||
b.Step(); // one step from "pressed"
|
||||
mt::IncMillis();
|
||||
}
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
|
||||
// 8
|
||||
for (uint8_t i = 0; i < oversampleFactor; ++i) {
|
||||
b.Step(); // fifth set of samples - should report "pressed" finally
|
||||
mt::IncMillis();
|
||||
}
|
||||
CHECK(b.ButtonPressed(mb::Left));
|
||||
CHECK(b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
|
||||
// 1023
|
||||
for (uint8_t i = 0; i < oversampleFactor; ++i) {
|
||||
b.Step(); // sixth set of samples - button released (no debouncing on release)
|
||||
mt::IncMillis();
|
||||
}
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
|
||||
// 1023
|
||||
for (uint8_t i = 0; i < oversampleFactor; ++i) {
|
||||
b.Step(); // seventh set of samples - still released
|
||||
mt::IncMillis();
|
||||
}
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Right));
|
||||
CHECK(!b.ButtonPressed(mb::Middle));
|
||||
CHECK(!b.ButtonPressed(mb::Left));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue