Преглед изворни кода

Fix M428

This fixes the old implementation of M428 which was broken, did not
match the website, and made no sense.
RowanMeara пре 7 година
родитељ
комит
227b96b28b
2 измењених фајлова са 18 додато и 21 уклоњено
  1. 1
    0
      Marlin/Marlin.h
  2. 17
    21
      Marlin/Marlin_main.cpp

+ 1
- 0
Marlin/Marlin.h Прегледај датотеку

@@ -439,6 +439,7 @@ void do_blocking_move_to_xy(const float &x, const float &y, const float &fr_mm_s
439 439
       || ENABLED(NOZZLE_CLEAN_FEATURE)                                             \
440 440
       || ENABLED(NOZZLE_PARK_FEATURE)                                              \
441 441
       || (ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(HOME_BEFORE_FILAMENT_CHANGE)) \
442
+      || HAS_M206_COMMAND                                                          \
442 443
     ) || ENABLED(NO_MOTION_BEFORE_HOMING)
443 444
 
444 445
 #if HAS_AXIS_UNHOMED_ERR

+ 17
- 21
Marlin/Marlin_main.cpp Прегледај датотеку

@@ -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

Loading…
Откажи
Сачувај