Przeglądaj źródła

Introduce a way to read the previous tool used

Guðni Már Gilbert 2 lat temu
rodzic
commit
d5cdb412ba
3 zmienionych plików z 9 dodań i 1 usunięć
  1. 1 1
      Firmware/Marlin_main.cpp
  2. 4 0
      Firmware/mmu2.cpp
  3. 4 0
      Firmware/mmu2.h

+ 1 - 1
Firmware/Marlin_main.cpp

@@ -3511,7 +3511,7 @@ static void mmu_M600_wait_and_beep() {
 /// @brief load filament for mmu v2
 /// @par nozzle_temp nozzle temperature to load filament
 void mmu_M600_load_filament(bool automatic, float nozzle_temp) {
-    uint8_t tmp_extruder = MMU2::mmu2.get_current_tool();
+    uint8_t tmp_extruder = MMU2::mmu2.get_previous_tool();
 
     // TODO SpoolJoin
     /*if (automatic) {

+ 4 - 0
Firmware/mmu2.cpp

@@ -85,6 +85,7 @@ MMU2::MMU2()
     : is_mmu_error_monitor_active(false)
     , logic(&mmu2Serial)
     , extruder(MMU2_NO_TOOL)
+    , previous_extruder(MMU2_NO_TOOL)
     , resume_position()
     , resume_hotend_temp(0)
     , logicStepLastStatus(StepStatus::Finished)
@@ -228,6 +229,7 @@ bool MMU2::tool_change(uint8_t index) {
 //        SERIAL_ECHOLN(current_position[E_AXIS]);
 
         extruder = index; //filament change is finished
+        previous_extruder = extruder;
         SetActiveExtruder(0);
 
         // @@TODO really report onto the serial? May be for the Octoprint? Not important now
@@ -260,6 +262,7 @@ bool MMU2::tool_change(char code, uint8_t slot) {
         logic.ToolChange(slot);
         manage_response(false, false);
         extruder = slot;
+        previous_extruder = extruder;
         SetActiveExtruder(0);
         set_extrude_min_temp(EXTRUDE_MINTEMP);
     } break;
@@ -383,6 +386,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;
+        previous_extruder = extruder;
         SetActiveExtruder(0);
 
         Sound_MakeSound(e_SOUND_TYPE_StandardConfirm);

+ 4 - 0
Firmware/mmu2.h

@@ -107,6 +107,9 @@ public:
     
     /// @returns the active filament slot index (0-4) or 0xff in case of no active tool
     uint8_t get_current_tool() const;
+
+    /// @returns the previous active filament slot index (0-4) or 0xff in case of no active tool at boot-up
+    inline uint8_t get_previous_tool() const { return previous_extruder; };
     
     bool set_filament_type(uint8_t index, uint8_t type);
 
@@ -201,6 +204,7 @@ private:
     
     ProtocolLogic logic; ///< implementation of the protocol logic layer
     int extruder; ///< currently active slot in the MMU ... somewhat... not sure where to get it from yet
+    uint8_t previous_extruder; ///< last active slot in the MMU, useful for M600
 
     xyz_pos_t resume_position;
     int16_t resume_hotend_temp;