ToolChange: don't disengage Idler after unload, but engage next slot immediately
parent
5d8fa524fb
commit
f4388b8d20
|
|
@ -39,7 +39,7 @@ bool ToolChange::Reset(uint8_t param) {
|
||||||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||||
dbg_logic_P(PSTR("Filament is loaded --> unload"));
|
dbg_logic_P(PSTR("Filament is loaded --> unload"));
|
||||||
state = ProgressCode::UnloadingFilament;
|
state = ProgressCode::UnloadingFilament;
|
||||||
unl.Reset(mg::globals.ActiveSlot());
|
unl.Reset2(mg::globals.ActiveSlot());
|
||||||
} else {
|
} else {
|
||||||
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector); // activate the correct slot, feed uses that
|
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector); // activate the correct slot, feed uses that
|
||||||
if (feed.Reset(true, false)) {
|
if (feed.Reset(true, false)) {
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,18 @@ bool UnloadFilament::Reset(uint8_t /*param*/) {
|
||||||
mpu::pulley.InitAxis();
|
mpu::pulley.InitAxis();
|
||||||
state = ProgressCode::UnloadingToFinda;
|
state = ProgressCode::UnloadingToFinda;
|
||||||
error = ErrorCode::RUNNING;
|
error = ErrorCode::RUNNING;
|
||||||
|
skipDisengagingIdler = false;
|
||||||
unl.Reset(maxRetries);
|
unl.Reset(maxRetries);
|
||||||
ml::leds.SetAllOff();
|
ml::leds.SetAllOff();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UnloadFilament::Reset2(uint8_t param) {
|
||||||
|
bool rv = Reset(param);
|
||||||
|
skipDisengagingIdler = true;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
void UnloadFilament::UnloadFinishedCorrectly() {
|
void UnloadFilament::UnloadFinishedCorrectly() {
|
||||||
FinishedOK();
|
FinishedOK();
|
||||||
mpu::pulley.Disable();
|
mpu::pulley.Disable();
|
||||||
|
|
@ -77,9 +84,13 @@ bool UnloadFilament::StepInner() {
|
||||||
GoToErrDisengagingIdler(ErrorCode::FINDA_DIDNT_SWITCH_OFF); // signal unloading error
|
GoToErrDisengagingIdler(ErrorCode::FINDA_DIDNT_SWITCH_OFF); // signal unloading error
|
||||||
} else {
|
} else {
|
||||||
state = ProgressCode::DisengagingIdler;
|
state = ProgressCode::DisengagingIdler;
|
||||||
|
if (skipDisengagingIdler && ms::selector.State() == ms::Selector::Ready) {
|
||||||
|
UnloadFinishedCorrectly(); // skip disengaging the Idler - to be used inside ToolChange to speed up
|
||||||
|
} else {
|
||||||
mi::idler.Disengage();
|
mi::idler.Disengage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case ProgressCode::DisengagingIdler:
|
case ProgressCode::DisengagingIdler:
|
||||||
if (mi::idler.Disengaged() && ms::selector.State() == ms::Selector::Ready) {
|
if (mi::idler.Disengaged() && ms::selector.State() == ms::Selector::Ready) {
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,15 @@ namespace logic {
|
||||||
class UnloadFilament : public CommandBase {
|
class UnloadFilament : public CommandBase {
|
||||||
public:
|
public:
|
||||||
inline constexpr UnloadFilament()
|
inline constexpr UnloadFilament()
|
||||||
: CommandBase() {}
|
: CommandBase()
|
||||||
|
, skipDisengagingIdler(false) {}
|
||||||
|
|
||||||
/// Restart the automaton
|
/// Restart the automaton
|
||||||
/// @param param is not used, always unloads from the active slot
|
/// @param param is not used, always unloads from the active slot
|
||||||
bool Reset(uint8_t param) override;
|
bool Reset(uint8_t param) override;
|
||||||
|
|
||||||
|
bool Reset2(uint8_t param);
|
||||||
|
|
||||||
/// @returns true if the state machine finished its job, false otherwise
|
/// @returns true if the state machine finished its job, false otherwise
|
||||||
bool StepInner() override;
|
bool StepInner() override;
|
||||||
|
|
||||||
|
|
@ -32,6 +35,7 @@ private:
|
||||||
UnloadToFinda unl;
|
UnloadToFinda unl;
|
||||||
FeedToFinda feed;
|
FeedToFinda feed;
|
||||||
RetractFromFinda retract;
|
RetractFromFinda retract;
|
||||||
|
bool skipDisengagingIdler;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The one and only instance of UnloadFilament state machine in the FW
|
/// The one and only instance of UnloadFilament state machine in the FW
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ Idler::OperationResult Idler::PlanMoveInner(uint8_t slot, Operation plannedOp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// already engaged or disengaged
|
// already engaged or disengaged
|
||||||
if (currentlyEngaged == plannedMove) {
|
if (currentlyEngaged == plannedMove && currentSlot == plannedSlot) {
|
||||||
return OperationResult::Accepted;
|
return OperationResult::Accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue