Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DIRECT_MIXING_IN_G1 to preserve the previous mix #5228

Merged
merged 1 commit into from
Nov 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2672,16 +2672,26 @@ static void homeaxis(AxisEnum axis) {

#if ENABLED(DIRECT_MIXING_IN_G1)
// Get mixing parameters from the GCode
// Factors that are left out are set to 0
// The total "must" be 1.0 (but it will be normalized)
// If no mix factors are given, the old mix is preserved
void gcode_get_mix() {
const char* mixing_codes = "ABCDHI";
for (int i = 0; i < MIXING_STEPPERS; i++) {
float v = code_seen(mixing_codes[i]) ? code_value_float() : 0.0;
NOLESS(v, 0.0);
mixing_factor[i] = RECIPROCAL(v);
byte mix_bits = 0;
for (uint8_t i = 0; i < MIXING_STEPPERS; i++) {
if (code_seen(mixing_codes[i])) {
SBI(mix_bits, i);
float v = code_value_float();
NOLESS(v, 0.0);
mixing_factor[i] = RECIPROCAL(v);
}
}
// If any mixing factors were included, clear the rest
// If none were included, preserve the last mix
if (mix_bits) {
for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
if (!TEST(mix_bits, i)) mixing_factor[i] = 0.0;
normalize_mix();
}
normalize_mix();
}
#endif

Expand Down