Add sanity checks to Linear Advance 1.5 (#9859)

This commit is contained in:
Sebastianv650 2018-03-01 09:10:39 +01:00 committed by Scott Lahteine
parent f7b44ac2a6
commit 951b65c2de
2 changed files with 23 additions and 8 deletions

View File

@ -10469,14 +10469,19 @@ inline void gcode_M502() {
* K<factor> Set advance K factor * K<factor> Set advance K factor
*/ */
inline void gcode_M900() { inline void gcode_M900() {
stepper.synchronize(); if (parser.seenval('K')) {
const float newK = parser.floatval('K');
const float newK = parser.floatval('K', -1); if (WITHIN(newK, 0, 10)) {
if (newK >= 0) planner.extruder_advance_K = newK; stepper.synchronize();
planner.extruder_advance_K = newK;
SERIAL_ECHO_START(); }
SERIAL_ECHOPAIR("Advance K=", planner.extruder_advance_K); else
SERIAL_EOL(); SERIAL_PROTOCOLLNPGM("?K value out of range (0-10).");
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Advance K=", planner.extruder_advance_K);
}
} }
#endif // LIN_ADVANCE #endif // LIN_ADVANCE

View File

@ -527,6 +527,16 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE,
#endif #endif
#endif #endif
/**
* Linear Advance 1.5 - Check K value range
*/
#if ENABLED(LIN_ADVANCE)
static_assert(
WITHIN(LIN_ADVANCE_K, 0, 10),
"LIN_ADVANCE_K must be a value from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."
);
#endif
/** /**
* Parking Extruder requirements * Parking Extruder requirements
*/ */