Browse Source

Merge pull request #5228 from thinkyhead/rc_keep_last_mix

Fix DIRECT_MIXING_IN_G1 to preserve the previous mix
Scott Lahteine 8 years ago
parent
commit
5d23e52d75
1 changed files with 16 additions and 6 deletions
  1. 16
    6
      Marlin/Marlin_main.cpp

+ 16
- 6
Marlin/Marlin_main.cpp View File

@@ -2672,16 +2672,26 @@ static void homeaxis(AxisEnum axis) {
2672 2672
 
2673 2673
   #if ENABLED(DIRECT_MIXING_IN_G1)
2674 2674
     // Get mixing parameters from the GCode
2675
-    // Factors that are left out are set to 0
2676 2675
     // The total "must" be 1.0 (but it will be normalized)
2676
+    // If no mix factors are given, the old mix is preserved
2677 2677
     void gcode_get_mix() {
2678 2678
       const char* mixing_codes = "ABCDHI";
2679
-      for (int i = 0; i < MIXING_STEPPERS; i++) {
2680
-        float v = code_seen(mixing_codes[i]) ? code_value_float() : 0.0;
2681
-        NOLESS(v, 0.0);
2682
-        mixing_factor[i] = RECIPROCAL(v);
2679
+      byte mix_bits = 0;
2680
+      for (uint8_t i = 0; i < MIXING_STEPPERS; i++) {
2681
+        if (code_seen(mixing_codes[i])) {
2682
+          SBI(mix_bits, i);
2683
+          float v = code_value_float();
2684
+          NOLESS(v, 0.0);
2685
+          mixing_factor[i] = RECIPROCAL(v);
2686
+        }
2687
+      }
2688
+      // If any mixing factors were included, clear the rest
2689
+      // If none were included, preserve the last mix
2690
+      if (mix_bits) {
2691
+        for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
2692
+          if (!TEST(mix_bits, i)) mixing_factor[i] = 0.0;
2693
+        normalize_mix();
2683 2694
       }
2684
-      normalize_mix();
2685 2695
     }
2686 2696
   #endif
2687 2697
 

Loading…
Cancel
Save