Update current position in M852

This commit is contained in:
Scott Lahteine 2017-12-10 21:29:10 -06:00
parent 7d2e850577
commit 117fc872a7

View file

@ -36,37 +36,47 @@
* K[yz_factor] - New YZ skew factor * K[yz_factor] - New YZ skew factor
*/ */
void GcodeSuite::M852() { void GcodeSuite::M852() {
const bool ijk = parser.seen('I') || parser.seen('S') uint8_t ijk = 0, badval = 0, setval = 0;
#if ENABLED(SKEW_CORRECTION_FOR_Z)
|| parser.seen('J') || parser.seen('K')
#endif
;
bool badval = false;
if (parser.seen('I') || parser.seen('S')) { if (parser.seen('I') || parser.seen('S')) {
++ijk;
const float value = parser.value_linear_units(); const float value = parser.value_linear_units();
if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
planner.xy_skew_factor = value; if (planner.xy_skew_factor != value) {
planner.xy_skew_factor = value;
++setval;
}
}
else else
badval = true; ++badval;
} }
#if ENABLED(SKEW_CORRECTION_FOR_Z) #if ENABLED(SKEW_CORRECTION_FOR_Z)
if (parser.seen('J')) { if (parser.seen('J')) {
++ijk;
const float value = parser.value_linear_units(); const float value = parser.value_linear_units();
if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
planner.xz_skew_factor = value; if (planner.xz_skew_factor != value) {
planner.xz_skew_factor = value;
++setval;
}
}
else else
badval = true; ++badval;
} }
if (parser.seen('K')) { if (parser.seen('K')) {
++ijk;
const float value = parser.value_linear_units(); const float value = parser.value_linear_units();
if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
planner.yz_skew_factor = value; if (planner.yz_skew_factor != value) {
planner.yz_skew_factor = value;
++setval;
}
}
else else
badval = true; ++badval;
} }
#endif #endif
@ -74,6 +84,13 @@ void GcodeSuite::M852() {
if (badval) if (badval)
SERIAL_ECHOLNPGM(MSG_SKEW_MIN " " STRINGIFY(SKEW_FACTOR_MIN) " " MSG_SKEW_MAX " " STRINGIFY(SKEW_FACTOR_MAX)); SERIAL_ECHOLNPGM(MSG_SKEW_MIN " " STRINGIFY(SKEW_FACTOR_MIN) " " MSG_SKEW_MAX " " STRINGIFY(SKEW_FACTOR_MAX));
// When skew is changed the current position changes
if (setval) {
set_current_from_steppers_for_axis(ALL_AXES);
SYNC_PLAN_POSITION_KINEMATIC();
report_current_position();
}
if (!ijk) { if (!ijk) {
SERIAL_ECHO_START(); SERIAL_ECHO_START();
SERIAL_ECHOPAIR(MSG_SKEW_FACTOR " XY: ", planner.xy_skew_factor); SERIAL_ECHOPAIR(MSG_SKEW_FACTOR " XY: ", planner.xy_skew_factor);