|
@@ -9959,31 +9959,27 @@ void quickstop_stepper() {
|
9959
|
9959
|
* Use M206 to set these values directly.
|
9960
|
9960
|
*/
|
9961
|
9961
|
inline void gcode_M428() {
|
9962
|
|
- bool err = false;
|
|
9962
|
+ if (axis_unhomed_error()) return;
|
|
9963
|
+
|
|
9964
|
+ float diff[XYZ];
|
9963
|
9965
|
LOOP_XYZ(i) {
|
9964
|
|
- if (axis_homed[i]) {
|
9965
|
|
- const float base = (current_position[i] > (soft_endstop_min[i] + soft_endstop_max[i]) * 0.5) ? base_home_pos((AxisEnum)i) : 0,
|
9966
|
|
- diff = base - current_position[i];
|
9967
|
|
- if (WITHIN(diff, -20, 20)) {
|
9968
|
|
- set_home_offset((AxisEnum)i, diff);
|
9969
|
|
- }
|
9970
|
|
- else {
|
9971
|
|
- SERIAL_ERROR_START();
|
9972
|
|
- SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
|
9973
|
|
- LCD_ALERTMESSAGEPGM("Err: Too far!");
|
9974
|
|
- BUZZ(200, 40);
|
9975
|
|
- err = true;
|
9976
|
|
- break;
|
9977
|
|
- }
|
|
9966
|
+ diff[i] = base_home_pos((AxisEnum)i) - current_position[i];
|
|
9967
|
+ if (!WITHIN(diff[i], -20, 20) && home_dir((AxisEnum)i) > 0)
|
|
9968
|
+ diff[i] = -current_position[i];
|
|
9969
|
+ if (!WITHIN(diff[i], -20, 20)) {
|
|
9970
|
+ SERIAL_ERROR_START();
|
|
9971
|
+ SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
|
|
9972
|
+ LCD_ALERTMESSAGEPGM("Err: Too far!");
|
|
9973
|
+ BUZZ(200, 40);
|
|
9974
|
+ return;
|
9978
|
9975
|
}
|
9979
|
9976
|
}
|
9980
|
9977
|
|
9981
|
|
- if (!err) {
|
9982
|
|
- report_current_position();
|
9983
|
|
- LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
|
9984
|
|
- BUZZ(100, 659);
|
9985
|
|
- BUZZ(100, 698);
|
9986
|
|
- }
|
|
9978
|
+ LOOP_XYZ(i) set_home_offset((AxisEnum)i, diff[i]);
|
|
9979
|
+ report_current_position();
|
|
9980
|
+ LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
|
|
9981
|
+ BUZZ(100, 659);
|
|
9982
|
+ BUZZ(100, 698);
|
9987
|
9983
|
}
|
9988
|
9984
|
|
9989
|
9985
|
#endif // HAS_M206_COMMAND
|