Browse Source

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

D.R.racer 2 years ago
parent
commit
14b2befb7d
3 changed files with 24 additions and 4 deletions
  1. 11 3
      Firmware/Filament_sensor.cpp
  2. 12 1
      Firmware/mmu2_protocol_logic.cpp
  3. 1 0
      Firmware/mmu2_protocol_logic.h

+ 11 - 3
Firmware/Filament_sensor.cpp

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

+ 12 - 1
Firmware/mmu2_protocol_logic.cpp

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

+ 1 - 0
Firmware/mmu2_protocol_logic.h

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