From f01d3a342f23b53a0b39165ca635978fd2942d07 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 21 Sep 2021 14:55:52 +0200 Subject: [PATCH 1/2] Fix unit test compatibility with mingw change __mingw32__ to __win32__ --- tests/unit/modules/motion/rampgen.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unit/modules/motion/rampgen.cpp b/tests/unit/modules/motion/rampgen.cpp index f917167..940fe0f 100644 --- a/tests/unit/modules/motion/rampgen.cpp +++ b/tests/unit/modules/motion/rampgen.cpp @@ -1,5 +1,11 @@ #include +#ifndef __WIN32__ #include +#else +#define EX_OK 0 +#define EX_USAGE 64 +#define EX_OSERR 71 +#endif #include "motion.h" using namespace modules::motion; From d3d992da5b4b28baf364c258afa765e24478165e Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 23 Sep 2021 09:36:43 +0200 Subject: [PATCH 2/2] Cheange LED modes to be consistent. --- src/logic/feed_to_bondtech.cpp | 4 ++-- src/logic/feed_to_finda.cpp | 8 ++++---- src/logic/load_filament.cpp | 4 ++-- src/logic/unload_to_finda.cpp | 2 +- src/main.cpp | 14 +++++++------- .../feed_to_bondtech/test_feed_to_bondtech.cpp | 4 ++-- .../logic/feed_to_finda/test_feed_to_finda.cpp | 8 ++++---- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/logic/feed_to_bondtech.cpp b/src/logic/feed_to_bondtech.cpp index 084a1ea..f17e287 100644 --- a/src/logic/feed_to_bondtech.cpp +++ b/src/logic/feed_to_bondtech.cpp @@ -22,7 +22,7 @@ bool FeedToBondtech::Step() { case EngagingIdler: if (mi::idler.Engaged()) { state = PushingFilament; - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::blink0); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); mm::motion.PlanMove(mm::Pulley, steps, 4500); //@@TODO constants - there was some strange acceleration sequence in the original FW, // we can probably hand over some array of constants for hand-tuned acceleration + leverage some smoothing in the stepper as well } @@ -42,7 +42,7 @@ bool FeedToBondtech::Step() { // case DisengagingIdler: // if (!mi::idler.Engaged()) { // state = OK; - // ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::on); + // ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on); // } // return false; case OK: diff --git a/src/logic/feed_to_finda.cpp b/src/logic/feed_to_finda.cpp index d527023..2b1130f 100644 --- a/src/logic/feed_to_finda.cpp +++ b/src/logic/feed_to_finda.cpp @@ -23,7 +23,7 @@ bool FeedToFinda::Step() { case EngagingIdler: if (mi::idler.Engaged() && ms::selector.Slot() == mg::globals.ActiveSlot()) { state = PushingFilament; - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::blink0); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); mm::motion.PlanMove(mm::Pulley, feedPhaseLimited ? 1500 : 32767, 4000); //@@TODO constants mui::userInput.Clear(); // remove all buffered events if any just before we wait for some input } @@ -37,8 +37,8 @@ bool FeedToFinda::Step() { } else if (mm::motion.QueueEmpty()) { // all moves have been finished and FINDA didn't switch on state = Failed; // @@TODO - shall we disengage the idler? - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::off); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::red, ml::blink0); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); } } return false; @@ -51,7 +51,7 @@ bool FeedToFinda::Step() { // case DisengagingIdler: // if (!mi::idler.Engaged()) { state = OK; - // ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::on); + // ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on); } // @@TODO FINDA must be reported as OFF again as we are pulling the filament from it - is this correct? return false; diff --git a/src/logic/load_filament.cpp b/src/logic/load_filament.cpp index cafebe2..44e9961 100644 --- a/src/logic/load_filament.cpp +++ b/src/logic/load_filament.cpp @@ -41,8 +41,8 @@ bool LoadFilament::StepInner() { state = ProgressCode::ERRDisengagingIdler; error = ErrorCode::FINDA_DIDNT_SWITCH_ON; mi::idler.Disengage(); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::off); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::red, ml::Mode::blink0); // signal loading error + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); // signal loading error } else { state = ProgressCode::FeedingToBondtech; james.Reset(config::feedToBondtechMaxRetries); diff --git a/src/logic/unload_to_finda.cpp b/src/logic/unload_to_finda.cpp index 1d63cfc..aaf3c1c 100644 --- a/src/logic/unload_to_finda.cpp +++ b/src/logic/unload_to_finda.cpp @@ -30,7 +30,7 @@ bool UnloadToFinda::Step() { mm::motion.PlanMove(mm::Pulley, -1400, 6000); // @@TODO constants mm::motion.PlanMove(mm::Pulley, -1800 + 1400, 2500); // @@TODO constants 1800-1400 = 400 mm::motion.PlanMove(mm::Pulley, -second_point + 1800, 550); // @@TODO constants - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::blink0); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); } return false; case WaitingForFINDA: diff --git a/src/main.cpp b/src/main.cpp index 2544f4d..a1eb58a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -104,7 +104,7 @@ void setup() { // watchdog init shr16::shr16.Init(); - ml::leds.SetMode(4, ml::Color::green, ml::Mode::on); + ml::leds.SetMode(4, ml::green, ml::on); ml::leds.Step(); // @@TODO if the shift register doesn't work we really can't signalize anything, only internal variables will be accessible if the UART works @@ -115,7 +115,7 @@ void setup() { .baudrate = 115200, }; hu::usart1.Init(&usart_conf); - ml::leds.SetMode(3, ml::Color::green, ml::Mode::on); + ml::leds.SetMode(3, ml::green, ml::on); ml::leds.Step(); // @@TODO if both shift register and the UART are dead, we are sitting ducks :( @@ -130,21 +130,21 @@ void setup() { .cpol = 1, }; spi::Init(SPI0, &spi_conf); - ml::leds.SetMode(2, ml::Color::green, ml::Mode::on); + ml::leds.SetMode(2, ml::green, ml::on); ml::leds.Step(); mm::Init(); - ml::leds.SetMode(1, ml::Color::green, ml::Mode::on); + ml::leds.SetMode(1, ml::green, ml::on); ml::leds.Step(); adc::Init(); - ml::leds.SetMode(0, ml::Color::green, ml::Mode::on); + ml::leds.SetMode(0, ml::green, ml::on); ml::leds.Step(); /// Turn off all leds for (uint8_t i = 0; i < config::toolCount; i++) { - ml::leds.SetMode(i, ml::Color::green, ml::Mode::off); - ml::leds.SetMode(i, ml::Color::red, ml::Mode::off); + ml::leds.SetMode(i, ml::green, ml::off); + ml::leds.SetMode(i, ml::red, ml::off); } ml::leds.Step(); } 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 3e0c3ae..16fd834 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 @@ -52,7 +52,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") { // idler engaged, selector in position, we'll start pushing filament REQUIRE(fb.State() == FeedToBondtech::PushingFilament); // at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test) - REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::Color::green)); + REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::green)); REQUIRE(WhileCondition( fb, @@ -77,7 +77,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") { // state machine finished ok, the green LED should be on REQUIRE(fb.State() == FeedToBondtech::OK); - // REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::Color::green)); + // REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::green)); REQUIRE(fb.Step() == true); // the automaton finished its work, any consecutive calls to Step must return true } 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 233c413..3398647 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 @@ -52,7 +52,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") { // idler engaged, selector in position, we'll start pushing filament REQUIRE(ff.State() == FeedToFinda::PushingFilament); // at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test) - REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::Color::green)); + REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::green)); // now let the filament be pushed into the FINDA - do 500 steps without triggering the condition hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high); @@ -117,7 +117,7 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") { // idler engaged, we'll start pushing filament REQUIRE(ff.State() == FeedToFinda::PushingFilament); // at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test) - REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::Color::green) == ml::blink0); + REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::green) == ml::blink0); // now let the filament be pushed into the FINDA - but we make sure the FINDA doesn't trigger at all hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); @@ -129,8 +129,8 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") { // the FINDA didn't trigger, we should be in the Failed state REQUIRE(ff.State() == FeedToFinda::Failed); - REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::Color::green) == ml::off); - REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::Color::red) == ml::blink0); + REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::green) == ml::off); + REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::red) == ml::blink0); REQUIRE(ff.Step() == true); // the automaton finished its work, any consecutive calls to Step must return true }