Finish M900 updates
This commit is contained in:
@ -47,6 +47,71 @@ void GcodeSuite::M900() {
|
||||
SERIAL_ECHOPGM(" value out of range");
|
||||
if (ten) SERIAL_ECHOPGM(" (0-10)");
|
||||
SERIAL_ECHOLNPGM(".");
|
||||
};
|
||||
|
||||
#if EXTRUDERS < 2
|
||||
constexpr uint8_t tool_index = 0;
|
||||
#else
|
||||
const uint8_t tool_index = parser.intval('T', active_extruder);
|
||||
if (tool_index >= EXTRUDERS) {
|
||||
echo_value_oor('T', false);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
float &kref = planner.extruder_advance_K[tool_index];
|
||||
|
||||
#if ENABLED(EXTRA_LIN_ADVANCE_K)
|
||||
float &lref = other_extruder_advance_K[tool_index];
|
||||
#endif
|
||||
|
||||
const float oldK = kref;
|
||||
float newK = oldK;
|
||||
|
||||
#if ENABLED(EXTRA_LIN_ADVANCE_K)
|
||||
|
||||
const bool old_slot = TEST(lin_adv_slot, tool_index), // The tool's current slot (0 or 1)
|
||||
new_slot = parser.boolval('S', old_slot); // The passed slot (default = current)
|
||||
|
||||
// If a new slot is being selected swap the current and
|
||||
// saved K values. Do here so K/L will apply correctly.
|
||||
if (new_slot != old_slot) { // Not the same slot?
|
||||
SET_BIT_TO(lin_adv_slot, tool_index, new_slot); // Update the slot for the tool
|
||||
newK = lref; // Get new K value from backup
|
||||
lref = oldK; // Save K to backup
|
||||
}
|
||||
|
||||
// Set the main K value. Apply if the main slot is active.
|
||||
if (parser.seenval('K')) {
|
||||
const float K = parser.value_float();
|
||||
if (!WITHIN(K, 0, 10)) echo_value_oor('K');
|
||||
else if (new_slot) lref = K; // S1 Knn
|
||||
else newK = K; // S0 Knn
|
||||
}
|
||||
|
||||
// Set the extra K value. Apply if the extra slot is active.
|
||||
if (parser.seenval('L')) {
|
||||
const float L = parser.value_float();
|
||||
if (!WITHIN(L, 0, 10)) echo_value_oor('L');
|
||||
else if (!new_slot) lref = L; // S0 Lnn
|
||||
else newK = L; // S1 Lnn
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (parser.seenval('K')) {
|
||||
const float K = parser.value_float();
|
||||
if (WITHIN(K, 0, 10))
|
||||
newK = K;
|
||||
else
|
||||
echo_value_oor('K');
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (newK != oldK) {
|
||||
planner.synchronize();
|
||||
kref = newK;
|
||||
}
|
||||
|
||||
if (!parser.seen_any()) {
|
||||
@ -79,70 +144,8 @@ void GcodeSuite::M900() {
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#if EXTRUDERS < 2
|
||||
constexpr uint8_t tool_index = 0;
|
||||
#else
|
||||
const uint8_t tool_index = parser.intval('T', active_extruder);
|
||||
if (tool_index >= EXTRUDERS) {
|
||||
echo_value_oor('T', false);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
float &kref = planner.extruder_advance_K[tool_index],
|
||||
&lref = other_extruder_advance_K[tool_index];
|
||||
const float oldK = kref, oldOther = lref;
|
||||
float newK = oldK;
|
||||
|
||||
#if ENABLED(EXTRA_LIN_ADVANCE_K)
|
||||
|
||||
const bool old_slot = TEST(lin_adv_slot, tool_index), // The tool's current slot (0 or 1)
|
||||
new_slot = parser.boolval('S', old_slot); // The passed slot (default = current)
|
||||
|
||||
// If a new slot is being selected swap the current and
|
||||
// saved K values. Do here so K/L will apply correctly.
|
||||
if (new_slot != old_slot) { // Not the same slot?
|
||||
SET_BIT_TO(lin_adv_slot, tool_index, new_slot); // Update the slot for the tool
|
||||
newK = oldOther; // Get new K value from backup
|
||||
lref = oldK; // Save K to backup
|
||||
}
|
||||
|
||||
// Set the main K value. Apply if the main slot is active.
|
||||
if (parser.seenval('K')) {
|
||||
const float newK = parser.value_float();
|
||||
if (!WITHIN(newK, 0, 10)) echo_value_oor('K');
|
||||
else if (new_slot) lref = newK; // S1 Knn
|
||||
else newK = newK; // S0 Knn
|
||||
}
|
||||
|
||||
// Set the extra K value. Apply if the extra slot is active.
|
||||
if (parser.seenval('L')) {
|
||||
const float newL = parser.value_float();
|
||||
if (!WITHIN(newL, 0, 10)) echo_value_oor('L');
|
||||
else if (!new_slot) lref = newL; // S0 Lnn
|
||||
else newK = newL; // S1 Lnn
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (parser.seenval('K')) {
|
||||
const float newK = parser.value_float();
|
||||
if (WITHIN(newK, 0, 10))
|
||||
newK = newK;
|
||||
else
|
||||
echo_value_oor('K');
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (newK != oldK) {
|
||||
planner.synchronize();
|
||||
kref = newK;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // LIN_ADVANCE
|
||||
|
Reference in New Issue
Block a user