From 46f4f2658d9c339f912dc18c45a2bdeb5c60736b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 19 Nov 2022 15:16:21 +0000 Subject: [PATCH] PFW-1432 Reduce LOC If verification test fails, increment load fail statistic --- Firmware/mmu2.cpp | 18 ++++++++---------- Firmware/mmu2.h | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 42442212c..7592743df 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -306,7 +306,7 @@ void MMU2::DecrementRetryAttempts() { } } -bool MMU2::FSensorCalibrationCheck() +bool MMU2::VerifyFilamentEnteredPTFE() { st_synchronize(); @@ -327,6 +327,7 @@ bool MMU2::FSensorCalibrationCheck() if (fsensorState) { + IncrementLoadFails(); return false; } else { // else, happy printing! :) @@ -339,10 +340,8 @@ bool MMU2::FSensorCalibrationCheck() } void MMU2::ToolChangeCommon(uint8_t slot){ - bool calibrationCheckResult = true; tool_change_extruder = slot; - do { - if (!calibrationCheckResult) unload(); // TODO cut filament + for(;;) { // while not successfully fed into extruder's PTFE tube for(;;) { logic.ToolChange(slot); // let the MMU pull the filament out and push a new one in if( manage_response(true, true) ) @@ -353,15 +352,14 @@ void MMU2::ToolChangeCommon(uint8_t slot){ // if we run out of retries, we must do something ... may be raise an error screen and allow the user to do something // but honestly - if the MMU restarts during every toolchange, // something else is seriously broken and stopping a print is probably our best option. - - // IncrementLoadFails(); // this should be contained in the while condition } // reset current position to whatever the planner thinks it is plan_set_e_position(current_position[E_AXIS]); - calibrationCheckResult = FSensorCalibrationCheck(); - } while (!calibrationCheckResult); // while not successfully fed into etruder's PTFE tube - // when we run out of feeding retries, we should call an unload + cut before trying again. - // + we need some error screen report + if (VerifyFilamentEnteredPTFE()) break; + else { // Prepare a retry attempt + unload(); // TODO cut filament + } + } extruder = slot; //filament change is finished SpoolJoin::spooljoin.setSlot(slot); diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 522a6e1b1..01f84f4c2 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -286,7 +286,7 @@ private: /// at any moment the test fails. Else test passes, and the E-motor retraction /// is reverted. /// @returns false if test fails, true otherwise - bool FSensorCalibrationCheck(); + bool VerifyFilamentEnteredPTFE(); /// Common processing of pushing filament into the extruder - shared by tool_change, load_to_nozzle and probably others void ToolChangeCommon(uint8_t slot);