From 5eedeb09681edcb51ee00fdd882752ba6a678e7e Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Thu, 23 Sep 2021 10:03:14 +0200 Subject: [PATCH] Remove redundant ::Color and ::Mode for LED colors and modes makes the code shorter and more readable, no identifier clashes revealed --- src/logic/feed_to_bondtech.cpp | 2 +- src/logic/feed_to_finda.cpp | 2 +- src/logic/unload_filament.cpp | 16 ++++++++-------- src/logic/unload_to_finda.cpp | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/logic/feed_to_bondtech.cpp b/src/logic/feed_to_bondtech.cpp index 7c3dab6..34def0c 100644 --- a/src/logic/feed_to_bondtech.cpp +++ b/src/logic/feed_to_bondtech.cpp @@ -20,7 +20,7 @@ void FeedToBondtech::Reset(uint8_t maxRetries) { #endif //DEBUG_LOGIC state = EngagingIdler; this->maxRetries = maxRetries; - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::blink0); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); mi::idler.Engage(mg::globals.ActiveSlot()); } diff --git a/src/logic/feed_to_finda.cpp b/src/logic/feed_to_finda.cpp index 2dd52de..fd363c5 100644 --- a/src/logic/feed_to_finda.cpp +++ b/src/logic/feed_to_finda.cpp @@ -13,7 +13,7 @@ namespace logic { void FeedToFinda::Reset(bool feedPhaseLimited) { state = EngagingIdler; this->feedPhaseLimited = feedPhaseLimited; - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::blink0); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); mi::idler.Engage(mg::globals.ActiveSlot()); // We can't get any FINDA readings if the selector is at the wrong spot - move it accordingly if necessary ms::selector.MoveToSlot(mg::globals.ActiveSlot()); diff --git a/src/logic/unload_filament.cpp b/src/logic/unload_filament.cpp index 4ac6a4f..2a12d96 100644 --- a/src/logic/unload_filament.cpp +++ b/src/logic/unload_filament.cpp @@ -22,8 +22,8 @@ void UnloadFilament::Reset(uint8_t /*param*/) { state = ProgressCode::UnloadingToFinda; error = ErrorCode::RUNNING; unl.Reset(maxRetries); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::Mode::off); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::Mode::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::off); } bool UnloadFilament::StepInner() { @@ -35,8 +35,8 @@ bool UnloadFilament::StepInner() { // couldn't unload to FINDA, report error and wait for user to resolve it state = ProgressCode::ERRDisengagingIdler; error = ErrorCode::FINDA_DIDNT_SWITCH_OFF; - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::Mode::off); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::Mode::blink0); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); } else { state = ProgressCode::DisengagingIdler; } @@ -64,8 +64,8 @@ bool UnloadFilament::StepInner() { error = ErrorCode::OK; mm::motion.Disable(mm::Pulley); mg::globals.SetFilamentLoaded(false); // filament unloaded - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::Mode::off); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::Mode::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::off); } return false; case ProgressCode::ERRDisengagingIdler: // couldn't unload to FINDA @@ -86,8 +86,8 @@ bool UnloadFilament::StepInner() { Reset(0); //@@TODO validate the reset parameter break; case mui::Event::Right: // problem resolved - the user pulled the fillament by hand - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::Mode::off); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::Mode::on); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on); // mm::motion.PlanMove(mm::Pulley, 450, 5000); // @@TODO constants state = ProgressCode::AvoidingGrind; break; diff --git a/src/logic/unload_to_finda.cpp b/src/logic/unload_to_finda.cpp index 74a2c84..e9c4605 100644 --- a/src/logic/unload_to_finda.cpp +++ b/src/logic/unload_to_finda.cpp @@ -25,7 +25,7 @@ bool UnloadToFinda::Step() { case EngagingIdler: if (mg::globals.FilamentLoaded()) { state = UnloadingToFinda; - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::blink0); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); } else { state = Failed; } @@ -41,7 +41,7 @@ bool UnloadToFinda::Step() { // detected end of filament state = OK; mm::motion.AbortPlannedMoves(); // stop rotating the pulley - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::off); + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); } else if (/*tmc2130_read_gstat() &&*/ mm::motion.QueueEmpty()) { // we reached the end of move queue, but the FINDA didn't switch off // two possible causes - grinded filament or malfunctioning FINDA