Extract common ErrDisengagingIdler state's implementation

pull/122/head
D.R.racer 2021-09-27 09:45:47 +02:00
parent 53e48e0705
commit c6010456f7
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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
};