Switch from Start Seq into Idle immediately + disable FS autoload on MMU

This commit is contained in:
D.R.racer 2022-08-04 09:34:04 +02:00
parent 400fec5d9f
commit 14b2befb7d
3 changed files with 24 additions and 4 deletions

View File

@ -107,9 +107,17 @@ bool Filament_sensor::checkFilamentEvents() {
}
void Filament_sensor::triggerFilamentInserted() {
if (autoLoadEnabled && (eFilamentAction == FilamentAction::None) &&
!(moves_planned() || IS_SD_PRINTING || usb_timer.running() || (lcd_commands_type == LcdCommands::Layer1Cal) ||
eeprom_read_byte((uint8_t *)EEPROM_WIZARD_ACTIVE))) {
if (autoLoadEnabled
&& (eFilamentAction == FilamentAction::None)
&& (! MMU2::mmu2.Enabled() ) // quick and dirty hack to prevent spurious runouts while the MMU is in charge
&& !(
moves_planned()
|| IS_SD_PRINTING
|| usb_timer.running()
|| (lcd_commands_type == LcdCommands::Layer1Cal)
|| eeprom_read_byte((uint8_t *)EEPROM_WIZARD_ACTIVE)
)
) {
filAutoLoad();
}
}

View File

@ -180,7 +180,10 @@ StepStatus StartSeq::Step() {
break;
case State::FilamentSensorStateSent:
state = State::Ready;
return Finished;
logic->SwitchFromStartToIdle();
return Processing; // Returning Finished is not a good idea in case of a fast error recovery
// - it tells the printer, that the command which experienced a protocol error and recovered successfully actually terminated.
// In such a case we must return "Processing" in order to keep the MMU state machine running and prevent the printer from executing next G-codes.
break;
case State::RecoveringProtocolError:
// timer elapsed, clear the input buffer
@ -483,6 +486,14 @@ void ProtocolLogic::SwitchToIdle() {
idle.Restart();
}
void ProtocolLogic::SwitchFromStartToIdle(){
state = State::Running;
currentState = &idle;
idle.Restart();
idle.SendQuery(); // force sending Q0 immediately
idle.state = Idle::State::QuerySent;
}
bool ProtocolLogic::Elapsed(uint32_t timeout) const {
return _millis() >= (lastUARTActivityMs + timeout);
}

View File

@ -276,6 +276,7 @@ private:
void LogError(const char *reason);
void LogResponse();
void SwitchFromIdleToCommand();
void SwitchFromStartToIdle();
enum class State : uint_fast8_t {
Stopped, ///< stopped for whatever reason