|
@@ -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
|
|