From 9ad3aed0ef2ae8875e2aaace43f3507ee994c5d5 Mon Sep 17 00:00:00 2001
From: AnHardt <github@kitelab.de>
Date: Tue, 13 Nov 2018 11:56:10 +0100
Subject: [PATCH] Fix tool-change for MIXING_EXTRUDER with < 2 virtual tools
 (#12417)

Fix #12416

Better handling of `ENABLED(MIXING_EXTRUDER) && !MIXING_VIRTUAL_TOOLS > 1` -  to not fall through to the general case. Fix compiler warnings for `#elif EXTRUDERS < 2`.
---
 Marlin/src/module/tool_change.cpp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp
index 274a64ee47..a8a2ba3cfb 100644
--- a/Marlin/src/module/tool_change.cpp
+++ b/Marlin/src/module/tool_change.cpp
@@ -498,25 +498,28 @@ inline void invalid_extruder_error(const uint8_t e) {
  * previous tool out of the way and the new tool into place.
  */
 void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {
-  #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
+  #if ENABLED(MIXING_EXTRUDER)
 
-      if (tmp_extruder >= MIXING_VIRTUAL_TOOLS)
-        return invalid_extruder_error(tmp_extruder);
+    UNUSED(fr_mm_s);
+    UNUSED(no_move);
+    if (tmp_extruder >= MIXING_VIRTUAL_TOOLS)
+      return invalid_extruder_error(tmp_extruder);
+
+    #if MIXING_VIRTUAL_TOOLS >  1
       // T0-Tnnn: Switch virtual tool by changing the index to the mix
       mixer.T(uint_fast8_t(tmp_extruder));
-      UNUSED(fr_mm_s);
-      UNUSED(no_move);
+    #endif
 
   #elif EXTRUDERS < 2
 
+    UNUSED(fr_mm_s);
+    UNUSED(no_move);
     if (tmp_extruder) invalid_extruder_error(tmp_extruder);
     return;
 
   #else
 
-    #if DISABLED(MIXING_EXTRUDER)
-      planner.synchronize();
-    #endif
+    planner.synchronize();
 
     #if ENABLED(DUAL_X_CARRIAGE)  // Only T0 allowed if the Printer is in DXC_DUPLICATION_MODE or DXC_SCALED_DUPLICATION_MODE
       if (tmp_extruder != 0 && dxc_is_duplicating())
-- 
GitLab