diff --git a/src/logic/command_base.cpp b/src/logic/command_base.cpp index 3893a9c..e091e5c 100644 --- a/src/logic/command_base.cpp +++ b/src/logic/command_base.cpp @@ -3,6 +3,7 @@ #include "../modules/selector.h" #include "../modules/motion.h" #include "../modules/leds.h" +#include "../modules/user_input.h" namespace logic { @@ -96,4 +97,11 @@ bool CommandBase::CheckToolIndex(uint8_t index) { } } +void CommandBase::ErrDisengagingIdler() { + if (!mi::idler.Engaged()) { + state = ProgressCode::ERRWaitingForUser; + mui::userInput.Clear(); // remove all buffered events if any just before we wait for some input + } +} + } // namespace logic diff --git a/src/logic/command_base.h b/src/logic/command_base.h index f57a9b9..2be8b08 100644 --- a/src/logic/command_base.h +++ b/src/logic/command_base.h @@ -74,6 +74,9 @@ protected: /// If not, it returns false and sets the error to ErrorCode::INVALID_TOOL bool CheckToolIndex(uint8_t index); + /// Common error processing - disengaging idler + void ErrDisengagingIdler(); + ProgressCode state; ///< current progress state of the state machine ErrorCode error; ///< current error code };