Prechádzať zdrojové kódy

PFW-1362 SpoolJoin needs to known what the previous slot was

Guðni Már Gilbert 2 rokov pred
rodič
commit
63b4abb66d
3 zmenil súbory, kde vykonal 13 pridanie a 1 odobranie
  1. 6 1
      Firmware/SpoolJoin.cpp
  2. 4 0
      Firmware/SpoolJoin.h
  3. 3 0
      Firmware/mmu2.cpp

+ 6 - 1
Firmware/SpoolJoin.cpp

@@ -58,12 +58,17 @@ uint8_t SpoolJoin::isSpoolJoinEnabled()
     }
 }
 
+void SpoolJoin::setSlot(uint8_t slot)
+{
+    currentMMUSlot = slot;
+}
 
 uint8_t SpoolJoin::nextSlot()
 {
     SERIAL_ECHOPGM("SpoolJoin: Changing slot from ");
     SERIAL_ECHO((int)currentMMUSlot);
-    if (currentMMUSlot == 4) currentMMUSlot = 0;
+
+    if (currentMMUSlot >= 4) currentMMUSlot = 0;
     else currentMMUSlot++;
 
     SERIAL_ECHOPGM(" to ");

+ 4 - 0
Firmware/SpoolJoin.h

@@ -33,6 +33,10 @@ public:
     /// @brief Check if SpoolJoin is enabled
     uint8_t isSpoolJoinEnabled();
 
+    /// @brief Update the saved MMU slot number so SpoolJoin can determine the next slot to use
+    /// @param slot number of the slot to set
+    void setSlot(uint8_t slot);
+
     /// @brief Fetch the next slot number should count from 0 to 4.
     /// When filament slot 4 is depleted, the next slot should be 0.
     /// @returns the next slot, ranges from 0 to 4

+ 3 - 0
Firmware/mmu2.cpp

@@ -307,6 +307,7 @@ bool MMU2::tool_change(uint8_t index) {
         plan_set_e_position(current_position[E_AXIS]);
 
         extruder = index; //filament change is finished
+        SpoolJoin::spooljoin.setSlot(index);
 
         // @@TODO really report onto the serial? May be for the Octoprint? Not important now
         //        SERIAL_ECHO_START();
@@ -339,6 +340,7 @@ bool MMU2::tool_change(char code, uint8_t slot) {
         logic.ToolChange(slot);
         manage_response(false, false);
         extruder = slot;
+        SpoolJoin::spooljoin.setSlot(slot);
         set_extrude_min_temp(EXTRUDE_MINTEMP);
     } break;
 
@@ -485,6 +487,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t index) {
         execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0]));
 
         extruder = index;
+        SpoolJoin::spooljoin.setSlot(index);
 
         Sound_MakeSound(e_SOUND_TYPE_StandardConfirm);
     }