From 67d7be2b2d35e2a1f48abd1ad727114e0aba1b56 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Mon, 27 Nov 2023 07:11:19 +0100 Subject: [PATCH] MMU2: Report current tool onto the serial PFW-1546 --- Firmware/mmu2.cpp | 16 +++++++++++----- Firmware/mmu2.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 2735889a7..10c364359 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -72,7 +72,7 @@ void MMU2::Start() { PowerOn(); mmu2Serial.flush(); // make sure the UART buffer is clear before starting communication - extruder = MMU2_NO_TOOL; + SetCurrentTool(MMU2_NO_TOOL); state = xState::Connecting; // start the communication @@ -357,7 +357,7 @@ void MMU2::ToolChangeCommon(uint8_t slot) { static_cast(manage_response(true, true)); // yes, I'd like to silence [[nodiscard]] warning at this spot by casting to void } - extruder = slot; //filament change is finished + SetCurrentTool(slot); //filament change is finished SpoolJoin::spooljoin.setSlot(slot); ++toolchange_counter; @@ -428,6 +428,12 @@ uint8_t MMU2::get_tool_change_tool() const { return tool_change_extruder == MMU2_NO_TOOL ? (uint8_t)FILAMENT_UNKNOWN : tool_change_extruder; } +void MMU2::SetCurrentTool(uint8_t ex){ + extruder = ex; + MMU2_ECHO_MSGRPGM(PSTR("MMU2tool=")); + SERIAL_ECHOLN((int)ex); +} + bool MMU2::set_filament_type(uint8_t /*slot*/, uint8_t /*type*/) { if (!WaitForMMUReady()) return false; @@ -462,7 +468,7 @@ void MMU2::UnloadInner() { MakeSound(Confirm); // no active tool - extruder = MMU2_NO_TOOL; + SetCurrentTool(MMU2_NO_TOOL); tool_change_extruder = MMU2_NO_TOOL; } @@ -504,7 +510,7 @@ bool MMU2::cut_filament(uint8_t slot, bool enableFullScreenMsg /*= true*/) { ReportingRAII rep(CommandInProgress::CutFilament); CutFilamentInner(slot); - extruder = MMU2_NO_TOOL; + SetCurrentTool(MMU2_NO_TOOL); tool_change_extruder = MMU2_NO_TOOL; MakeSound(SoundType::Confirm); } @@ -587,7 +593,7 @@ bool MMU2::eject_filament(uint8_t slot, bool enableFullScreenMsg /* = true */) { break; IncrementMMUFails(); } - extruder = MMU2_NO_TOOL; + SetCurrentTool(MMU2_NO_TOOL); tool_change_extruder = MMU2_NO_TOOL; MakeSound(Confirm); } diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 0765e82ec..a39267c16 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -340,6 +340,8 @@ private: void UnloadInner(); void CutFilamentInner(uint8_t slot); + void SetCurrentTool(uint8_t ex); + ProtocolLogic logic; ///< implementation of the protocol logic layer uint8_t extruder; ///< currently active slot in the MMU ... somewhat... not sure where to get it from yet uint8_t tool_change_extruder; ///< only used for UI purposes