[2.0.x] Extruder-Distinct Linear Advance K Factors (#11789)

This commit is contained in:
Sam Lane
2018-09-11 04:37:32 +01:00
committed by Scott Lahteine
parent fe9f088d60
commit 4f883d5971
5 changed files with 82 additions and 26 deletions

View File

@ -34,18 +34,38 @@
* K<factor> Set advance K factor
*/
void GcodeSuite::M900() {
#if EXTRUDERS < 2
constexpr uint8_t tmp_extruder = 0;
#else
const uint8_t tmp_extruder = parser.seenval('T') ? parser.value_int() : active_extruder;
if (tmp_extruder >= EXTRUDERS) {
SERIAL_PROTOCOLLNPGM("?T value out of range.");
return;
}
#endif
if (parser.seenval('K')) {
const float newK = parser.floatval('K');
if (WITHIN(newK, 0, 10)) {
planner.synchronize();
planner.extruder_advance_K = newK;
planner.extruder_advance_K[tmp_extruder] = newK;
}
else
SERIAL_PROTOCOLLNPGM("?K value out of range (0-10).");
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Advance K=", planner.extruder_advance_K);
#if EXTRUDERS < 2
SERIAL_ECHOLNPAIR("Advance K=", planner.extruder_advance_K[0]);
#else
SERIAL_ECHOPGM("Advance K");
LOOP_L_N(i, EXTRUDERS) {
SERIAL_CHAR(' '); SERIAL_ECHO(int(i));
SERIAL_CHAR('='); SERIAL_ECHO(planner.extruder_advance_K[i]);
}
SERIAL_EOL();
#endif
}
}