Browse Source

Fix G53 as prefix, G28 with CNC_COORDINATE_SYSTEMS (#15069)

Luu Lac 6 years ago
parent
commit
081e4506ca

+ 1
- 0
Marlin/src/gcode/calibrate/G28.cpp View File

@@ -453,6 +453,7 @@ void GcodeSuite::G28(const bool always_home_all) {
453 453
   ui.refresh();
454 454
 
455 455
   report_current_position();
456
+
456 457
   #if ENABLED(NANODLP_Z_SYNC)
457 458
     #if ENABLED(NANODLP_ALL_AXIS)
458 459
       #define _HOME_SYNC true       // For any axis, output sync text.

+ 20
- 13
Marlin/src/gcode/geometry/G53-G59.cpp View File

@@ -27,23 +27,21 @@
27 27
 
28 28
 #include "../../module/stepper.h"
29 29
 
30
+//#define DEBUG_M53
31
+
30 32
 /**
31 33
  * Select a coordinate system and update the workspace offset.
32 34
  * System index -1 is used to specify machine-native.
33 35
  */
34 36
 bool GcodeSuite::select_coordinate_system(const int8_t _new) {
35 37
   if (active_coordinate_system == _new) return false;
36
-  planner.synchronize();
37
-  float old_offset[XYZ] = { 0 }, new_offset[XYZ] = { 0 };
38
-  if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
39
-    COPY(old_offset, coordinate_system[active_coordinate_system]);
38
+  active_coordinate_system = _new;
39
+  float new_offset[XYZ] = { 0 };
40 40
   if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1))
41 41
     COPY(new_offset, coordinate_system[_new]);
42
-  active_coordinate_system = _new;
43 42
   LOOP_XYZ(i) {
44
-    const float diff = new_offset[i] - old_offset[i];
45
-    if (diff) {
46
-      position_shift[i] += diff;
43
+    if (position_shift[i] != new_offset[i]) {
44
+      position_shift[i] = new_offset[i];
47 45
       update_workspace_offset((AxisEnum)i);
48 46
     }
49 47
   }
@@ -60,11 +58,20 @@ bool GcodeSuite::select_coordinate_system(const int8_t _new) {
60 58
  * Marlin also uses G53 on a line by itself to go back to native space.
61 59
  */
62 60
 void GcodeSuite::G53() {
63
-  const int8_t _system = active_coordinate_system;
64
-  active_coordinate_system = -1;
65
-  if (parser.chain()) { // If this command has more following...
66
-    process_parsed_command();
67
-    active_coordinate_system = _system;
61
+  const int8_t old_system = active_coordinate_system;
62
+  select_coordinate_system(-1);   // Always remove workspace offsets
63
+  #ifdef DEBUG_M53
64
+    SERIAL_ECHOLNPGM("Go to native space");
65
+    report_current_position();
66
+  #endif
67
+
68
+  if (parser.chain()) {       // Command to chain?
69
+    process_parsed_command(); // ...process the chained command
70
+    select_coordinate_system(old_system);
71
+    #ifdef DEBUG_M53
72
+      SERIAL_ECHOLNPAIR("Go back to workspace ", old_system);
73
+      report_current_position();
74
+    #endif
68 75
   }
69 76
 }
70 77
 

+ 3
- 6
Marlin/src/gcode/geometry/G92.cpp View File

@@ -52,12 +52,9 @@ void GcodeSuite::G92() {
52 52
       case 1: {
53 53
         // Zero the G92 values and restore current position
54 54
         #if !IS_SCARA
55
-          LOOP_XYZ(i) {
56
-            const float v = position_shift[i];
57
-            if (v) {
58
-              position_shift[i] = 0;
59
-              update_workspace_offset((AxisEnum)i);
60
-            }
55
+          LOOP_XYZ(i) if (position_shift[i]) {
56
+            position_shift[i] = 0;
57
+            update_workspace_offset((AxisEnum)i);
61 58
           }
62 59
         #endif // Not SCARA
63 60
       } return;

+ 0
- 5
Marlin/src/module/motion.cpp View File

@@ -1325,11 +1325,6 @@ void set_axis_is_at_home(const AxisEnum axis) {
1325 1325
   SBI(axis_known_position, axis);
1326 1326
   SBI(axis_homed, axis);
1327 1327
 
1328
-  #if HAS_POSITION_SHIFT
1329
-    position_shift[axis] = 0;
1330
-    update_workspace_offset(axis);
1331
-  #endif
1332
-
1333 1328
   #if ENABLED(DUAL_X_CARRIAGE)
1334 1329
     if (axis == X_AXIS && (active_extruder == 1 || dual_x_carriage_mode == DXC_DUPLICATION_MODE)) {
1335 1330
       current_position[X_AXIS] = x_home_pos(active_extruder);

Loading…
Cancel
Save