From 6f982e25059beac43da0e54e87cef28f4101ca54 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 10 Nov 2021 08:24:51 +0100 Subject: [PATCH] Cleanup compiler warnings --- .../logic/cut_filament/test_cut_filament.cpp | 4 ++-- .../unit/logic/failing_tmc/test_failing_tmc.cpp | 4 ++-- .../feed_to_bondtech/test_feed_to_bondtech.cpp | 8 ++++---- .../logic/feed_to_finda/test_feed_to_finda.cpp | 8 ++++---- .../logic/load_filament/test_load_filament.cpp | 8 ++++---- tests/unit/logic/stubs/main_loop_stub.h | 2 +- .../unit/logic/tool_change/test_tool_change.cpp | 17 ++++++----------- .../unload_filament/test_unload_filament.cpp | 4 ++-- .../unload_to_finda/test_unload_to_finda.cpp | 8 ++++---- 9 files changed, 29 insertions(+), 34 deletions(-) diff --git a/tests/unit/logic/cut_filament/test_cut_filament.cpp b/tests/unit/logic/cut_filament/test_cut_filament.cpp index 9f195ee..e938bff 100644 --- a/tests/unit/logic/cut_filament/test_cut_filament.cpp +++ b/tests/unit/logic/cut_filament/test_cut_filament.cpp @@ -44,7 +44,7 @@ void CutSlot(logic::CutFilament &cf, uint8_t cutSlot) { // prepare for simulated finda trigger REQUIRE(WhileCondition( cf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if( step == 100 ){ // simulate FINDA trigger - will get pressed in 100 steps (due to debouncing) hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high); } @@ -56,7 +56,7 @@ void CutSlot(logic::CutFilament &cf, uint8_t cutSlot) { // pull it back to the pulley + simulate FINDA depress REQUIRE(WhileCondition( cf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if( step == 100 ){ // simulate FINDA trigger - will get depressed in 100 steps hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); } diff --git a/tests/unit/logic/failing_tmc/test_failing_tmc.cpp b/tests/unit/logic/failing_tmc/test_failing_tmc.cpp index 9103b24..8f8c47f 100644 --- a/tests/unit/logic/failing_tmc/test_failing_tmc.cpp +++ b/tests/unit/logic/failing_tmc/test_failing_tmc.cpp @@ -54,10 +54,10 @@ void FailingIdler(hal::tmc2130::ErrorFlags ef, ErrorCode ec) { REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), 0, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda)); - int failingStep = 5; + uint32_t failingStep = 5; REQUIRE(WhileCondition( uf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == failingStep){ // on 5th step make the TMC report some error CauseTMCError(mm::Idler, ef); } diff --git a/tests/unit/logic/feed_to_bondtech/test_feed_to_bondtech.cpp b/tests/unit/logic/feed_to_bondtech/test_feed_to_bondtech.cpp index 0d24e30..4f65c99 100644 --- a/tests/unit/logic/feed_to_bondtech/test_feed_to_bondtech.cpp +++ b/tests/unit/logic/feed_to_bondtech/test_feed_to_bondtech.cpp @@ -44,7 +44,7 @@ TEST_CASE("feed_to_bondtech::feed_phase_unlimited", "[feed_to_bondtech]") { // engaging idler REQUIRE(WhileCondition( fb, - [&](int) { return !mi::idler.Engaged(); }, + [&](uint32_t) { return !mi::idler.Engaged(); }, 5000)); CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(0).v); @@ -58,7 +58,7 @@ TEST_CASE("feed_to_bondtech::feed_phase_unlimited", "[feed_to_bondtech]") { REQUIRE(WhileCondition( fb, - [&](int step) { + [&](uint32_t step) { if( step == 1000 ){ mfs::fsensor.ProcessMessage(true); } @@ -71,14 +71,14 @@ TEST_CASE("feed_to_bondtech::feed_phase_unlimited", "[feed_to_bondtech]") { REQUIRE(fb.State() == FeedToBondtech::PushingFilamentIntoNozzle); REQUIRE(WhileCondition( fb, - [&](int) { return fb.State() == FeedToBondtech::PushingFilamentIntoNozzle; }, + [&](uint32_t) { return fb.State() == FeedToBondtech::PushingFilamentIntoNozzle; }, 5000)); // disengaging idler REQUIRE(fb.State() == FeedToBondtech::DisengagingIdler); REQUIRE(WhileCondition( fb, - [&](int) { return fb.State() == FeedToBondtech::DisengagingIdler; }, + [&](uint32_t) { return fb.State() == FeedToBondtech::DisengagingIdler; }, 5000)); CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(5).v); diff --git a/tests/unit/logic/feed_to_finda/test_feed_to_finda.cpp b/tests/unit/logic/feed_to_finda/test_feed_to_finda.cpp index e6355f6..e53661c 100644 --- a/tests/unit/logic/feed_to_finda/test_feed_to_finda.cpp +++ b/tests/unit/logic/feed_to_finda/test_feed_to_finda.cpp @@ -43,7 +43,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") { // engaging idler REQUIRE(WhileCondition( ff, - [&](int) { return !mi::idler.Engaged(); }, + [&](uint32_t) { return !mi::idler.Engaged(); }, 5000)); CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(0).v); @@ -60,7 +60,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") { REQUIRE(WhileCondition( ff, - [&](int) { return ff.State() == FeedToFinda::PushingFilament; }, + [&](uint32_t) { return ff.State() == FeedToFinda::PushingFilament; }, 1500)); // From now on the FINDA is reported as ON @@ -111,7 +111,7 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") { // engaging idler REQUIRE(WhileCondition( ff, - [&](int) { return !mi::idler.Engaged(); }, + [&](uint32_t) { return !mi::idler.Engaged(); }, 5000)); CHECK(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(0).v); @@ -127,7 +127,7 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") { REQUIRE(WhileCondition( ff, - [&](int) { return ff.State() == FeedToFinda::PushingFilament; }, + [&](uint32_t) { return ff.State() == FeedToFinda::PushingFilament; }, 5000)); // the FINDA didn't trigger, we should be in the Failed state diff --git a/tests/unit/logic/load_filament/test_load_filament.cpp b/tests/unit/logic/load_filament/test_load_filament.cpp index 3be0aa5..958d5f3 100644 --- a/tests/unit/logic/load_filament/test_load_filament.cpp +++ b/tests/unit/logic/load_filament/test_load_filament.cpp @@ -47,7 +47,7 @@ void LoadFilamentSuccessful(uint8_t slot, logic::LoadFilament &lf) { // we'll assume the finda is working correctly here REQUIRE(WhileCondition( lf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 100){ // on 100th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high); } @@ -59,7 +59,7 @@ void LoadFilamentSuccessful(uint8_t slot, logic::LoadFilament &lf) { // we'll assume the finda is working correctly here REQUIRE(WhileCondition( lf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 50){ // on 50th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); } @@ -113,7 +113,7 @@ void FailedLoadToFindaResolveHelpFindaTriggered(uint8_t slot, logic::LoadFilamen // Stage 5 - move the pulley a bit - simulate FINDA depress REQUIRE(WhileCondition( lf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 100){ // on 100th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high); } @@ -144,7 +144,7 @@ void FailedLoadToFindaResolveManual(uint8_t slot, logic::LoadFilament &lf) { // we'll assume the finda is working correctly here REQUIRE(WhileCondition( lf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 50){ // on 50th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); } diff --git a/tests/unit/logic/stubs/main_loop_stub.h b/tests/unit/logic/stubs/main_loop_stub.h index e647f4d..0e2a5a0 100644 --- a/tests/unit/logic/stubs/main_loop_stub.h +++ b/tests/unit/logic/stubs/main_loop_stub.h @@ -19,7 +19,7 @@ bool WhileCondition(SM &sm, COND cond, uint32_t maxLoops = 5000) { template bool WhileTopState(SM &sm, ProgressCode state, uint32_t maxLoops = 5000) { return WhileCondition( - sm, [&](int) { return sm.TopLevelState() == state; }, maxLoops); + sm, [&](uint32_t) { return sm.TopLevelState() == state; }, maxLoops); } extern void EnsureActiveSlotIndex(uint8_t slot, modules::globals::FilamentLoadState loadState); diff --git a/tests/unit/logic/tool_change/test_tool_change.cpp b/tests/unit/logic/tool_change/test_tool_change.cpp index e9c56c2..714f51d 100644 --- a/tests/unit/logic/tool_change/test_tool_change.cpp +++ b/tests/unit/logic/tool_change/test_tool_change.cpp @@ -25,7 +25,7 @@ void FeedingToFinda(logic::ToolChange &tc, uint8_t toSlot, uint32_t triggerAt = // feeding to finda REQUIRE(WhileCondition( tc, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == triggerAt){ // on specified stepNr make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high); } else if(step >= triggerAt + config::findaDebounceMs + 1){ @@ -40,7 +40,7 @@ void FeedingToBondtech(logic::ToolChange &tc, uint8_t toSlot) { // james is feeding REQUIRE(WhileCondition( tc, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 2000){ // on 2000th step make filament sensor trigger mfs::fsensor.ProcessMessage(true); } @@ -65,18 +65,13 @@ void ToolChange(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) { REQUIRE(WhileCondition( tc, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 2000){ // on 2000th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); } return tc.TopLevelState() == ProgressCode::UnloadingFilament; }, 200000UL)); - auto gf = ml::leds.Mode(fromSlot, ml::green); - auto gt = ml::leds.Mode(toSlot, ml::green); - auto rf = ml::leds.Mode(fromSlot, ml::red); - auto rt = ml::leds.Mode(toSlot, ml::red); - // REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::AtPulley); REQUIRE(VerifyState2(tc, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), fromSlot, false, false, toSlot, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda)); @@ -174,7 +169,7 @@ void ToolChangeFailLoadToFinda(logic::ToolChange &tc, uint8_t fromSlot, uint8_t REQUIRE(WhileCondition( tc, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 2000){ // on 2000th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); } @@ -202,7 +197,7 @@ void ToolChangeFailLoadToFindaButton0(logic::ToolChange &tc, uint8_t toSlot) { // try push more, if FINDA triggers, continue loading REQUIRE(WhileCondition( tc, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 20){ // on 20th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high); } @@ -222,7 +217,7 @@ void ToolChangeFailLoadToFindaButton1(logic::ToolChange &tc, uint8_t toSlot) { REQUIRE(WhileCondition( tc, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 2000){ // on 2000th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); } diff --git a/tests/unit/logic/unload_filament/test_unload_filament.cpp b/tests/unit/logic/unload_filament/test_unload_filament.cpp index 6e94069..ef1f152 100644 --- a/tests/unit/logic/unload_filament/test_unload_filament.cpp +++ b/tests/unit/logic/unload_filament/test_unload_filament.cpp @@ -52,7 +52,7 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf) { // Stage 1 - unloading to FINDA REQUIRE(WhileCondition( uf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 100){ // on 100th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); } @@ -181,7 +181,7 @@ void FindaDidntTriggerResolveHelpFindaTriggered(uint8_t slot, logic::UnloadFilam // Stage 5 - move the pulley a bit - simulate FINDA depress REQUIRE(WhileCondition( uf, - [&](int step) -> bool { + [&](uint32_t step) -> bool { if(step == 100){ // on 100th step make FINDA trigger hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); } diff --git a/tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp b/tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp index 2bf0998..712a5bc 100644 --- a/tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp +++ b/tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp @@ -45,7 +45,7 @@ TEST_CASE("unload_to_finda::regular_unload", "[unload_to_finda]") { // engaging idler REQUIRE(WhileCondition( ff, - [&](int) { return !mi::idler.Engaged(); }, + [&](uint32_t) { return !mi::idler.Engaged(); }, 5000)); CHECK(mm::axes[mm::Pulley].enabled == true); @@ -54,7 +54,7 @@ TEST_CASE("unload_to_finda::regular_unload", "[unload_to_finda]") { hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); REQUIRE(WhileCondition( ff, - [&](int) { return mf::finda.Pressed(); }, + [&](uint32_t) { return mf::finda.Pressed(); }, 50000)); REQUIRE(ff.State() == logic::UnloadToFinda::OK); @@ -100,7 +100,7 @@ TEST_CASE("unload_to_finda::unload_without_FINDA_trigger", "[unload_to_finda]") // engaging idler REQUIRE(WhileCondition( ff, - [&](int) { return !mi::idler.Engaged(); }, + [&](uint32_t) { return !mi::idler.Engaged(); }, 5000)); // now pulling the filament until finda triggers @@ -109,7 +109,7 @@ TEST_CASE("unload_to_finda::unload_without_FINDA_trigger", "[unload_to_finda]") // no changes to FINDA during unload - we'll pretend it never triggers REQUIRE_FALSE(WhileCondition( ff, - [&](int) { return mf::finda.Pressed(); }, + [&](uint32_t) { return mf::finda.Pressed(); }, 50000)); REQUIRE(ff.State() == logic::UnloadToFinda::Failed);