Perform a re-check (LoadFilamentLimited) after successful LoadFilament

- [] Unit tests of unlimited LoadFilament need to be introduced as the complexity of this scenario is increasing

.
pull/173/head
D.R.racer 2022-05-11 07:44:34 +02:00 committed by DRracer
parent c5aea89cac
commit 6b06fed4b1
2 changed files with 23 additions and 6 deletions

View File

@ -21,6 +21,7 @@ void LoadFilament::Reset(uint8_t param) {
}
dbg_logic_P(PSTR("Load Filament"));
mg::globals.SetFilamentLoaded(param, mg::FilamentLoadState::AtPulley); // still at pulley, haven't moved yet
verifyLoadedFilament = 1;
Reset2(false);
}
@ -61,10 +62,12 @@ bool LoadFilament::StepInner() {
case FeedToFinda::Failed: // @@TODO - try to repeat 6x - push/pull sequence - probably something to put into feed_to_finda as an option
GoToErrDisengagingIdler(ErrorCode::FINDA_DIDNT_SWITCH_ON); // signal loading error
break;
case FeedToFinda::Stopped:
// as requested in MMU-116 - stopping an unsuccessful feed should retract as well but not check the filament
verifyLoadedFilament = 0;
// [[fallthrough]]
case FeedToFinda::OK:
case FeedToFinda::Stopped: // as requested in MMU-77 - stopping an unsuccessful feed should retract as well
state = ProgressCode::RetractingFromFinda;
retract.Reset();
GoToRetractingFromFinda();
break;
}
}
@ -74,8 +77,15 @@ bool LoadFilament::StepInner() {
if (retract.State() == RetractFromFinda::Failed) {
GoToErrDisengagingIdler(ErrorCode::FINDA_DIDNT_SWITCH_OFF); // signal loading error
} else {
state = ProgressCode::DisengagingIdler;
mi::idler.Disengage();
if (verifyLoadedFilament) {
--verifyLoadedFilament;
// as requested in MMU-116 - once the filament gets retracted after first feed, perform a short re-check
// by doing a limited load + retract. That ensures the filament can be loaded into the selector later when needed.
ResetLimited(mg::globals.ActiveSlot());
} else {
state = ProgressCode::DisengagingIdler;
mi::idler.Disengage();
}
}
}
break;

View File

@ -11,7 +11,8 @@ namespace logic {
class LoadFilament : public CommandBase {
public:
inline LoadFilament()
: CommandBase() {}
: CommandBase()
, verifyLoadedFilament(0) {}
/// Restart the automaton - performs unlimited rotation of the Pulley
/// @param param index of filament slot to load
@ -33,6 +34,12 @@ private:
FeedToFinda feed;
RetractFromFinda retract;
/// As requested in MMU-116:
/// Once the filament gets retracted after first feed, perform a short re-check by doing a limited load + retract.
/// That ensures the filament can be loaded into the selector later when needed.
/// verifyLoadedFilament holds the number of re-checks to be performed (we expect >1 re-checks will be requested one day ;) )
uint8_t verifyLoadedFilament;
};
/// The one and only instance of LoadFilament state machine in the FW